lib/vos/box.rb in vos-0.1.3 vs lib/vos/box.rb in vos-0.1.4
- old
+ new
@@ -1,11 +1,9 @@
module Vos
class Box
include Shell, Marks, Vfs
- attr_accessor :options
-
def initialize *args
first = args.first
if args.empty?
@driver = Drivers::Local.new
elsif first.is_a?(String) or first.is_a?(Symbol) or first.is_a?(Hash) and (args.size <= 2)
@@ -16,16 +14,16 @@
options = args[1] || {}
raise 'invalid arguments' unless options.is_a?(Hash)
options[:host] = first.to_s
end
- @driver = options[:host] == 'localhost' ? Drivers::Local.new(options) : Drivers::Ssh.new(options)
+ @driver = options[:host] == 'localhost' ? Drivers::Local.new : Drivers::Ssh.new(options)
elsif args.size == 1
@driver = first
else
raise 'invalid arguments'
- end
+ end
end
#
# driver
@@ -41,17 +39,17 @@
#
# Micelaneous
#
- def inspect
- driver.to_s
- # host = options[:host]
- # if host == 'localhost'
- # ''
- # else
- # host
- # end
- end
+ def inspect; driver.to_s end
alias_method :to_s, :inspect
+
+ def host; driver.host end
+
+ def local?; host == 'localhost' end
+
+ class << self
+ def local; @local ||= Box.new end
+ end
end
end
\ No newline at end of file