Bläddra i källkod

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
Chris Price 11 år sedan
förälder
incheckning
4f0e7264e3
5 ändrade filer med 42 tillägg och 3 borttagningar
  1. 22 0
      README.markdown
  2. 0 2
      README.md
  3. 3 1
      lib/puppet/util/ini_file.rb
  4. 1 0
      spec/unit/puppet/util/ini_file_spec.rb
  5. 16 0
      tests/ini_setting.pp

+ 22 - 0
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.
+

+ 0 - 2
README.md

@@ -1,2 +0,0 @@
-puppetlabs-inifile
-==================

+ 3 - 1
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

+ 1 - 0
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

+ 16 - 0
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"],
+}