Class: CapUtil::FakeCap
- Inherits:
-
Object
show all
- Defined in:
- lib/cap-util/fake_cap.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(*args) ⇒ FakeCap
Returns a new instance of FakeCap.
8
9
10
11
12
|
# File 'lib/cap-util/fake_cap.rb', line 8
def initialize(*args)
@struct = OpenStruct.new
@roles = []
@cmds_run = []
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
14
15
16
|
# File 'lib/cap-util/fake_cap.rb', line 14
def method_missing(method, *args, &block)
@struct.send(method, *args, &block)
end
|
Instance Attribute Details
#cmds_run ⇒ Object
Returns the value of attribute cmds_run.
6
7
8
|
# File 'lib/cap-util/fake_cap.rb', line 6
def cmds_run
@cmds_run
end
|
#roles ⇒ Object
Returns the value of attribute roles.
6
7
8
|
# File 'lib/cap-util/fake_cap.rb', line 6
def roles
@roles
end
|
Instance Method Details
#fetch(var_name) ⇒ Object
30
31
32
|
# File 'lib/cap-util/fake_cap.rb', line 30
def fetch(var_name)
self.send("fetch_#{var_name}")
end
|
#respond_to?(method) ⇒ Boolean
18
19
20
|
# File 'lib/cap-util/fake_cap.rb', line 18
def respond_to?(method)
@struct.respond_to?(method) ? true : super
end
|
#role(name, hostname, opts) ⇒ Object
34
35
36
|
# File 'lib/cap-util/fake_cap.rb', line 34
def role(name, hostname, opts)
@roles << [name, hostname, opts]
end
|
#run(cmd, *args) ⇒ Object
22
23
24
|
# File 'lib/cap-util/fake_cap.rb', line 22
def run(cmd, *args)
@cmds_run << cmd
end
|
#sudo(cmd, *args) ⇒ Object
26
27
28
|
# File 'lib/cap-util/fake_cap.rb', line 26
def sudo(cmd, *args)
run("sudo #{cmd}", *args)
end
|