Commit 25b0f9a5 by Jon Frisby

Accept string or symbol for positions.

parent 3bdb536f
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
no replacement. It will be removed on or after 2011-10-01.` no replacement. It will be removed on or after 2011-10-01.`
* Fix handling of files with no trailing newline when putting annotations at * Fix handling of files with no trailing newline when putting annotations at
the end of the file. the end of the file.
* Accept String or Symbol for :position (et al) options.
== 2.1 2009-10-18 == 2.1 2009-10-18
......
...@@ -117,7 +117,7 @@ module AnnotateModels ...@@ -117,7 +117,7 @@ module AnnotateModels
# #
# === Options (opts) # === Options (opts)
# :position<Symbol>:: where to place the annotated section in fixture or model file, # :position<Symbol>:: where to place the annotated section in fixture or model file,
# "before" or "after". Default is "before". # :before or :after. Default is :before.
# :position_in_class<Symbol>:: where to place the annotated section in model file # :position_in_class<Symbol>:: where to place the annotated section in model file
# :position_in_fixture<Symbol>:: where to place the annotated section in fixture file # :position_in_fixture<Symbol>:: where to place the annotated section in fixture file
# :position_in_others<Symbol>:: where to place the annotated section in the rest of # :position_in_others<Symbol>:: where to place the annotated section in the rest of
...@@ -147,7 +147,7 @@ module AnnotateModels ...@@ -147,7 +147,7 @@ module AnnotateModels
# 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
old_content.sub!(encoding, '') old_content.sub!(encoding, '')
new_content = options[:position] == 'after' ? new_content = (options[:position] || 'before').to_s == 'after' ?
(encoding_header + (old_content.rstrip + "\n\n" + info_block)) : (encoding_header + (old_content.rstrip + "\n\n" + info_block)) :
(encoding_header + info_block + old_content) (encoding_header + info_block + old_content)
end end
......
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