Commit 8d3c00c7 by Tony Day

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

parent e0527559
......@@ -4,3 +4,4 @@ rdoc/*
coverage/*
spec/debug.log
pkg/*
.idea
......@@ -13,7 +13,7 @@ OptionParser.new do |opts|
opts.on('-v', '--version', "Show the current version of this gem") { puts "Annotate v#{Annotate::VERSION}"; exit }
opts.on('-m', '--show-migration', "Include the migration version number in the annotation") { ENV['include_version'] = "yes" }
opts.on('-i', '--show-indexes', "List the table's database indexes in the annotation") { ENV['show_indexes'] = "yes" }
opts.on('-s', '--sort', "Sort columns alphabetically (rather than listing in creation order)") { ENV['sort'] = "yes" }
opts.on('-n', '--no-sort', "Sort columns alphabetically (rather than listing in creation order)") { ENV['no_sort'] = "yes" }
opts.on('--model-dir dir', "Annotate model files stored in dir rather than app/models") {|dir| ENV['model_dir'] = dir }
end.parse!
......
......@@ -65,7 +65,7 @@ module AnnotateModels
cols << sprintf("# %-#{max_size}.#{max_size}s:%-15.15s %s", col.name, col_type, attrs.join(", ")).rstrip + "\n"
end
cols.sort! if options[:sort]
cols.sort! unless options[:no_sort]
info << cols.join
if options[:show_indexes]
......
......@@ -7,7 +7,7 @@ task :annotate_models => :environment do
options[:show_indexes] = ENV['show_indexes']
options[:model_dir] = ENV['model_dir']
options[:include_version] = ENV['include_version']
options[:sort] = ENV['sort']
options[:no_sort] = ENV['no_sort']
AnnotateModels.do_annotations(options)
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