Skip to content

Commit 78610bf

Browse files
codeapectran
codeape
authored and
ctran
committed
adding extra option to enable skipping the inclusion of current migration veresion
Signed-off-by: ctran <[email protected]>
1 parent 5867d5a commit 78610bf

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

Diff for: annotate_models.gemspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
Gem::Specification.new do |s|
44
s.name = %q{annotate}
5-
s.version = "2.0.0"
5+
s.version = "2.0.0.20090212000"
66

77
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8-
s.authors = ["Cuong Tran"]
8+
s.authors = ["Dan Cheail", "Cuong Tran"]
99
s.date = %q{2009-02-03}
1010
s.default_executable = %q{annotate}
1111
s.description = %q{Annotates Rails Models, routes, and others}

Diff for: bin/annotate

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ OptionParser.new do |opts|
1111
opts.on('-p', '--position [before|after]', ['before', 'after']) { |p| ENV['position'] = p }
1212
opts.on('-r', '--routes') { task = :annotate_routes }
1313
opts.on('-v', '--version') { puts "Annotate v#{Annotate::VERSION}"; exit }
14+
opts.on('-m', '--show-migration') { ENV['include_version'] = "yes" }
1415
end.parse!
1516

1617
begin

Diff for: lib/annotate/annotate_models.rb

+7-4
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,12 @@ def get_model_class(file)
168168
# then pas it to the associated block
169169
def do_annotations(options={})
170170
header = PREFIX.dup
171-
version = ActiveRecord::Migrator.current_version rescue 0
172-
if version > 0
173-
header << "\n# Schema version: #{version}"
171+
172+
if options[:include_version]
173+
version = ActiveRecord::Migrator.current_version rescue 0
174+
if version > 0
175+
header << "\n# Schema version: #{version}"
176+
end
174177
end
175178

176179
annotated = []
@@ -183,7 +186,7 @@ def do_annotations(options={})
183186
end
184187
end
185188
rescue Exception => e
186-
puts "Unable to annotate #{file}: #{e.message}"
189+
puts "Unable to annotate #{file}: #{e.message} (#{e.backtrace.first})"
187190
end
188191
end
189192
if annotated.empty?

Diff for: lib/tasks/annotate.rake

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ task :annotate_models => :environment do
44
options={}
55
options[:position_in_class] = ENV['position_in_class'] || ENV['position']
66
options[:position_in_fixture] = ENV['position_in_fixture'] || ENV['position']
7+
options[:include_version] = ENV['include_version']
78
AnnotateModels.do_annotations(options)
89
end
910

0 commit comments

Comments
 (0)