Class: Nodectl::Context
- Inherits:
-
Object
- Object
- Nodectl::Context
- Defined in:
- lib/nodectl/context.rb
Instance Attribute Summary collapse
-
#recipe ⇒ Object
readonly
Returns the value of attribute recipe.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Instance Method Summary collapse
- #chdir(dir) ⇒ Object
- #exec(*args) ⇒ Object
-
#initialize(recipe, service, methods = nil) ⇒ Context
constructor
A new instance of Context.
- #run(command, options = {}, &blk) ⇒ Object
- #run_action(action_name, options = {}) ⇒ Object
Constructor Details
#initialize(recipe, service, methods = nil) ⇒ Context
Returns a new instance of Context.
5 6 7 8 9 10 11 12 |
# File 'lib/nodectl/context.rb', line 5 def initialize(recipe, service, methods = nil) @recipe = recipe @service = service if methods extend methods end end |
Instance Attribute Details
#recipe ⇒ Object (readonly)
Returns the value of attribute recipe.
2 3 4 |
# File 'lib/nodectl/context.rb', line 2 def recipe @recipe end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
3 4 5 |
# File 'lib/nodectl/context.rb', line 3 def service @service end |
Instance Method Details
#chdir(dir) ⇒ Object
18 19 20 |
# File 'lib/nodectl/context.rb', line 18 def chdir(dir) Dir.chdir(dir) end |
#exec(*args) ⇒ Object
14 15 16 |
# File 'lib/nodectl/context.rb', line 14 def exec(*args) Process.exec(*args) end |
#run(command, options = {}, &blk) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/nodectl/context.rb', line 22 def run(command, = {}, &blk) instance = Nodectl::Instance.new(service, command, ) do instance_eval &blk if blk end instance.run instance end |
#run_action(action_name, options = {}) ⇒ Object
31 32 33 |
# File 'lib/nodectl/context.rb', line 31 def run_action(action_name, = {}) service.recipe_binding.run_action(action_name, ) end |