module Rush

The top-level Rush module has some convenience methods for accessing the local box.

Public Class Methods

[](key) click to toggle source

Access the root filesystem of the local box.

@param key [String] relative path. @example

Rush['/etc/hosts'].contents
# File lib/rush.rb, line 12
def self.[](key)
  box[key]
end
bash(command, options={}) click to toggle source

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

# File lib/rush.rb, line 38
def self.bash(command, options={})
  box.bash(command, options)
end
box() click to toggle source

Create a box object for localhost.

# File lib/rush.rb, line 61
def self.box
  @@box = Rush::Box.new
end
dir(filename) click to toggle source

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

@param filename [String] path that should be created. @example

Rush.dir(__FILE__).files
# File lib/rush.rb, line 22
def self.dir(filename)
  box[::File.expand_path(::File.dirname(filename)) + '/']
end
launch_dir() click to toggle source

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

@example

Rush.launch_dir.files
# File lib/rush.rb, line 32
def self.launch_dir
  box[::Dir.pwd + '/']
end
my_process() click to toggle source

Get the process object for this program's PID.

@example

puts "I'm using #{Rush.my_process.mem} blocks of memory"
# File lib/rush.rb, line 56
def self.my_process
  box.processes.filter(:pid => ::Process.pid).first
end
processes() click to toggle source

Pull the process list for the local machine.

@example

Rush.processes.filter(:cmdline => /ruby/)
# File lib/rush.rb, line 47
def self.processes
  box.processes
end
quote(path) click to toggle source

Quote a path for use in backticks, say.

# 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