From 4f0e7264e3c3089e489d05bbb4371c449b0ed78d Mon Sep 17 00:00:00 2001 From: Chris Price Date: Thu, 16 Aug 2012 19:30:58 -0700 Subject: 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 --- README.markdown | 22 ++++++++++++++++++++++ README.md | 2 -- lib/puppet/util/ini_file.rb | 4 +++- spec/unit/puppet/util/ini_file_spec.rb | 1 + tests/ini_setting.pp | 16 ++++++++++++++++ 5 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 README.markdown delete mode 100644 README.md create mode 100644 tests/ini_setting.pp 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"], +} -- cgit v1.2.3