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|
ENV['ignore_model_sub_dir'] = "yes"
end
opts.on('-n', '--no-sort',
"Sort columns in creation order rather than alphabetically") do |dir|
ENV['no_sort'] = "yes"
opts.on('--sort',
"Sort columns alphabetically, rather than in creation order") do |dir|
ENV['sort'] = "yes"
end
opts.on('-R', '--require path',
......@@ -73,7 +73,7 @@ OptionParser.new do |opts|
else
ENV['require'] = path
end
end
end\
opts.on('-e', '--exclude [tests,fixtures]', Array, "Do not annotate fixtures, test files, or both") do |exclusions|
exclusions.each { |exclusion| ENV["exclude_#{exclusion}"] = "yes" }
......
......@@ -39,7 +39,7 @@ module AnnotateModels
def model_dir
@model_dir || "app/models"
end
def model_dir=(dir)
@model_dir = dir
end
......@@ -77,7 +77,7 @@ module AnnotateModels
end
cols = klass.columns
cols = cols.sort_by(&:name) unless(options[:no_sort])
cols = cols.sort_by(&:name) if(options[:sort])
cols.each do |col|
attrs = []
attrs << "default(#{quote(col.default)})" unless col.default.nil?
......@@ -92,7 +92,7 @@ module AnnotateModels
col_type << "(#{col.limit})" unless NO_LIMIT_COL_TYPES.include?(col_type)
end
end
# Check out if we got a geometric column
# and print the type and SRID
if col.respond_to?(:geometry_type)
......@@ -207,13 +207,11 @@ module AnnotateModels
end
end
end
def remove_annotation_of_file(file_name)
if File.exist?(file_name)
content = File.read(file_name)
content.sub!(PATTERN, '')
File.open(file_name, "wb") { |f| f.puts content }
end
end
......@@ -304,7 +302,7 @@ module AnnotateModels
end
models
end
# Retrieve the classes belonging to the model names we're asked to process
# Check for namespaced models in subdirectories as well as models
# in subdirectories without namespacing.
......@@ -340,9 +338,9 @@ module AnnotateModels
version = ActiveRecord::Migrator.current_version rescue 0
if version > 0
header << "\n# Schema version: #{version}"
end
end
end
if options[:model_dir]
self.model_dir = options[:model_dir]
end
......@@ -367,7 +365,7 @@ module AnnotateModels
puts "Annotated (#{annotated.length}): #{annotated.join(', ')}"
end
end
def remove_annotations(options={})
if options[:model_dir]
puts "removing"
......
......@@ -26,7 +26,7 @@ task :annotate_models => :environment do
options[:ignore_model_sub_dir] = ENV['ignore_model_sub_dir'] =~ true_re
options[:format_rdoc] = ENV['format_rdoc'] =~ 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
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