Sha256: 1045071ac3f9880b91478d8ba03061739300729059605863cb7c7e77ad616317

Contents?: true

Size: 761 Bytes

Versions: 8

Compression:

Stored size: 761 Bytes

Contents

require 'tempfile'

module Kafo
  class PuppetConfigurer
    attr_reader :logger

    def initialize(settings = {})
      @settings = {'reports' => ''}.merge(settings)
      @logger = KafoConfigure.logger
      @temp_file = Tempfile.new(['kafo_puppet', '.conf'])
    end

    def config_path
      @temp_file.path
    end

    def [](key)
      @settings[key]
    end

    def []=(key, value)
      @settings[key] = value
    end

    def write_config
      @logger.debug("Writing Puppet config file at #{@temp_file.path}")
      @temp_file.open
      @temp_file.truncate(0)
      @temp_file.puts '[main]'
      @settings.keys.sort.each do |key|
        @temp_file.puts "#{key} = #{@settings[key]}"
      end
    ensure
      @temp_file.close
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
kafo-3.0.0 lib/kafo/puppet_configurer.rb
kafo-2.1.0 lib/kafo/puppet_configurer.rb
kafo-2.0.2 lib/kafo/puppet_configurer.rb
kafo-2.0.1 lib/kafo/puppet_configurer.rb
kafo-2.0.0 lib/kafo/puppet_configurer.rb
kafo-1.0.8 lib/kafo/puppet_configurer.rb
kafo-1.0.7 lib/kafo/puppet_configurer.rb
kafo-1.0.6 lib/kafo/puppet_configurer.rb