Commit 637499db by Alex Chaffee

Revert "Changed to sort be default with an option to not sort."

This reverts commit 8d3c00c7. Sorry, but database order should be the default unless a user really wants it alphabetized. (We should also allow a .annotate file so users can set their own preferred options more easily.) Conflicts: .gitignore bin/annotate lib/annotate/annotate_models.rb lib/tasks/annotate_models.rake
parent 60381f84
...@@ -61,9 +61,9 @@ OptionParser.new do |opts| ...@@ -61,9 +61,9 @@ OptionParser.new do |opts|
ENV['ignore_model_sub_dir'] = "yes" ENV['ignore_model_sub_dir'] = "yes"
end end
opts.on('-n', '--no-sort', opts.on('--sort',
"Sort columns in creation order rather than alphabetically") do |dir| "Sort columns alphabetically, rather than in creation order") do |dir|
ENV['no_sort'] = "yes" ENV['sort'] = "yes"
end end
opts.on('-R', '--require path', opts.on('-R', '--require path',
...@@ -73,7 +73,7 @@ OptionParser.new do |opts| ...@@ -73,7 +73,7 @@ OptionParser.new do |opts|
else else
ENV['require'] = path ENV['require'] = path
end end
end end\
opts.on('-e', '--exclude [tests,fixtures]', Array, "Do not annotate fixtures, test files, or both") do |exclusions| opts.on('-e', '--exclude [tests,fixtures]', Array, "Do not annotate fixtures, test files, or both") do |exclusions|
exclusions.each { |exclusion| ENV["exclude_#{exclusion}"] = "yes" } exclusions.each { |exclusion| ENV["exclude_#{exclusion}"] = "yes" }
......
...@@ -77,7 +77,7 @@ module AnnotateModels ...@@ -77,7 +77,7 @@ module AnnotateModels
end end
cols = klass.columns cols = klass.columns
cols = cols.sort_by(&:name) unless(options[:no_sort]) cols = cols.sort_by(&:name) if(options[:sort])
cols.each do |col| cols.each do |col|
attrs = [] attrs = []
attrs << "default(#{quote(col.default)})" unless col.default.nil? attrs << "default(#{quote(col.default)})" unless col.default.nil?
...@@ -211,9 +211,7 @@ module AnnotateModels ...@@ -211,9 +211,7 @@ module AnnotateModels
def remove_annotation_of_file(file_name) def remove_annotation_of_file(file_name)
if File.exist?(file_name) if File.exist?(file_name)
content = File.read(file_name) content = File.read(file_name)
content.sub!(PATTERN, '') content.sub!(PATTERN, '')
File.open(file_name, "wb") { |f| f.puts content } File.open(file_name, "wb") { |f| f.puts content }
end end
end end
......
...@@ -26,7 +26,7 @@ task :annotate_models => :environment do ...@@ -26,7 +26,7 @@ task :annotate_models => :environment do
options[:ignore_model_sub_dir] = ENV['ignore_model_sub_dir'] =~ true_re options[:ignore_model_sub_dir] = ENV['ignore_model_sub_dir'] =~ true_re
options[:format_rdoc] = ENV['format_rdoc'] =~ true_re options[:format_rdoc] = ENV['format_rdoc'] =~ true_re
options[:format_markdown] = ENV['format_markdown'] =~ true_re options[:format_markdown] = ENV['format_markdown'] =~ true_re
options[:no_sort] = ENV['no_sort'] =~ true_re options[:sort] = ENV['sort'] =~ true_re
options[:force] = ENV['force'] =~ true_re options[:force] = ENV['force'] =~ true_re
AnnotateModels.do_annotations(options) AnnotateModels.do_annotations(options)
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