Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds env.rb note to README #18

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,54 @@ PATH
remote: .
specs:
rush (0.6.8)
encase (~> 0.1.2)
session

GEM
remote: http://rubygems.org/
specs:
fattr (2.2.0)
coderay (1.1.0)
diff-lcs (1.2.5)
encase (0.1.2)
git (1.2.5)
jeweler (1.8.3)
bundler (~> 1.0)
git (>= 1.2.5)
rake
rdoc
json (1.6.5)
method_source (0.8.2)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
rspec (1.2.9)
session (3.1.0)
fattr
rspec (3.0.0)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-core (3.0.4)
rspec-support (~> 3.0.0)
rspec-expectations (3.0.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.0.0)
rspec-mocks (3.0.4)
rspec-support (~> 3.0.0)
rspec-support (3.0.4)
session (3.2.0)
slop (3.6.0)

PLATFORMS
ruby

DEPENDENCIES
jeweler (>= 1.8.3)
pry
rake (>= 0.9.0)
rspec (~> 1.2.0)
rspec (~> 3.0.0)
rush!

BUNDLED WITH
1.10.6
2 changes: 2 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ In rush:

Run the "rush" binary to enter the interactive shell.

Upon shell invocation, code will be run from ~/.rush/env.rb, which thus can be thought of as a "rushrc".

== Remote access and clustering

rush can control any number of remote machines from a single location. Copy files or directories between servers as seamlessly as if it was all local.
Expand Down
58 changes: 18 additions & 40 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,60 +1,38 @@
require 'rake'

require 'jeweler'

Jeweler::Tasks.new do |s|
s.name = "rush"
s.summary = "A Ruby replacement for bash+ssh."
s.description = "A Ruby replacement for bash+ssh, providing both an interactive shell and a library. Manage both local and remote unix systems from a single client."
s.author = "Adam Wiggins"
s.email = "[email protected]"
s.homepage = "http://rush.heroku.com/"
s.executables = [ "rush", "rushd" ]
s.rubyforge_project = "ruby-shell"
s.has_rdoc = true

s.add_dependency 'session'

s.files = FileList["[A-Z]*", "{bin,lib,spec}/**/*"]
end

Jeweler::GemcutterTasks.new

######################################################

require 'spec/rake/spectask'
require 'rspec/core/rake_task'

desc "Run all specs"
Spec::Rake::SpecTask.new('spec') do |t|
t.spec_files = FileList['spec/*_spec.rb']
RSpec::Core::RakeTask.new('spec') do |t|
t.pattern = 'spec/*_spec.rb'
end

desc "Print specdocs"
Spec::Rake::SpecTask.new(:doc) do |t|
t.spec_opts = ["--format", "specdoc", "--dry-run"]
t.spec_files = FileList['spec/*_spec.rb']
RSpec::Core::RakeTask.new(:doc) do |t|
t.rspec_opts = ["--format", "specdoc", "--dry-run"]
t.pattern = 'spec/*_spec.rb'
end

desc "Run all examples with RCov"
Spec::Rake::SpecTask.new('rcov') do |t|
t.spec_files = FileList['spec/*_spec.rb']
t.rcov = true
t.rcov_opts = ['--exclude', 'examples']
RSpec::Core::RakeTask.new('rcov') do |t|
t.pattern = 'spec/*_spec.rb'
t.rcov = true
t.rcov_opts = ['--exclude', 'examples']
end

task :default => :spec

######################################################

require 'rake/rdoctask'
require 'rdoc/task'

Rake::RDocTask.new do |t|
t.rdoc_dir = 'rdoc'
t.title = "rush, a Ruby replacement for bash+ssh"
t.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
t.options << '--charset' << 'utf-8'
t.rdoc_files.include('README.rdoc')
t.rdoc_files.include('lib/rush.rb')
t.rdoc_files.include('lib/rush/*.rb')
t.rdoc_dir = 'rdoc'
t.title = "rush, a Ruby replacement for bash+ssh"
t.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
t.options << '--charset' << 'utf-8'
t.rdoc_files.include('README.rdoc')
t.rdoc_files.include('lib/rush.rb')
t.rdoc_files.include('lib/rush/*.rb')
end

91 changes: 46 additions & 45 deletions lib/rush.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,69 @@
# The top-level Rush module has some convenience methods for accessing the
# local box.
module Rush
# Access the root filesystem of the local box. Example:
#
# Rush['/etc/hosts'].contents
#
def self.[](key)
box[key]
end
# Access the root filesystem of the local box. Example:
#
# Rush['/etc/hosts'].contents
#
def self.[](key)
box[key]
end

# Create a dir object from the path of a provided file. Example:
#
# Rush.dir(__FILE__).files
#
def self.dir(filename)
box[::File.expand_path(::File.dirname(filename)) + '/']
end
# Create a dir object from the path of a provided file. Example:
#
# Rush.dir(__FILE__).files
#
def self.dir(filename)
box[::File.expand_path(::File.dirname(filename)) + '/']
end

# Create a dir object based on the shell's current working directory at the
# time the program was run. Example:
#
# Rush.launch_dir.files
#
def self.launch_dir
box[::Dir.pwd + '/']
end
# Create a dir object based on the shell's current working directory at the
# time the program was run. Example:
#
# Rush.launch_dir.files
#
def self.launch_dir
box[::Dir.pwd + '/']
end

# Run a bash command in the root of the local machine. Equivalent to
# Rush::Box.new.bash.
def self.bash(command, options={})
box.bash(command, options)
end
# Run a bash command in the root of the local machine. Equivalent to
# Rush::Box.new.bash.
def self.bash(command, options={})
box.bash(command, options)
end

# Pull the process list for the local machine. Example:
# Pull the process list for the local machine. Example:
#
# Rush.processes.filter(:cmdline => /ruby/)
#
def self.processes
box.processes
end
#
def self.processes
box.processes
end

# Get the process object for this program's PID. Example:
# Get the process object for this program's PID. Example:
#
# puts "I'm using #{Rush.my_process.mem} blocks of memory"
#
def self.my_process
box.processes.filter(:pid => ::Process.pid).first
end
#
def self.my_process
box.processes.filter(:pid => ::Process.pid).first
end

# Create a box object for localhost.
def self.box
@@box = Rush::Box.new
end
# Create a box object for localhost.
def self.box
@@box = Rush::Box.new
end

# Quote a path for use in backticks, say.
def self.quote(path)
path.gsub(/(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF\n])/n, '\\').gsub(/\n/, "'\n'").sub(/^$/, "''")
end
# Quote a path for use in backticks, say.
def self.quote(path)
path.gsub(/(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF\n])/n, '\\').gsub(/\n/, "'\n'").sub(/^$/, "''")
end
end

module Rush::Connection; end

$LOAD_PATH.unshift(File.dirname(__FILE__))

require 'rush/app'
require 'rush/exceptions'
require 'rush/config'
require 'rush/commands'
Expand Down
4 changes: 4 additions & 0 deletions lib/rush/app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Rush
class App
end
end
Loading