Sha256: d564fbabc699d6f446876ac50ed5a47daa912a2367165089cf82b4c4b076cc0d
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
# A rush box is a single unix machine - a server, workstation, or VPS instance. # # Specify a box by hostname (default = 'localhost'). If the box is remote, the # first action performed will attempt to open an ssh tunnel. Use square # brackets to access the filesystem, or processes to access the process list. # # Example: # # local = Rush::Box.new('localhost') # local['/etc/hosts'].contents # local.processes # class Rush::Box attr_reader :host # Instantiate a box. No action is taken to make a connection until you try # to perform an action. If the box is remote, an ssh tunnel will be opened. # Specify a username with the host if the remote ssh user is different from # the local one (e.g. Rush::Box.new('user@host')). def initialize(host='localhost') @host = host end def to_s # :nodoc: host end def inspect # :nodoc: host end # Access / on the box. def filesystem Rush::Entry.factory('/', self) end # Look up an entry on the filesystem, e.g. box['/path/to/some/file']. # Returns a subclass of Rush::Entry - either Rush::Dir if you specifiy # trailing slash, or Rush::File otherwise. def [](key) filesystem[key] end # Get the list of processes currently running on the box. Returns an array # of Rush::Process. def processes connection.processes.map do |ps| Rush::Process.new(ps, self) end end def connection # :nodoc: @connection ||= make_connection end def make_connection # :nodoc: host == 'localhost' ? Rush::Connection::Local.new : Rush::Connection::Remote.new(host) end def ==(other) # :nodoc: host == other.host end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rush-0.1 | lib/rush/box.rb |