Class: Kafo::PuppetConfigurer
- Inherits:
-
Object
- Object
- Kafo::PuppetConfigurer
- Defined in:
- lib/kafo/puppet_configurer.rb
Instance Attribute Summary collapse
-
#config_path ⇒ Object
readonly
Returns the value of attribute config_path.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(config_path, settings = {}) ⇒ PuppetConfigurer
constructor
A new instance of PuppetConfigurer.
- #write_config ⇒ Object
Constructor Details
#initialize(config_path, settings = {}) ⇒ PuppetConfigurer
Returns a new instance of PuppetConfigurer.
7 8 9 10 11 |
# File 'lib/kafo/puppet_configurer.rb', line 7 def initialize(config_path, settings = {}) @config_path = config_path @settings = {'reports' => ''}.merge(settings) @logger = KafoConfigure.logger end |
Instance Attribute Details
#config_path ⇒ Object (readonly)
Returns the value of attribute config_path.
5 6 7 |
# File 'lib/kafo/puppet_configurer.rb', line 5 def config_path @config_path end |
#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
13 14 15 |
# File 'lib/kafo/puppet_configurer.rb', line 13 def [](key) @settings[key] end |
#[]=(key, value) ⇒ Object
17 18 19 |
# File 'lib/kafo/puppet_configurer.rb', line 17 def []=(key, value) @settings[key] = value end |
#write_config ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/kafo/puppet_configurer.rb', line 21 def write_config @logger.debug("Writing Puppet config file at #{config_path}") File.open(config_path, 'w') do |file| file.puts '[main]' @settings.keys.sort.each do |key| file.puts "#{key} = #{@settings[key]}" end end end |