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
The quote_char is used to quote the entire setting when it is modified
as a result of changes to some subsettings.
For an example let's assume we have a setting of this form:
JAVA_ARGS=-Xmx256m
and we want to add the '-Xms' parameter to the setting, for that purpose
we define a resource like this:
ini_subsetting { '-Xms':
ensure => present,
path => '/some/config/file',
section => '',
setting => 'JAVA_ARGS',
subsetting => '-Xms'
value => '256m',
}
which results into the following setting:
JAVA_ARGS=-Xmx256m -Xms256m
But this is not what we intended - if this setting is read by the bash
shell the '-Xms256m' parameter is interpreted as a command to be
executed rather than a value to be assigned to the JAVA_ARGS variable.
To fix this problem the quote_char parameter was added to the
ini_subsetting resource type, and we'll take advantage of it to fix the
problem in the above example like so:
ini_subsetting { '-Xms':
ensure => present,
path => '/some/config/file',
section => '',
setting => 'JAVA_ARGS',
quote_char => '"',
subsetting => '-Xms'
value => '256m',
}
which will result into:
JAVA_ARGS="-Xmx256m -Xms256m"
which is what we intended.
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.
If you follow the example in the README you may not have implemented the
:key_value_separator parameter in your type, and you get the wonderful failure
case:
Puppet::Error: Invalid parameter key_val_separator(:key_val_separator)
This change looks first, and if the user hasn't specified that attribute in
their type in their type, it falls back to '='
This commit adds purging to ini file native types.
Purging will only work for child providers that
implement the method: self.file_path. This is
because collecting all instances of the type (
which is a requirement for purging) is only possible
when the path of the file that is being managed
can be accessed by the class instance (in the
method self.instances.)
This commit adds the following method to the internal
of the ini_file:
- get_settings - has of all settings/values for
a given section
It also adds the following method to the section
class:
- setting_names - list of all setting names in a
section.
These methods are required for the instances method
to be able to list the values for all settings of
each section.
This commit converts value to a property so that it
can be managed and modified when a file already has
a value set.
It was previously treating the line creation state
the same as the update case, which is not in
alignment with Puppet's model.
In order to allow the provider to be a parent for
other providers, I have implemented the following
methods: section, setting, file_path, separator so
that they can be overridden by child providers and
decouple this provider from its type.
This introduces a new parameter, 'key_val_separator', which
can be set in order to override the string that is used
as a separator between the key/value pair of a setting line.
The default is ' = ', but you could set the param to '=' if
you don't want to include whitespace in your settings file.
characters. Fixed writing to file without any sections at all.
Fixed exists checking for variable type by always casting to string
and added all the tests for the above items.