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