Class: Kafo::PuppetConfigurer
- Inherits:
-
Object
- Object
- Kafo::PuppetConfigurer
- Defined in:
- lib/kafo/puppet_configurer.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #config_path ⇒ Object
-
#initialize(settings = {}) ⇒ PuppetConfigurer
constructor
A new instance of PuppetConfigurer.
- #write_config ⇒ Object
Constructor Details
#initialize(settings = {}) ⇒ PuppetConfigurer
Returns a new instance of PuppetConfigurer.
7 8 9 10 11 |
# File 'lib/kafo/puppet_configurer.rb', line 7 def initialize(settings = {}) @settings = {'reports' => ''}.merge(settings) @logger = KafoConfigure.logger @temp_file = Tempfile.new(['kafo_puppet', '.conf']) end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
5 6 7 |
# File 'lib/kafo/puppet_configurer.rb', line 5 def logger @logger end |
Instance Method Details
#[](key) ⇒ Object
17 18 19 |
# File 'lib/kafo/puppet_configurer.rb', line 17 def [](key) @settings[key] end |
#[]=(key, value) ⇒ Object
21 22 23 |
# File 'lib/kafo/puppet_configurer.rb', line 21 def []=(key, value) @settings[key] = value end |
#config_path ⇒ Object
13 14 15 |
# File 'lib/kafo/puppet_configurer.rb', line 13 def config_path @temp_file.path end |
#write_config ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/kafo/puppet_configurer.rb', line 25 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 |