Skip to content

Commit e852121

Browse files
author
Cuong Tran
committed
Revert "Replacing old block with new one."
This reverts commit b11928e.
1 parent f264498 commit e852121

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

lib/annotate/annotate_models.rb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,17 +246,13 @@ def annotate_one_file(file_name, info_block, position, options={})
246246
# end
247247
# =======
248248

249-
if PATTERN.match(old_content)
250-
new_content = old_content.sub(PATTERN, info_block)
251-
else
252-
# Strip the old schema info, and insert new schema info.
253-
old_content.sub!(encoding, '')
254-
old_content.sub!(PATTERN, '')
255-
256-
new_content = options[position].to_s == 'after' ?
257-
(encoding_header + (old_content.rstrip + "\n\n" + info_block)) :
258-
(encoding_header + info_block + "\n" + old_content)
259-
end
249+
# Strip the old schema info, and insert new schema info.
250+
old_content.sub!(encoding, '')
251+
old_content.sub!(PATTERN, '')
252+
253+
new_content = options[position].to_s == 'after' ?
254+
(encoding_header + (old_content.rstrip + "\n\n" + info_block)) :
255+
(encoding_header + info_block + "\n" + old_content)
260256

261257
File.open(file_name, "wb") { |f| f.puts new_content }
262258
return true

0 commit comments

Comments
 (0)