diff options
author | Dan Bode <dan@puppetlabs.com> | 2012-10-02 18:52:34 -0700 |
---|---|---|
committer | Dan Bode <dan@puppetlabs.com> | 2012-10-02 18:52:34 -0700 |
commit | 1564c473a93105399bd777e78090463156948f2e (patch) | |
tree | 2b2fe0fc7b889d0e69b7b7f88ef9b45ea67d8e92 /lib/puppet | |
parent | 6d3e6a137a3a1d8c369f5bab6ca5d5dd7b2ac67b (diff) | |
download | puppet-inifile-1564c473a93105399bd777e78090463156948f2e.tar.gz puppet-inifile-1564c473a93105399bd777e78090463156948f2e.tar.bz2 |
Make ruby provider a better parent.
In order to allow the provider to be a parent for
other providers, I have implemented the following
methods: section, setting, file_path, separator so
that they can be overridden by child providers and
decouple this provider from its type.
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/provider/ini_setting/ruby.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/puppet/provider/ini_setting/ruby.rb b/lib/puppet/provider/ini_setting/ruby.rb index ba8165c..aca8ba2 100644 --- a/lib/puppet/provider/ini_setting/ruby.rb +++ b/lib/puppet/provider/ini_setting/ruby.rb @@ -6,15 +6,30 @@ Puppet::Type.type(:ini_setting).provide(:ruby) do end def create - ini_file.set_value(resource[:section], resource[:setting], resource[:value]) + ini_file.set_value(section, setting, resource[:value]) ini_file.save @ini_file = nil end + def section + resource[:section] + end + + def setting + resource[:setting] + end + + def file_path + resource[:path] + end + + def separator + resource[:key_val_separator] || '=' + end private def ini_file - @ini_file ||= Puppet::Util::IniFile.new(resource[:path], - resource[:key_val_separator]) + @ini_file ||= Puppet::Util::IniFile.new(file_path, separator) end + end |