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

File_line checks provided after param if no match is found #431

Merged
merged 2 commits into from
Apr 9, 2015

Conversation

bmjen
Copy link
Contributor

@bmjen bmjen commented Apr 9, 2015

This is a refactor of PRs:
Closes #427
Closes #327
Closes #317

Refactor eliminates the need to rewrite the file twice.

File.open(resource[:path], 'w') do |fh|
lines.each do |l|
fh.puts(regex.match(l) ? resource[:line] : l)
if (match_count == 0 and resource[:after])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want to use regex_after instead of resource[:after]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They would both logically be the same, nil or ! nil, just a matter of readability and preference I guess.

:path => @tmpfile,
:line => 'inserted = line',
:after => after,
:match => match,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is nitpicky, but the misalignment hurts my eyes. :(

Changed append line to open in 'w' mode and have to rewrite lines in order to append new line
underscorgan pushed a commit that referenced this pull request Apr 9, 2015
File_line checks provided after param if no match is found
@underscorgan underscorgan merged commit 5ee6e96 into puppetlabs:master Apr 9, 2015
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.

4 participants