Commit a43c08f0 by Cuong Tran

Merge pull request #69 from davidxia/master

Annotation position defaulted to 'before'. Bugfix: annotate_models.rake uses string instead of symbol.
parents 03256565 449bd7f1
...@@ -145,9 +145,9 @@ module AnnotateModels ...@@ -145,9 +145,9 @@ 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] == 'before' ? new_content = options[:position] == 'after' ?
(encoding_header + info_block + old_content) : (encoding_header + (old_content =~ /\n$/ ? old_content : old_content + '\n') + info_block) :
(encoding_header + (old_content =~ /\n$/ ? old_content : old_content + '\n') + info_block) (encoding_header + info_block + old_content)
end end
File.open(file_name, "wb") { |f| f.puts new_content } File.open(file_name, "wb") { |f| f.puts new_content }
......
...@@ -5,8 +5,8 @@ task :annotate_models => :environment do ...@@ -5,8 +5,8 @@ task :annotate_models => :environment do
true_re = /(true|t|yes|y|1)$/i true_re = /(true|t|yes|y|1)$/i
options={} options={}
options[:position_in_class] = ENV['position_in_class'] || ENV['position'] || :before options[:position_in_class] = ENV['position_in_class'] || ENV['position'] || 'before'
options[:position_in_fixture] = ENV['position_in_fixture'] || ENV['position'] || :before options[:position_in_fixture] = ENV['position_in_fixture'] || ENV['position'] || 'before'
options[:show_indexes] = ENV['show_indexes'] =~ true_re options[:show_indexes] = ENV['show_indexes'] =~ true_re
options[:simple_indexes] = ENV['simple_indexes'] =~ true_re options[:simple_indexes] = ENV['simple_indexes'] =~ true_re
options[:model_dir] = ENV['model_dir'] options[:model_dir] = ENV['model_dir']
......
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