annotate 2.5.0.pre2 → 2.5.0.pre3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +1 -0
- data/README.rdoc +3 -2
- data/bin/annotate +6 -1
- data/lib/annotate/annotate_models.rb +20 -22
- data/lib/annotate/version.rb +1 -1
- data/lib/tasks/annotate_models.rake +1 -0
- metadata +4 -4
data/History.txt
CHANGED
@@ -61,6 +61,7 @@
|
|
61
61
|
* Add --format=markdown option
|
62
62
|
* "Table name" annotation (if table name is different from model name)
|
63
63
|
* "Human name" annotation (enabling translation to non-English locales)
|
64
|
+
* --trace option to help debug "Unable to annotate" errors
|
64
65
|
|
65
66
|
== 2.4.2 2009-11-21
|
66
67
|
|
data/README.rdoc
CHANGED
@@ -43,7 +43,7 @@ Also, if you pass the -r option, it'll annotate routes.rb with the output of "ra
|
|
43
43
|
|
44
44
|
Into Gemfile from rubygems.org:
|
45
45
|
|
46
|
-
gem 'annotate', ">=2.5.0.
|
46
|
+
gem 'annotate', ">=2.5.0.pre3"
|
47
47
|
|
48
48
|
Into Gemfile from Github:
|
49
49
|
|
@@ -101,7 +101,7 @@ anywhere in the file:
|
|
101
101
|
|
102
102
|
== OPTIONS
|
103
103
|
|
104
|
-
Usage:
|
104
|
+
Usage: annotate [options] [model_file]*
|
105
105
|
-d, --delete Remove annotations from all model files
|
106
106
|
-p, --position [before|after] Place the annotations at the top (before) or the bottom (after) of the model file
|
107
107
|
-r, --routes Annotate routes.rb with the output of 'rake routes'
|
@@ -117,6 +117,7 @@ anywhere in the file:
|
|
117
117
|
-f [bare|rdoc|markdown], Render Schema Infomation as plain/RDoc/Markdown
|
118
118
|
--format
|
119
119
|
--force Force new annotations even if there are no changes.
|
120
|
+
--trace If unable to annotate a file, print the full stack trace, not just the exception message.
|
120
121
|
|
121
122
|
|
122
123
|
== SORTING
|
data/bin/annotate
CHANGED
@@ -13,7 +13,7 @@ end
|
|
13
13
|
task = :annotate_models
|
14
14
|
|
15
15
|
OptionParser.new do |opts|
|
16
|
-
opts.banner = "Usage:
|
16
|
+
opts.banner = "Usage: annotate [options] [model_file]*"
|
17
17
|
|
18
18
|
opts.on('-d', '--delete',
|
19
19
|
"Remove annotations from all model files") do
|
@@ -87,6 +87,11 @@ OptionParser.new do |opts|
|
|
87
87
|
ENV['force'] = 'yes'
|
88
88
|
end
|
89
89
|
|
90
|
+
opts.on('--trace', 'If unable to annotate a file, print the full stack trace, not just the exception message.') do |value|
|
91
|
+
ENV['trace'] = 'yes'
|
92
|
+
end
|
93
|
+
|
94
|
+
|
90
95
|
end.parse!
|
91
96
|
|
92
97
|
ENV['is_cli'] = '1'
|
@@ -344,25 +344,11 @@ module AnnotateModels
|
|
344
344
|
end
|
345
345
|
end
|
346
346
|
|
347
|
-
if options[:model_dir]
|
348
|
-
self.model_dir = options[:model_dir]
|
349
|
-
end
|
347
|
+
self.model_dir = options[:model_dir] if options[:model_dir]
|
350
348
|
|
351
349
|
annotated = []
|
352
350
|
get_model_files(options).each do |file|
|
353
|
-
|
354
|
-
klass = get_model_class(file)
|
355
|
-
if klass && klass < ActiveRecord::Base && !klass.abstract_class?
|
356
|
-
if annotate(klass, file, header, options)
|
357
|
-
annotated << klass
|
358
|
-
end
|
359
|
-
end
|
360
|
-
rescue Exception => e
|
361
|
-
# todo: check if all backtrace lines are in "gems" -- if so, it's an annotate bug, so print the whole stack trace.
|
362
|
-
puts "Unable to annotate #{file}: #{e.message} (#{e.backtrace.first})"
|
363
|
-
# todo: save this backtrace somewhere nice
|
364
|
-
# puts "\t" + e.backtrace.join("\n\t")
|
365
|
-
end
|
351
|
+
annotate_model_file(annotated, file, header, options)
|
366
352
|
end
|
367
353
|
if annotated.empty?
|
368
354
|
puts "Nothing annotated."
|
@@ -370,12 +356,23 @@ module AnnotateModels
|
|
370
356
|
puts "Annotated (#{annotated.length}): #{annotated.join(', ')}"
|
371
357
|
end
|
372
358
|
end
|
373
|
-
|
374
|
-
def
|
375
|
-
|
376
|
-
|
377
|
-
|
359
|
+
|
360
|
+
def annotate_model_file(annotated, file, header, options)
|
361
|
+
begin
|
362
|
+
klass = get_model_class(file)
|
363
|
+
if klass && klass < ActiveRecord::Base && !klass.abstract_class?
|
364
|
+
if annotate(klass, file, header, options)
|
365
|
+
annotated << klass
|
366
|
+
end
|
367
|
+
end
|
368
|
+
rescue Exception => e
|
369
|
+
puts "Unable to annotate #{file}: #{e.message}"
|
370
|
+
puts "\t" + e.backtrace.join("\n\t") if options[:trace]
|
378
371
|
end
|
372
|
+
end
|
373
|
+
|
374
|
+
def remove_annotations(options={})
|
375
|
+
self.model_dir = options[:model_dir] if options[:model_dir]
|
379
376
|
deannotated = []
|
380
377
|
get_model_files(options).each do |file|
|
381
378
|
begin
|
@@ -406,7 +403,8 @@ module AnnotateModels
|
|
406
403
|
|
407
404
|
end
|
408
405
|
rescue Exception => e
|
409
|
-
puts "Unable to
|
406
|
+
puts "Unable to deannotate #{file}: #{e.message}"
|
407
|
+
puts "\t" + e.backtrace.join("\n\t") if options[:trace]
|
410
408
|
end
|
411
409
|
end
|
412
410
|
puts "Removed annotation from: #{deannotated.join(', ')}"
|
data/lib/annotate/version.rb
CHANGED
@@ -28,6 +28,7 @@ task :annotate_models => :environment do
|
|
28
28
|
options[:format_markdown] = ENV['format_markdown'] =~ true_re
|
29
29
|
options[:sort] = ENV['sort'] =~ true_re
|
30
30
|
options[:force] = ENV['force'] =~ true_re
|
31
|
+
options[:trace] = ENV['trace'] =~ true_re
|
31
32
|
AnnotateModels.do_annotations(options)
|
32
33
|
end
|
33
34
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: annotate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.0.
|
4
|
+
version: 2.5.0.pre3
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2012-07-
|
15
|
+
date: 2012-07-26 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rake
|
@@ -74,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
74
|
version: '0'
|
75
75
|
segments:
|
76
76
|
- 0
|
77
|
-
hash:
|
77
|
+
hash: 4381666328163276586
|
78
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
79
|
none: false
|
80
80
|
requirements:
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
version: 1.3.1
|
84
84
|
requirements: []
|
85
85
|
rubyforge_project: annotate
|
86
|
-
rubygems_version: 1.8.
|
86
|
+
rubygems_version: 1.8.21
|
87
87
|
signing_key:
|
88
88
|
specification_version: 3
|
89
89
|
summary: Annotates Rails Models, routes, fixtures, and others based on the database
|