Skip to content

Commit

Permalink
Annotation position defaulted to 'before'. Bugfix: annotate_models.ra…
Browse files Browse the repository at this point in the history
…ke uses string instead of symbol.
  • Loading branch information
davidxia committed Jan 27, 2012
1 parent 0325656 commit 449bd7f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/annotate/annotate_models.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ def annotate_one_file(file_name, info_block, options={})
# 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 }
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/annotate_models.rake
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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']
Expand Down

0 comments on commit 449bd7f

Please sign in to comment.