Sha256: cf34d12bf2cd37f3bd794a8190d57b8b28384d37d2b3561434e642bba6d9d32b

Contents?: true

Size: 932 Bytes

Versions: 2

Compression:

Stored size: 932 Bytes

Contents

require 'lightchef'
require 'specinfra'

module Lightchef
  class Runner
    extend SpecInfra::Helper::Backend
    extend SpecInfra::Helper::DetectOS

    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

    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

    attr_accessor :backend
    attr_accessor :node

    def initialize(backend)
      @backend = backend
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lightchef-0.0.2 lib/lightchef/runner.rb
lightchef-0.0.1 lib/lightchef/runner.rb