Class: Vos::Box
- Inherits:
-
Object
show all
- Includes:
- Marks, Shell, Vfs
- Defined in:
- lib/vos/box.rb,
lib/vos/box/vfs.rb,
lib/vos/box/marks.rb,
lib/vos/box/shell.rb
Defined Under Namespace
Modules: Marks, Shell, Vfs
Instance Attribute Summary collapse
Attributes included from Shell
#env
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Shell
#bash, #bash_without_path, #default_env, #exec, #home, #wrap_cmd
Methods included from Marks
#clear_marks!, #has_mark?, #mark!, #marks_dir
Methods included from Vfs
#to_dir, #to_entry, #to_file
Constructor Details
#initialize(*args) ⇒ Box
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/vos/box.rb', line 5
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)
if first.is_a? Hash
options = first
options[:host] ||= 'localhost'
else
options = args[1] || {}
raise 'invalid arguments' unless options.is_a?(Hash)
options[:host] = first.to_s
end
@driver = options[:host] == 'localhost' ? Drivers::Local.new : Drivers::Ssh.new(options)
elsif args.size == 1
@driver = first
else
raise 'invalid arguments'
end
@driver.box = self
end
|
Instance Attribute Details
#driver ⇒ Object
32
33
34
|
# File 'lib/vos/box.rb', line 32
def driver
@driver
end
|
Class Method Details
.local ⇒ Object
53
|
# File 'lib/vos/box.rb', line 53
def local; @local ||= Box.new end
|
Instance Method Details
#close ⇒ Object
37
38
39
|
# File 'lib/vos/box.rb', line 37
def close
driver.close
end
|
#host ⇒ Object
48
|
# File 'lib/vos/box.rb', line 48
def host; driver.host end
|
#inspect ⇒ Object
Also known as:
to_s
45
|
# File 'lib/vos/box.rb', line 45
def inspect; driver.to_s end
|
#local? ⇒ Boolean
50
|
# File 'lib/vos/box.rb', line 50
def local?; host == 'localhost' end
|
#open(&block) ⇒ Object
34
35
36
|
# File 'lib/vos/box.rb', line 34
def open &block
driver.open &block
end
|