Class: Lightchef::Runner

Inherits:
Object
  • Object
show all
Extended by:
SpecInfra::Helper::Backend, SpecInfra::Helper::DetectOS
Defined in:
lib/lightchef/runner.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(backend) ⇒ Runner

Returns a new instance of Runner.



34
35
36
# File 'lib/lightchef/runner.rb', line 34

def initialize(backend)
  @backend = backend
end

Instance Attribute Details

#backendObject

Returns the value of attribute backend.



31
32
33
# File 'lib/lightchef/runner.rb', line 31

def backend
  @backend
end

#nodeObject

Returns the value of attribute node.



32
33
34
# File 'lib/lightchef/runner.rb', line 32

def node
  @node
end

Class Method Details

.new_from_options(options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/lightchef/runner.rb', line 9

def self.new_from_options(options)
  self.new(backend_for(:exec)).tap do |runner|
    node = if options[:node_json]
             node_json_path = File.expand_path(options[:node_json])
             Logger.debug "Loading node data from #{node_json_path} ..."
             Node.new_from_file(node_json_path)
           else
             Node.new
           end
    runner.node = node
  end
end

.run(recipe_files, options = {}) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/lightchef/runner.rb', line 22

def self.run(recipe_files, options={})
  runner = new_from_options(options)

  recipe_files.each do |path|
    recipe = Recipe.new(File.expand_path(path))
    recipe.run(runner)
  end
end