summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Price <chris@pupppetlabs.com>2012-08-16 19:30:58 -0700
committerChris Price <chris@pupppetlabs.com>2012-08-16 21:50:20 -0700
commit4f0e7264e3c3089e489d05bbb4371c449b0ed78d (patch)
treefea109b142afa7bc9233dd651d849cd61cc1d327
parentbf06644b4a38a40a36c629e7dc619fba4c35c730 (diff)
downloadpuppet-inifile-4f0e7264e3c3089e489d05bbb4371c449b0ed78d.tar.gz
puppet-inifile-4f0e7264e3c3089e489d05bbb4371c449b0ed78d.tar.bz2
final commit for 0.0.1 release
* Updated README * Fixed a small bug that would be triggered if the file specified by `path` didn't exist. * Added a smoke test manifest
-rw-r--r--README.markdown22
-rw-r--r--README.md2
-rw-r--r--lib/puppet/util/ini_file.rb4
-rw-r--r--spec/unit/puppet/util/ini_file_spec.rb1
-rw-r--r--tests/ini_setting.pp16
5 files changed, 42 insertions, 3 deletions
diff --git a/README.markdown b/README.markdown
new file mode 100644
index 0000000..3e6532e
--- /dev/null
+++ b/README.markdown
@@ -0,0 +1,22 @@
+# INI-file module #
+
+This module provides resource types for use in managing INI-style configuration
+files. The main resource type is `ini_setting`, which is used to manage an
+individual setting in an INI file. Here's an example usage:
+
+ ini_setting { "sample setting":
+ path => '/tmp/foo.ini',
+ section => 'foo',
+ setting => 'foosetting',
+ value => 'FOO!',
+ ensure => present,
+ }
+
+A few noteworthy features:
+
+ * The module tries *hard* not to manipulate your file any more than it needs to.
+ In most cases, it should leave the original whitespace, comments, ordering,
+ etc. perfectly intact.
+ * Supports comments starting with either '#' or ';'.
+ * Will add missing sections if they don't exist.
+
diff --git a/README.md b/README.md
deleted file mode 100644
index 2c44dca..0000000
--- a/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-puppetlabs-inifile
-================== \ No newline at end of file
diff --git a/lib/puppet/util/ini_file.rb b/lib/puppet/util/ini_file.rb
index b951b3f..9fd08ad 100644
--- a/lib/puppet/util/ini_file.rb
+++ b/lib/puppet/util/ini_file.rb
@@ -12,7 +12,9 @@ module Util
@path = path
@section_names = []
@sections_hash = {}
- parse_file
+ if File.file?(@path)
+ parse_file
+ end
end
def section_names
diff --git a/spec/unit/puppet/util/ini_file_spec.rb b/spec/unit/puppet/util/ini_file_spec.rb
index 7e7458a..f2c6e20 100644
--- a/spec/unit/puppet/util/ini_file_spec.rb
+++ b/spec/unit/puppet/util/ini_file_spec.rb
@@ -23,6 +23,7 @@ baz=bazvalue
}
before :each do
+ File.should_receive(:file?).with("/my/ini/file/path") { true }
described_class.should_receive(:readlines).once.with("/my/ini/file/path") do
sample_content
end
diff --git a/tests/ini_setting.pp b/tests/ini_setting.pp
new file mode 100644
index 0000000..598bedf
--- /dev/null
+++ b/tests/ini_setting.pp
@@ -0,0 +1,16 @@
+ini_setting { "sample setting":
+ path => '/tmp/foo.ini',
+ section => 'foo',
+ setting => 'foosetting',
+ value => 'FOO!',
+ ensure => present,
+}
+
+ini_setting { "sample setting2":
+ path => '/tmp/foo.ini',
+ section => 'bar',
+ setting => 'barsetting',
+ value => 'BAR!',
+ ensure => present,
+ require => Ini_setting["sample setting"],
+}