Commit 89914697 by codeape Committed by Martin Stannard

adding extra option to enable skipping the inclusion of current migration veresion

Signed-off-by: 's avatarctran <ctran@pragmaquest.com>
parent 81ab6187
......@@ -2,10 +2,10 @@
Gem::Specification.new do |s|
s.name = %q{annotate}
s.version = "2.0.0"
s.version = "2.0.0.20090212000"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Cuong Tran"]
s.authors = ["Dan Cheail", "Cuong Tran"]
s.date = %q{2009-02-03}
s.default_executable = %q{annotate}
s.description = %q{Annotates Rails Models, routes, and others}
......
......@@ -11,6 +11,7 @@ OptionParser.new do |opts|
opts.on('-p', '--position [before|after]', ['before', 'after']) { |p| ENV['position'] = p }
opts.on('-r', '--routes') { task = :annotate_routes }
opts.on('-v', '--version') { puts "Annotate v#{Annotate::VERSION}"; exit }
opts.on('-m', '--show-migration') { ENV['include_version'] = "yes" }
end.parse!
begin
......
......@@ -174,10 +174,13 @@ module AnnotateModels
# then pas it to the associated block
def do_annotations(options={})
header = PREFIX.dup
if options[:include_version]
version = ActiveRecord::Migrator.current_version rescue 0
if version > 0
header << "\n# Schema version: #{version}"
end
end
annotated = []
get_model_files.each do |file|
......@@ -189,7 +192,7 @@ module AnnotateModels
end
end
rescue Exception => e
puts "Unable to annotate #{file}: #{e.message}"
puts "Unable to annotate #{file}: #{e.message} (#{e.backtrace.first})"
end
end
if annotated.empty?
......
......@@ -4,6 +4,7 @@ task :annotate_models => :environment do
options={}
options[:position_in_class] = ENV['position_in_class'] || ENV['position']
options[:position_in_fixture] = ENV['position_in_fixture'] || ENV['position']
options[:include_version] = ENV['include_version']
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