Sha256: ba94879c23dc3597b0ab2d9298498db67db9d976fca04648faebdf41eb220ea3

Contents?: true

Size: 743 Bytes

Versions: 24

Compression:

Stored size: 743 Bytes

Contents

module Kafo
  class MigrationContext

    attr_accessor :scenario, :answers

    def self.execute(scenario, answers, &migration)
      context = new(scenario, answers)
      context.instance_eval(&migration)
      return context.scenario, context.answers
    end

    def initialize(scenario, answers)
      @scenario = scenario
      @answers = answers
    end

    def logger
      KafoConfigure.logger
    end

    def facts
      self.class.facts
    end

    private

    def self.facts
      @facts ||= begin
        YAML.load(`#{facter_path} --yaml`).inject({}) { |facts,(k,v)| facts.update(k.to_sym => v) }
      end
    end

    def self.facter_path
      @facter_path ||= PuppetCommand.search_puppet_path('facter')
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
kafo-2.0.2 lib/kafo/migration_context.rb
kafo-2.0.1 lib/kafo/migration_context.rb
kafo-2.0.0 lib/kafo/migration_context.rb
kafo-1.0.8 lib/kafo/migration_context.rb
kafo-1.0.7 lib/kafo/migration_context.rb
kafo-1.0.6 lib/kafo/migration_context.rb
kafo-1.0.5 lib/kafo/migration_context.rb
kafo-1.0.4 lib/kafo/migration_context.rb
kafo-0.9.8 lib/kafo/migration_context.rb
kafo-1.0.3 lib/kafo/migration_context.rb
kafo-0.9.7 lib/kafo/migration_context.rb
kafo-1.0.2 lib/kafo/migration_context.rb
kafo-1.0.1 lib/kafo/migration_context.rb
kafo-1.0.0 lib/kafo/migration_context.rb
kafo-0.9.6 lib/kafo/migration_context.rb
kafo-0.9.5 lib/kafo/migration_context.rb
kafo-0.9.4 lib/kafo/migration_context.rb
kafo-0.9.3 lib/kafo/migration_context.rb
kafo-0.9.2 lib/kafo/migration_context.rb
kafo-0.9.1 lib/kafo/migration_context.rb