Commit graph

57 commits

Author SHA1 Message Date
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
530b053f71 Update Modulefile and CHANGELOG for 0.10.1 release 2013-05-21 15:28:42 -07:00
Chris Price
6b198641ea Change constants to class variables
Because of the way that puppet's autoloader and pluginsync work,
modules on the master get loaded twice, which means that
you can't use Ruby constants at all w/o getting warning messages.

This commit changes all of the constants in `ini_file` to class
variables, which will avoid the warning messages.
2013-05-21 15:19:33 -07:00
Chris Price
fdfd6f8840 Merge pull request #39 from dalen/master
Style fixes
2013-04-22 14:14:57 -07:00
Erik Dalén
c4af8c31d2 Style fixes 2013-04-10 14:57:39 +02:00
Chris Price
fa74951ffe Merge pull request #36 from bodepd/travis_part_three
Add travisfile and Gemfile
2013-04-03 15:05:53 -07:00
Dan Bode
c2052b3cbd Add travisfile and Gemfile
in order to automate travis-ci tests.
2013-04-02 15:38:36 -07:00
Chris Price
ad38a08dc7 Update README.markdown 2013-04-02 15:28:34 -07:00
Chris Price
389531a6f5 Merge pull request #33 from bodepd/doc_update
Update Modulefile and Changelog, prepping for 0.10.0 release
2013-04-02 15:13:08 -07:00
Chris Price
6c245ef674 Update Modulefile and Changelog, prepping for 0.10.0 release
This commit also adds some comments clarifying the new code
that was added to support purging.
2013-04-02 15:10:43 -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
Chris Price
8064df6d00 Merge pull request #30 from bodepd/fix_nil_indentation
guard against nil indentation values
2013-03-12 11:11:09 -07:00
Dan Bode
5f71d7f0bd guard against nil indentation values
This commit is intended to resolves an issue where the indentation
value can be nil (which leads to a run time exception)

This occurrs in cases where a section is following by only one of more
comments.

The proposed fix is to guard against potential nil values where the
error occurs. This fix is idential to code used at line 125 of the same file.
2013-03-11 17:42:08 -07:00
Chris Price
5fdca54f6e Merge pull request #25 from bodepd/add_purging_support
Add purging support to ini file
2013-03-11 13:08:01 -07:00
Dan Bode
2f22483c87 Add purging support to ini file
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.
2013-03-04 15:38:58 -08:00
Chris Price
2008179ebe Merge pull request #28 from supercow/master
Fix the key_val_setting parameter
2013-02-06 08:18:32 -08:00
James Sweeny
b1aff63803 Fix test to use correct key_val_parameter 2013-02-05 08:26:18 +00:00
Chris Price
5e1d203a39 Added license file w/Apache 2.0 license 2012-11-06 13:53:15 -08:00
Chris Price
6a5323008e Update Modulefile/CHANGELOG ; final commit for v0.9.0 release 2012-11-02 12:45:11 -07:00
Chris Price
85afa277bc Merge pull request #20 from cprice-puppet/feature/master/detect-commented-settings
Add detection for commented versions of settings
2012-10-26 17:27:28 -07:00
Chris Price
a45ab65930 Add detection for commented versions of settings
This commit adds support for detecting commented versions of
settings in an existing version of an inifile.  If you are
setting a value for a setting that isn't currently set
in the file, but a commented version is found, then we
add the new setting immediately following the commented
version, rather than at the end of the section.
2012-10-26 17:24:37 -07:00
Chris Price
8a0d1fa1f2 Merge pull request #19 from cprice-puppet/feature/master/use-existing-indentation
Feature/master/use existing indentation
2012-10-22 11:05:39 -07:00
Chris Price
f0d443fed0 Refactor to clarify implementation of save
The `save` method was previously relying on some really
specific implementation details of the `section` class
(when the start/end_line would be nil, etc.).  This made
the code a bit hard to follow.

This commit introduces a few utility methods in the
`section` class (`is_new_section?`, `is_global?`), and
refactors the `save` method to use them... this makes
the logic a little easier to follow and should hopefully
make it easier to maintain.
2012-10-20 23:14:39 -07:00
Chris Price
e517148f4a Add example for ensure=absent 2012-10-20 22:16:36 -07:00
Chris Price
845fa707be Better handling of whitespace lines at ends of sections
This is another bit of cosmetic functionality; prior to
this commit, when adding a new setting to a section, we'd
write it on the very last line before the next section,
even if there was a chunk of trailing whitespace lines
at the end of the existing section.  This was functional,
but the output was not always particularly pleasant for
human consumption.

This commit tweaks things so that we insert new settings
just before the final chunk of whitespace lines in an
existing section.  This keeps things a bit cleaner.
2012-10-20 01:43:19 -07:00
Chris Price
c2c26de9b1 Respect indentation / spacing for existing sections and settings
This commit adds some cosmetic functionality.  The main two
improvements are:

* We'll now pay attention to indentation within existing
  sections, and when we write new settings or update
  existing ones, we'll match the existing indentation.

* When modifying existing settings, the regex now captures
  a greater portion of the original line and preserves it.
  Basically, the original whitespacing in the line should
  remain intact and only the value should be modified.
2012-10-20 00:08:06 -07:00
Chris Price
a5eebcfca0 Merge pull request #18 from cprice-puppet/feature/master/tweaks-to-setting-removal
Feature/master/tweaks to setting removal
2012-10-17 15:50:02 -07:00
Chris Price
cda30a6ab9 Minor tweaks to handling of removing settings
This commit makes some minor changes to how we handle removing
settings.  In particular, it updates all of the line numbers
of the various 'section' objects to correspond to the new
state of the world based on the removal of a line that appeared
before them.

Also adds one more test related to setting removal.
2012-10-17 13:27:28 -07:00
Dan Bode
1106d70e88 Add support for removing lines
This commit adds the ability to ensure that lines are absent.
2012-10-10 17:40:38 -07:00
Chris Price
842b2f06b2 Merge pull request #16 from bodepd/master
changes for child provider usage
2012-10-03 09:29:27 -07:00
Dan Bode
cbc90d3834 Make value a property
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.
2012-10-02 18:53:53 -07:00
Dan Bode
1564c473a9 Make ruby provider a better parent.
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.
2012-10-02 18:52:34 -07:00
Chris Price
6d3e6a137a Merge pull request #15 from reidmv/bug/master/spaces
Cool, thanks!
2012-10-01 09:31:59 -07:00
Reid Vandewiele
3829e20c49 Allow values with spaces to be parsed and set
Previously, the following stanza would fail as a result of the
ini_setting type not being able to parse spaces in setting values.

  ini_setting { 'main_config_version':
    ensure  => present,
    path    => '/etc/puppetlabs/puppet/puppet.conf',
    section => 'main',
    setting => 'config_version',
    value   => '/etc/puppetlabs/puppet/config_version.sh $environment',
  }

This commit modifes the SETTING_REGEX to account for spaces in setting values.
2012-09-29 12:39:00 -07:00
Chris Price
e81a69adb5 Updated CHANGELOG and Modulefile; final commit for 0.0.3 release 2012-09-24 10:20:45 -07:00
Chris Price
4ff4995d9e Merge pull request #9 from cprice-puppet/feature/master/allow-override-of-separator-str
Allow overriding separator string between key/val pairs
2012-09-20 12:53:59 -07:00
Chris Price
e527908b7c Add validation for key_val_separator
For now, the key_val_separator is required to contain
exactly one '=' character.  This commit simply validates
that that is the case.
2012-09-20 11:35:45 -07:00
Chris Price
8d1fdc5c29 Allow overriding separator string between key/val pairs
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.
2012-09-19 15:42:16 -07:00
Chris Price
310a4b1575 Merge pull request #5 from jtopjian/jtopjian-colon
Added support for colons in section names
2012-09-04 10:27:39 -07:00
Joe Topjian
4d3acd8fae Added tests for sections with colons 2012-09-04 17:16:05 +00:00
Joe Topjian
5de1731151 Fixed spec_helper.rb so original tests can pass. 2012-09-04 16:55:36 +00:00
Joe Topjian
63ddc0c926 Added support for colons in section names 2012-08-24 08:37:08 +00:00
Chris Price
04e2c5ea3b Add CHANGELOG and update README; final commit for 0.0.2 release 2012-08-20 14:13:37 -07:00
Chris Price
c57dab4903 Add support for "global" section at beginning of file
This commit does the following:

* Fixes a bug in ExternalIterator
* Adds support for a "global" section before the first named
  section at the beginning of the INI file
* Improves test coverage
2012-08-17 04:48:28 -07:00
Chris Price
4f0e7264e3 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
2012-08-16 21:50:20 -07:00
Chris Price
bf06644b4a Add Modulefile 2012-08-16 18:49:40 -07:00
Chris Price
1740608847 Merge pull request #4 from stephenrjohnson/miscfixes
Updated Section/ Setting  regex, fixed bug with empty files and updated provider to not care about variable type
2012-08-14 13:48:57 -07:00