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
-
.[](key) ⇒ Object
Access the root filesystem of the local box.
-
.bash(command, options = {}) ⇒ Object
Run a bash command in the root of the local machine.
-
.box ⇒ Object
Create a box object for localhost.
-
.dir(filename) ⇒ Object
Create a dir object from the path of a provided file.
-
.launch_dir ⇒ Object
Create a dir object based on the shell's current working directory at the time the program was run.
-
.my_process ⇒ Object
puts "I'm using #my_process.mem blocks of memory".
-
.processes ⇒ Object
Rush.processes.filter(:cmdline => /ruby/).
-
.quote(path) ⇒ Object
Quote a path for use in backticks, say.
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, ={}) box.bash(command, ) end |
.box ⇒ Object
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.(::File.dirname(filename)) + '/'] end |
.launch_dir ⇒ Object
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_process ⇒ Object
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 |
.processes ⇒ Object
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 |