chef_attrdoc 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/chef_attrdoc.rb CHANGED
@@ -139,16 +139,23 @@ module ChefAttrdoc
139
139
  # TODO find a cleaner way and do this in one step
140
140
  content = f.read
141
141
  if content =~ /\nAttributes\s*=+\s*\n/
142
- updated = content.gsub(/(?<before>.*\nAttributes\s*=+\s*?\n)\n*(?m:.+?)(?<after>\n.+\s*\n=+.*)/,
142
+ updated = content.sub(/(?<before>.*\nAttributes\s*=+\s*?\n)\n*(?m:.+?)(?<after>\n.+\s*\n=+.*)/,
143
143
  '\k<before>CHEF_ATTRDOC_UPDATING_TEMPLATE\k<after>')
144
144
  elsif content =~ /\n\#+\s*Attributes\s*\n/
145
- updated = content.gsub(/(?<before>.*\n\#+\s*Attributes\s*?\n)\n*(.+?)(?<after>\n\#+.*)/m,
145
+ updated = content.sub(/(?<before>.*\n\#+\s*Attributes\s*?\n)\n*(.+?)(?<after>\n\#+.*)/m,
146
146
  '\k<before>CHEF_ATTRDOC_UPDATING_TEMPLATE\k<after>')
147
147
  else
148
- raise StandardError, "Could not find Attributes heading in #{readme}. Please make sure your README file has proper markdown formatting and includes an Attributes heading."
148
+ raise StandardError, "Could not find Attributes heading in #{readme}. "+
149
+ "Please make sure your README file has proper markdown formatting "+
150
+ "and includes an Attributes heading."
149
151
  end
150
152
 
151
- updated.sub! 'CHEF_ATTRDOC_UPDATING_TEMPLATE', "\n" + parsed
153
+ updated.sub!(
154
+ 'CHEF_ATTRDOC_UPDATING_TEMPLATE',
155
+ # need to sanitize the second parameter, otherwise it can repeat
156
+ # parts of the original README
157
+ "\n" + parsed.gsub(/\\/, "\\\\\\"))
158
+
152
159
  f.rewind
153
160
  f.write(updated)
154
161
  f.flush
@@ -1,3 +1,3 @@
1
1
  module ChefAttrdoc
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef_attrdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: