Commit 1d58ea1b by Jack Danger Canty

not continually prepending newlines.

Prior to this patch every time the schema was regenerated at the end of the file it prepended an additional newline character. This made the schema slowly creep down the file over time. Finally annoyed me enough to fork and fix ;)
parent 0076e085
...@@ -133,7 +133,9 @@ module AnnotateModels ...@@ -133,7 +133,9 @@ module AnnotateModels
new_content = old_content.sub(/^# #{COMPAT_PREFIX}.*?\n(#.*\n)*\n/, info_block) new_content = old_content.sub(/^# #{COMPAT_PREFIX}.*?\n(#.*\n)*\n/, info_block)
# But, if there *was* no old schema info, we simply need to insert it # But, if there *was* no old schema info, we simply need to insert it
if new_content == old_content if new_content == old_content
new_content = options[:position] == 'before' ? (info_block + old_content) : (old_content + "\n" + info_block) new_content = options[:position] == 'before' ?
(info_block + old_content) :
((old_content =~ /\n$/ ? old_content : old_content + '\n') + info_block)
end end
File.open(file_name, "wb") { |f| f.puts new_content } File.open(file_name, "wb") { |f| f.puts new_content }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment