Module: Rush
- Defined in:
- lib/rush.rb,
lib/rush/shell.rb,
lib/rush/exceptions.rb,
lib/rush/embeddable_shell.rb,
lib/rush/shell/completion.rb
Overview
The top-level Rush module has some convenience methods for accessing the local box.
Defined Under Namespace
Modules: Commands, Completion, Connection, FindBy, HeadTail Classes: Access, BadAccessSpecifier, BashFailed, Box, Config, Dir, DoesNotExist, EmbeddableShell, Entry, Exception, FailedTransmit, File, NameAlreadyExists, NameCannotContainSlash, NotADir, NotAuthorized, Path, Process, ProcessSet, RushdNotRunning, SearchResults, Shell
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
Get the process object for this program’s PID.
-
.processes ⇒ Object
Pull the process list for the local machine.
-
.quote(path) ⇒ Object
Quote a path for use in backticks, say.
Class Method Details
.[](key) ⇒ Object
Access the root filesystem of the local box.
12 13 14 |
# File 'lib/rush.rb', line 12 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.
38 39 40 |
# File 'lib/rush.rb', line 38 def self.bash(command, ={}) box.bash(command, ) end |
.box ⇒ Object
Create a box object for localhost.
61 62 63 |
# File 'lib/rush.rb', line 61 def self.box @@box = Rush::Box.new end |
.dir(filename) ⇒ Object
Create a dir object from the path of a provided file.
22 23 24 |
# File 'lib/rush.rb', line 22 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.
32 33 34 |
# File 'lib/rush.rb', line 32 def self.launch_dir box[::Dir.pwd + '/'] end |
.my_process ⇒ Object
Get the process object for this program’s PID.
56 57 58 |
# File 'lib/rush.rb', line 56 def self.my_process box.processes.filter(:pid => ::Process.pid).first end |
.processes ⇒ Object
Pull the process list for the local machine.
47 48 49 |
# File 'lib/rush.rb', line 47 def self.processes box.processes end |
.quote(path) ⇒ Object
Quote a path for use in backticks, say.
66 67 68 |
# File 'lib/rush.rb', line 66 def self.quote(path) path.gsub(/(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF\n])/n, '\\').gsub(/\n/, "'\n'").sub(/^$/, "''") end |