chef_attrdoc 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/chef_attrdoc.rb +11 -4
- data/lib/chef_attrdoc/version.rb +1 -1
- metadata +1 -1
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.
|
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.
|
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}.
|
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!
|
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
|
data/lib/chef_attrdoc/version.rb
CHANGED