Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/master/use existing indentation #19

Merged
merged 4 commits into from Oct 22, 2012

Conversation

cprice404
Copy link

commit f0d443f
Author: Chris Price chris@puppetlabs.com
Date: Sat Oct 20 23:14:39 2012 -0700

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.

commit e517148
Author: Chris Price chris@puppetlabs.com
Date: Sat Oct 20 22:16:36 2012 -0700

Add example for `ensure=absent`

commit 845fa70
Author: Chris Price chris@puppetlabs.com
Date: Sat Oct 20 00:24:37 2012 -0700

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.

commit c2c26de
Author: Chris Price chris@puppetlabs.com
Date: Sat Oct 20 00:08:06 2012 -0700

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.

Chris Price added 4 commits October 20, 2012 00:08
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.
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.
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.
cprice404 pushed a commit that referenced this pull request Oct 22, 2012
…-indentation

Feature/master/use existing indentation
@cprice404 cprice404 merged commit 8a0d1fa into master Oct 22, 2012
@tphoney tphoney deleted the feature/master/use-existing-indentation branch July 19, 2017 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants