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! 👍
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.
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
```
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.
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
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.
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.
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).
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.
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.