summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Bode <dan@puppetlabs.com>2012-10-02 18:52:34 -0700
committerDan Bode <dan@puppetlabs.com>2012-10-02 18:52:34 -0700
commit1564c473a93105399bd777e78090463156948f2e (patch)
tree2b2fe0fc7b889d0e69b7b7f88ef9b45ea67d8e92
parent6d3e6a137a3a1d8c369f5bab6ca5d5dd7b2ac67b (diff)
downloadpuppet-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.
-rw-r--r--lib/puppet/provider/ini_setting/ruby.rb21
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