Class: Nodectl::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/nodectl/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#recipeObject (readonly)

Returns the value of attribute recipe.



2
3
4
# File 'lib/nodectl/context.rb', line 2

def recipe
  @recipe
end

#serviceObject (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, options = {}, &blk)
  instance = Nodectl::Instance.new(service, command, options) 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, options = {})
  service.recipe_binding.run_action(action_name, options)
end