Commit graph

69 commits

Author SHA1 Message Date
mh
6eb8f9ca98 introduce create_ini_settings
create_ini_settings is a function that allows you to create
ini_setting resources from a simple hash:

    $settings = {  section1 => {
        setting1 => val1
      },
      section2 => {
        setting2 => val2,
        setting3 => {
          ensure => absent
        }
      }
    }
    $defaults = {
      path => '/tmp/foo.ini'
    }
    create_ini_settings($settings,$defaults)

Will create the following resources

    ini_setting{'[section1] setting1':
      ensure  => present,
      section => 'section1',
      setting => 'setting1',
      value   => 'val1',
      path    => '/tmp/foo.ini',
    }
    ini_setting{'[section2] setting2':
      ensure  => present,
      section => 'section2',
      setting => 'setting2',
      value   => 'val2',
      path    => '/tmp/foo.ini',
    }
    ini_setting{'[section2] setting3':
      ensure  => absent,
      section => 'section2',
      setting => 'setting3',
      path    => '/tmp/foo.ini',
    }

This allows one to create much easier classes
that should be able to manage an arbritary set of
ini-style settings without having to specify each
one of them.
2015-01-28 22:09:34 +01:00
Morgan Haskel
be5fc47f00 Merge pull request #141 from petems/dry_up_spec_test
Replace code with pre-existing shared_example
2015-01-15 08:49:00 -08:00
Jonathan Tripathy
a21dd813b2 Removed pending unit tests.
This functionality does not exist and thus was cluttering the output.
2015-01-13 17:02:10 -08:00
Peter Souter
9280f81be5 Replace code with pre-existing shared_example
Noticed this when I was testing the module out with a FreeBSD host this code duplicates the shared_example used in the rest of the spec, so I DRY'd it up! 👍
2015-01-11 19:45:27 -08:00
Morgan Haskel
15f972d092 Rebase/fix the flexible k/v separator. 2014-12-18 10:45:30 -08:00
Pete Johns
c4fa6a614a Fix spec: predicates return booleans 2014-12-18 10:22:20 -08:00
Igor Galić
3288d415e9 WIP: Allow changing key value separator beyond indentation
We have many ini-style configuration files which use : as key value
separator. We'd like to be able to manage them with ini_setting as well.
This here is a naïve first attempt in that direction.

Please note that despite the fact that this *should* match, it's failing
unit tests.. This is a work in progress.
2014-12-18 10:22:20 -08:00
Pete Johns
3e46c13dc2 Fix Ruby 1.9.3 build 2014-11-08 18:52:20 +11:00
Pete Johns
efeb174427 Add spec for #123
I may have made this configuration file up
2014-11-08 18:47:08 +11:00
Pete Johns
d98e9bcb77 Add failing spec for KDE Configuration with braces in setting names
Refer https://github.com/puppetlabs/puppetlabs-inifile/pull/131
2014-11-08 17:05:59 +11:00
Huan Do
f343c41cd8 modify test to compare to a hash which better tests the state of each setting
also update @@COMMENTED_SETTING_REGEX to be roughly equal to "(\s*)[#;]+" + @@SETTING_REGEX
2014-09-12 16:55:24 -07:00
Huan Do
681f5c0cb4 fix issue where single characters settings were not being saved.
see https://github.com/boxen/puppet-git/issues/30
2014-09-08 23:12:09 -07:00
Morgan Haskel
7f54eb1279 Update spec_helper for consistency. 2014-08-28 12:39:44 -04:00
Hunter Haugen
09b574ea1d Merge pull request #115 from johnsyweb/handle-quotation-marks-in-section-names
Handle quotation marks in section names
2014-07-07 14:49:22 -07:00
Hunter Haugen
07c4827f53 Merge remote-tracking branch 'puppetlabs/master' into temp
Conflicts:
	Gemfile
2014-07-07 14:23:33 -07:00
Pete Johns
b3fed85b57 Spec for MODULES-1194
Ini_file module does not recognize section names with forward slashes in them

https://tickets.puppetlabs.com/browse/MODULES-1194
2014-07-04 14:31:39 +10:00
Pete Johns
069aa56d5c Merge remote-tracking branch 'origin/master' into handle-quotation-marks-in-section-names 2014-07-04 14:11:04 +10:00
Pete Johns
bd99244353 Test allowing $ signs in section names
Verifying that this PR addresses https://github.com/puppetlabs/puppetlabs-inifile/pull/98
2014-06-28 13:22:01 +10:00
Pete Johns
cabc678131 Merge branch 'deprecation-warnings' into handle-quotation-marks-in-section-names
This should fix the build.

If this change isn't desired,
./spec/unit/puppet/provider/ini_setting/ruby_spec.rb:1044 could be
changed to:

```ruby
provider.exists?.should be_nil
```
2014-06-26 21:55:30 +10:00
Pete Johns
49960e1c5e Handle quotation marks in section names
The section name appears on a line by itself, in square brackets (`[` and
`]`), all characters between the opening `[` and the closing `]` should
be considered to form the section name.
2014-06-26 21:42:45 +10:00
Pete Johns
41fc8bfbf5 Failing spec to describe my problem 2014-06-26 21:42:06 +10:00
Pete Johns
961447dfdf be_true and be_false are deprecated
Replace with `be true` and `be false` and make predicate return a
boolean.

> Methods that don't return a boolean, shouldn't end in a question mark.
-- https://github.com/bbatsov/ruby-style-guide#naming
2014-06-26 20:04:33 +10:00
Colleen Murphy
269672552d Sync files 2014-06-25 17:23:22 -07:00
Travis Fields
acc9f43ce5 Add windows support and testing nodesets 2014-06-23 16:56:40 -07:00
Morgan Haskel
842915d93f OSX doesn't support the -e flag to echo. 2014-06-12 11:04:09 -04:00
Hunter Haugen
6fb89f5850 Remove stderr checks because of deprecations 2014-05-29 09:56:09 -07:00
Morgan Haskel
783fa4d074 Update PE version requirement.
Also fixes spec_helper_acceptance to use install_puppet.
2014-05-21 19:37:17 -04:00
Michal Růžička
77854d55f8 Tests for the quote_char parameter. 2014-05-07 23:52:07 +02:00
Ashley Penney
2aceaef207 Convert to using .tmpdir instead of a hardcoded /tmp, so this works
on Windows too.
2014-02-27 23:09:24 +00:00
Hunter Haugen
eda726f09c It is actually all solaris 2014-02-27 14:18:59 -08:00
Hunter Haugen
7de1e3d7a4 Correct syntax 2014-02-27 13:16:23 -08:00
Hunter Haugen
49433d02bf Avoid multi-line grep on Solaris 10 2014-02-27 12:53:46 -08:00
Hunter Haugen
17a59b2b13 AIX exits with 2 on file doesn't exist. 2014-02-26 13:14:19 -08:00
Justin Stoller
25e7c2845e Remove basic spec
This removes the "basic_spec" as it is largely a sanity check against
the env/tooling.  The spec itself is problematic because in Puppet
Enterprise a module will be in 'sitemoduledir' or 'distmoduledir'
depending on whether it's included in PE as part of the distribution or
not.  However it will always be in 'distmoduledir' for FOSS.
2014-02-13 15:38:21 -08:00
Hunter Haugen
eda78abb6e (FM-161) Add beaker tests for parameter coverage 2014-01-27 10:33:45 -08:00
Rob Braden
6870dfed7d Add tests to cover settings with square brackets and quotes in the name 2013-12-04 17:16:19 -08:00
Jesse Newland
c058ee5d40 support spaces in sections 2013-12-02 12:57:02 -05:00
Richard Clamp
756e7ab166 .instances isn't stable between puppet versions
Extract the names from all the instances, and check they don't have the form
`[ '/green', '/red' ]` which they would if the inheritance doesn't work.
2013-07-16 14:38:45 +01:00
Richard Clamp
6f7b28bd59 fix syntax for 1.8.7 2013-07-16 13:42:38 +01:00
Richard Clamp
b0c8d5c34a allow for the namevar construction
The default type would always have a section as part of its namevar, but if
you're inheriting from ini_setting you may be modelling a flat file with no
sections.

This pushes the formation of the namevar from the section_name and setting into
a method, then demonstrates overriding it so that inherited_ini_setting can just
be

   inherited_ini_file { 'setting':
     value => '12',
   }

and continue to be purgable.
2013-07-16 10:18:15 +01:00
Richard Clamp
abd7065936 actually write a file in spec/fixtures/tmp
This is useful for testing with puppet apply
2013-07-16 10:18:15 +01:00
Richard Clamp
e5898439c5 add a test for creating subclassed instances 2013-07-16 10:18:15 +01:00
Richard Clamp
bd6d244610 add a type to test inheriting from ini_setting
In order to test with rspec-puppet we need to set up the fixtures, and test via
rake spec, so we change that too
2013-07-16 10:17:27 +01:00
Terry Wilson
5904c6f7b4 Allow empty values
It is a legitimate use case to set empty values; to override a
default when an empty value is acceptable for instance. This patch
changes the regex in three ways: it 1) removes the requirement for
a non-whitespace terminator on a setting value, 2) makes the value
match non-greedy so that the \s*$ at the end can catch the newline
and 3) changes the \s*=\s* to [ \t]*=[ \t]* because we don't want
that to capture *any* whitespace (like a newline).
2013-07-10 10:26:37 -05:00
Chris Price
cbea5dcd72 Fix bug in subsetting handling for new settings
Our new state variable `@quote_char` was not being initialized
property if you used `ini_subsetting` for a setting that did
not yet exist.  This fixes that bug.
2013-05-28 14:56:57 -07:00
Chris Price
1aa7e601f4 Better handling of quotes for subsettings
Prior to this commit, the `ini_subsetting` type assumed that
all of the settings strings were quoted, and always wrote
out the modified value with double-quotes around it.

This commit adds tests for the case where the original setting
is not quoted, and intelligently writes the modified setting
with the same quote character (or lack thereof) that the
original setting used.
2013-05-22 11:50:12 -07:00
Chris Price
6e318317fb Merge pull request #32 from bodepd/fix_test_failures
fix unit test failures
2013-04-01 17:36:49 -07:00
Dan Bode
f48cae87a0 fix unit test failures
the previous tests were stubbing global class instances
in a way that was causing other tests to fail.

This commit updates the tests, and introdcuces child classes which
can safely be stubbed (and more closely test the real behavior intended to
be tested here)
2013-04-01 17:27:10 -07:00
Chris Price
e824ab2aba Merge pull request #29 from kbrezina/subsetting
Added 'ini_subsetting' custom resource type
2013-03-25 11:00:41 -07:00
Karel Brezina
4351d8b9c8 Added 'ini_subsetting' custom resource type 2013-03-25 11:34:37 +01:00