Module: Rush

Defined in:
lib/rush.rb,
lib/rush/shell.rb,
lib/rush/exceptions.rb,
lib/rush/embeddable_shell.rb

Overview

Rush::Shell is used to create an interactive shell. It is invoked by the rush binary.

Defined Under Namespace

Modules: Commands, Connection, FindBy, HeadTail Classes: Access, BadAccessSpecifier, BashFailed, Box, Config, Dir, DoesNotExist, EmbeddableShell, Entry, Exception, FailedTransmit, File, NameAlreadyExists, NameCannotContainSlash, NotADir, NotAuthorized, Process, ProcessSet, RushdNotRunning, SearchResults, Shell, SshTunnel

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object

Access the root filesystem of the local box. Example:

Rush['/etc/hosts'].contents


10
11
12
# File 'lib/rush.rb', line 10

def self.[](key)
  box[key]
end

.bash(command, options = {}) ⇒ Object

Run a bash command in the root of the local machine. Equivalent to Rush::Box.new.bash.



33
34
35
# File 'lib/rush.rb', line 33

def self.bash(command, options={})
  box.bash(command, options)
end

.boxObject

Create a box object for localhost.



54
55
56
# File 'lib/rush.rb', line 54

def self.box
  @@box = Rush::Box.new
end

.dir(filename) ⇒ Object

Create a dir object from the path of a provided file. Example:

Rush.dir(__FILE__).files


18
19
20
# File 'lib/rush.rb', line 18

def self.dir(filename)
  box[::File.expand_path(::File.dirname(filename)) + '/']
end

.launch_dirObject

Create a dir object based on the shell's current working directory at the time the program was run. Example:

Rush.launch_dir.files


27
28
29
# File 'lib/rush.rb', line 27

def self.launch_dir
  box[::Dir.pwd + '/']
end

.my_processObject

puts "I'm using #mem blocks of memory"



49
50
51
# File 'lib/rush.rb', line 49

def self.my_process
  box.processes.filter(:pid => ::Process.pid).first
end

.processesObject

Rush.processes.filter(:cmdline => /ruby/)



41
42
43
# File 'lib/rush.rb', line 41

def self.processes
  box.processes
end

.quote(path) ⇒ Object

Quote a path for use in backticks, say.



59
60
61
# File 'lib/rush.rb', line 59

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