annotate 2.7.0 → 2.7.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d69e9ad0ab7a59e673f3cb7287d6cccb78b8ba20
4
- data.tar.gz: a3b5adea28b4f3ebedc4f7af1df32907167d2bb9
3
+ metadata.gz: 2e6c2484a81d38c69c86e48305ae0a1b8724e5b1
4
+ data.tar.gz: 7463f0ee24a0023b105dc5e48fc9eec49559de0e
5
5
  SHA512:
6
- metadata.gz: e6b5b503403df98d298e29c1ea4413999496d4c67326704c4c59a079bcd58fa3c6160e0e8812793a5e2796ddd8dcb216482793e5ff11e789463432c93d76cadd
7
- data.tar.gz: 15d8f31b8c2bebd74cb0447b5f8283bf0397ae73b8e5a5fd6dc1306b19511cbbd03523338327da32fe2acc599c292fe2f0d434b5969b6eca2468d3bd2c4b9139
6
+ metadata.gz: d4dd08320d2fa1b85c21afdeb1fd5daa4ec6cd39877d70a0681b04ce7453f6fd204da258b0a9d20fe22d4eb4649d44c086383a20db3fe4c6b183ac35a8e1171c
7
+ data.tar.gz: 25101a0b978d74579bd47e2dba28a3b89fc738fe19966c50a78aaa43543748c5cd523ff7c7be3b708caa80925092a553a28f4dc6b55b6e91547d9ec5fdbb810f
@@ -29,5 +29,6 @@ With help from:
29
29
  - Paul Alexander
30
30
  - Dmitry Lihachev
31
31
  - qichunren
32
+ - Guillermo Guerrero - http://github.com/ryanfox1985
32
33
 
33
34
  and many others that I may have forgotten to add.
@@ -1,3 +1,6 @@
1
+ == 2.7.1
2
+ See https://github.com/ctran/annotate_models/releases/tag/v2.7.1
3
+
1
4
  == 2.7.0
2
5
  See https://github.com/ctran/annotate_models/releases/tag/v2.7.0
3
6
 
@@ -1,7 +1,10 @@
1
1
  == Annotate (aka AnnotateModels)
2
2
 
3
3
  {<img src="https://badge.fury.io/rb/annotate.svg" alt="Gem Version" />}[http://badge.fury.io/rb/annotate]
4
+ {<img src="https://img.shields.io/gem/dt/annotate.svg?style=flat" />}[https://rubygems.org/gems/annotate]
4
5
  {<img src="https://travis-ci.org/ctran/annotate_models.png" />}[https://travis-ci.org/ctran/annotate_models]
6
+ {<img src="https://coveralls.io/repos/ctran/annotate_models/badge.svg?branch=develop" />}[https://coveralls.io/r/ctran/annotate_models?branch=develop]
7
+ {<img src="https://codeclimate.com/github/ctran/annotate_models/badges/gpa.svg" />}[https://codeclimate.com/github/ctran/annotate_models]
5
8
  {<img src="https://gemnasium.com/ctran/annotate_models.png" />}[https://gemnasium.com/ctran/annotate_models]
6
9
 
7
10
  Add a comment summarizing the current schema to the top or bottom of each of
@@ -44,7 +47,7 @@ It also annotates geometrical columns, geom type and srid, when using
44
47
  # path :geometry line_string, 4326
45
48
 
46
49
  Also, if you pass the -r option, it'll annotate routes.rb with the output of
47
- +rake routes+.
50
+ <code>rake routes</code>.
48
51
 
49
52
 
50
53
  == Install
@@ -71,7 +74,7 @@ Into environment gems from Github checkout:
71
74
 
72
75
  == Usage
73
76
 
74
- (If you used the Gemfile install, prefix the below commands with +bundle exec+.)
77
+ (If you used the Gemfile install, prefix the below commands with <code>bundle exec</code>.)
75
78
 
76
79
  === Usage in Rails
77
80
 
@@ -100,7 +103,7 @@ To remove routes.rb annotations:
100
103
 
101
104
  annotate --routes --delete
102
105
 
103
- To automatically annotate every time you run +db:migrate+, either run +rails g annotate:install+ or add +Annotate.load_tasks+ to your `Rakefile`. See the [configuration in Rails](#configuration-in-rails) section for more info.
106
+ To automatically annotate every time you run <code>db:migrate</code>, either run <code>rails g annotate:install</code> or add +Annotate.load_tasks+ to your `Rakefile`. See the {configuration in Rails}[link:README.rdoc#configuration-in-rails] section for more info.
104
107
 
105
108
  === Usage Outside of Rails
106
109
 
@@ -136,7 +139,7 @@ functionality:
136
139
  rake remove_annotation # Remove schema information from model and fixture files
137
140
 
138
141
  By default, once you've generated a configuration file, annotate will be
139
- executed whenever you run +rake db:migrate+ (but only in development mode).
142
+ executed whenever you run <code>rake db:migrate</code> (but only in development mode).
140
143
  If you want to disable this behavior permanently, edit the +.rake+ file and
141
144
  change:
142
145
 
@@ -146,7 +149,7 @@ To:
146
149
 
147
150
  'skip_on_db_migrate' => 'true',
148
151
 
149
- If you want to run +rake db:migrate+ as a one-off without running annotate,
152
+ If you want to run <code>rake db:migrate</code> as a one-off without running annotate,
150
153
  you can do so with a simple environment variable, instead of editing the
151
154
  +.rake+ file:
152
155
 
@@ -175,6 +178,7 @@ you can do so with a simple environment variable, instead of editing the
175
178
  --wo, --wrapper-open STR Annotation wrapper opening.
176
179
  --wc, --wrapper-close STR Annotation wrapper closing
177
180
  -r, --routes Annotate routes.rb with the output of 'rake routes'
181
+ -aa, --active-admin Annotate all activeadmin models
178
182
  -v, --version Show the current version of this gem
179
183
  -m, --show-migration Include the migration version number in the annotation
180
184
  -i, --show-indexes List the table's database indexes in the annotation
@@ -26,10 +26,10 @@ Gem::Specification.new do |s|
26
26
  s.specification_version = 4
27
27
 
28
28
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
29
- s.add_runtime_dependency(%q<rake>, ["~> 10.4"])
29
+ s.add_runtime_dependency(%q<rake>, [">= 10.4", "< 12.0"])
30
30
  s.add_runtime_dependency(%q<activerecord>, [">= 3.2", "< 6.0"])
31
31
  else
32
- s.add_dependency(%q<rake>, ["~> 10.4"])
32
+ s.add_dependency(%q<rake>, [">= 10.4", "< 12.0"])
33
33
  s.add_dependency(%q<activerecord>, [">= 3.2", "< 6.0"])
34
34
  end
35
35
  else
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- unless File.exists?('./Rakefile') || File.exists?('./Gemfile')
4
- abort "Please run annotate from the root of the project."
3
+ unless File.exist?('./Rakefile') || File.exist?('./Gemfile')
4
+ abort 'Please run annotate from the root of the project.'
5
5
  end
6
6
 
7
7
  require 'rubygems'
8
8
  begin
9
9
  require 'bundler'
10
10
  Bundler.setup
11
- rescue Exception => e
11
+ rescue Exception
12
12
  end
13
13
 
14
14
  here = File.expand_path(File.dirname __FILE__)
@@ -20,58 +20,55 @@ Annotate.bootstrap_rake
20
20
 
21
21
  has_set_position = {}
22
22
  target_action = :do_annotations
23
+ positions = %w(before top after bottom)
23
24
 
24
25
  OptionParser.new do |opts|
25
- opts.banner = "Usage: annotate [options] [model_file]*"
26
-
27
- opts.on('-d', '--delete',
28
- "Remove annotations from all model files or the routes.rb file") do
26
+ opts.banner = 'Usage: annotate [options] [model_file]*'
29
27
 
28
+ opts.on('-d', '--delete', 'Remove annotations from all model files or the routes.rb file') do
30
29
  target_action = :remove_annotations
31
30
  end
32
31
 
33
- opts.on('-p', '--position [before|top|after|bottom]', ['before', 'top', 'after', 'bottom'],
34
- "Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route/serializer file(s)") do |p|
32
+ opts.on('-p', '--position [before|top|after|bottom]', positions,
33
+ 'Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route/serializer file(s)') do |p|
35
34
  ENV['position'] = p
36
- [
37
- 'position_in_class','position_in_factory','position_in_fixture','position_in_test', 'position_in_routes', 'position_in_serializer'
38
- ].each do |key|
39
- ENV[key] = p unless(has_set_position[key])
35
+ %w(position_in_class position_in_factory position_in_fixture position_in_test position_in_routes position_in_serializer).each do |key|
36
+ ENV[key] = p unless (has_set_position[key])
40
37
  end
41
38
  end
42
39
 
43
- opts.on('--pc', '--position-in-class [before|top|after|bottom]', ['before', 'top', 'after', 'bottom'],
44
- "Place the annotations at the top (before) or the bottom (after) of the model file") do |p|
40
+ opts.on('--pc', '--position-in-class [before|top|after|bottom]', positions,
41
+ 'Place the annotations at the top (before) or the bottom (after) of the model file') do |p|
45
42
  ENV['position_in_class'] = p
46
43
  has_set_position['position_in_class'] = true
47
44
  end
48
45
 
49
- opts.on('--pf', '--position-in-factory [before|top|after|bottom]', ['before', 'top', 'after', 'bottom'],
50
- "Place the annotations at the top (before) or the bottom (after) of any factory files") do |p|
46
+ opts.on('--pf', '--position-in-factory [before|top|after|bottom]', positions,
47
+ 'Place the annotations at the top (before) or the bottom (after) of any factory files') do |p|
51
48
  ENV['position_in_factory'] = p
52
49
  has_set_position['position_in_factory'] = true
53
50
  end
54
51
 
55
- opts.on('--px', '--position-in-fixture [before|top|after|bottom]', ['before', 'top', 'after', 'bottom'],
56
- "Place the annotations at the top (before) or the bottom (after) of any fixture files") do |p|
52
+ opts.on('--px', '--position-in-fixture [before|top|after|bottom]', positions,
53
+ 'Place the annotations at the top (before) or the bottom (after) of any fixture files') do |p|
57
54
  ENV['position_in_fixture'] = p
58
55
  has_set_position['position_in_fixture'] = true
59
56
  end
60
57
 
61
- opts.on('--pt', '--position-in-test [before|top|after|bottom]', ['before', 'top', 'after', 'bottom'],
62
- "Place the annotations at the top (before) or the bottom (after) of any test files") do |p|
58
+ opts.on('--pt', '--position-in-test [before|top|after|bottom]', positions,
59
+ 'Place the annotations at the top (before) or the bottom (after) of any test files') do |p|
63
60
  ENV['position_in_test'] = p
64
61
  has_set_position['position_in_test'] = true
65
62
  end
66
63
 
67
- opts.on('--pr', '--position-in-routes [before|top|after|bottom]', ['before', 'top', 'after', 'bottom'],
68
- "Place the annotations at the top (before) or the bottom (after) of the routes.rb file") do |p|
64
+ opts.on('--pr', '--position-in-routes [before|top|after|bottom]', positions,
65
+ 'Place the annotations at the top (before) or the bottom (after) of the routes.rb file') do |p|
69
66
  ENV['position_in_routes'] = p
70
67
  has_set_position['position_in_routes'] = true
71
68
  end
72
69
 
73
- opts.on('--ps', '--position-in-serializer [before|top|after|bottom]', ['before', 'top', 'after', 'bottom'],
74
- "Place the annotations at the top (before) or the bottom (after) of the serializer files") do |p|
70
+ opts.on('--ps', '--position-in-serializer [before|top|after|bottom]', positions,
71
+ 'Place the annotations at the top (before) or the bottom (after) of the serializer files') do |p|
75
72
  ENV['position_in_serializer'] = p
76
73
  has_set_position['position_in_serializer'] = true
77
74
  end
@@ -89,34 +86,36 @@ OptionParser.new do |opts|
89
86
  ENV['wrapper_close'] = p
90
87
  end
91
88
 
92
- opts.on('-r', '--routes',
93
- "Annotate routes.rb with the output of 'rake routes'") do
89
+ opts.on('-r', '--routes', "Annotate routes.rb with the output of 'rake routes'") do
94
90
  ENV['routes'] = 'true'
95
91
  end
96
92
 
93
+ opts.on('-aa', '--active-admin', 'Annotate active_admin models') do |p|
94
+ ENV['active_admin'] = p
95
+ end
96
+
97
97
  opts.on('-v', '--version',
98
- "Show the current version of this gem") do
98
+ 'Show the current version of this gem') do
99
99
  puts "annotate v#{Annotate.version}"; exit
100
100
  end
101
101
 
102
- opts.on('-m', '--show-migration',
103
- "Include the migration version number in the annotation") do
104
- ENV['include_version'] = "yes"
102
+ opts.on('-m', '--show-migration', 'Include the migration version number in the annotation') do
103
+ ENV['include_version'] = 'yes'
105
104
  end
106
105
 
107
106
  opts.on('-k', '--show-foreign-keys',
108
107
  "List the table's foreign key constraints in the annotation") do
109
- ENV['show_foreign_keys'] = "yes"
108
+ ENV['show_foreign_keys'] = 'yes'
110
109
  end
111
110
 
112
111
  opts.on('-i', '--show-indexes',
113
112
  "List the table's database indexes in the annotation") do
114
- ENV['show_indexes'] = "yes"
113
+ ENV['show_indexes'] = 'yes'
115
114
  end
116
115
 
117
116
  opts.on('-s', '--simple-indexes',
118
117
  "Concat the column's related indexes in the annotation") do
119
- ENV['simple_indexes'] = "yes"
118
+ ENV['simple_indexes'] = 'yes'
120
119
  end
121
120
 
122
121
  opts.on('--model-dir dir',
@@ -131,17 +130,17 @@ OptionParser.new do |opts|
131
130
 
132
131
  opts.on('--ignore-model-subdirects',
133
132
  "Ignore subdirectories of the models directory") do |dir|
134
- ENV['ignore_model_sub_dir'] = "yes"
133
+ ENV['ignore_model_sub_dir'] = 'yes'
135
134
  end
136
135
 
137
136
  opts.on('--sort',
138
137
  "Sort columns alphabetically, rather than in creation order") do |dir|
139
- ENV['sort'] = "yes"
138
+ ENV['sort'] = 'yes'
140
139
  end
141
140
 
142
141
  opts.on('--classified-sort',
143
142
  "Sort columns alphabetically, but first goes id, then the rest columns, then the timestamp columns and then the association columns") do |dir|
144
- ENV['classified_sort'] = "yes"
143
+ ENV['classified_sort'] = 'yes'
145
144
  end
146
145
 
147
146
  opts.on('-R', '--require path',
@@ -155,10 +154,10 @@ OptionParser.new do |opts|
155
154
 
156
155
  opts.on('-e', '--exclude [tests,fixtures,factories,serializers]', Array, "Do not annotate fixtures, test files, factories, and/or serializers") do |exclusions|
157
156
  exclusions ||= %w(tests fixtures factories)
158
- exclusions.each { |exclusion| ENV["exclude_#{exclusion}"] = "yes" }
157
+ exclusions.each { |exclusion| ENV["exclude_#{exclusion}"] = 'yes' }
159
158
  end
160
159
 
161
- opts.on('-f', '--format [bare|rdoc|markdown]', ['bare', 'rdoc', 'markdown'], 'Render Schema Infomation as plain/RDoc/Markdown') do |fmt|
160
+ opts.on('-f', '--format [bare|rdoc|markdown]', %w(bare rdoc markdown), 'Render Schema Infomation as plain/RDoc/Markdown') do |fmt|
162
161
  ENV["format_#{fmt}"] = 'yes'
163
162
  end
164
163
 
@@ -174,21 +173,25 @@ OptionParser.new do |opts|
174
173
  ENV['trace'] = 'yes'
175
174
  end
176
175
 
177
- opts.on('-I', '--ignore-columns REGEX', "don't annotate columns that match a given REGEX (i.e., `annotate -I '^(id|updated_at|created_at)'`" ) do |regex|
176
+ opts.on('-I', '--ignore-columns REGEX', "don't annotate columns that match a given REGEX (i.e., `annotate -I '^(id|updated_at|created_at)'`") do |regex|
178
177
  ENV['ignore_columns'] = regex
179
178
  end
180
179
 
181
- opts.on('--hide-limit-column-types VALUES', "don't show limit for given column types, separated by comas (i.e., `integer,boolean,text`)" ) do |values|
180
+ opts.on('--ignore-routes REGEX', "don't annotate routes that match a given REGEX (i.e., `annotate -I '(mobile|resque|pghero)'`") do |regex|
181
+ ENV['ignore_routes'] = regex
182
+ end
183
+
184
+ opts.on('--hide-limit-column-types VALUES', "don't show limit for given column types, separated by comas (i.e., `integer,boolean,text`)") do |values|
182
185
  ENV['hide_limit_column_types'] = "#{values}"
183
186
  end
184
187
 
185
- opts.on('--ignore-unknown-models', "don't display warnings for bad model files" ) do |values|
186
- ENV['ignore_unknown_models'] = "true"
188
+ opts.on('--ignore-unknown-models', "don't display warnings for bad model files") do |values|
189
+ ENV['ignore_unknown_models'] = 'true'
187
190
  end
188
191
 
189
192
  end.parse!
190
193
 
191
- options = Annotate.setup_options({ :is_rake => ENV['is_rake'] && !ENV['is_rake'].empty? })
194
+ options = Annotate.setup_options({is_rake: ENV['is_rake'] && !ENV['is_rake'].empty?})
192
195
  Annotate.eager_load(options)
193
196
 
194
197
  AnnotateModels.send(target_action, options) if Annotate.include_models?
@@ -1,4 +1,4 @@
1
- $:.unshift(File.dirname(__FILE__))
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  require 'annotate/version'
3
3
  require 'annotate/annotate_models'
4
4
  require 'annotate/annotate_routes'
@@ -14,53 +14,57 @@ rescue Exception
14
14
  end
15
15
 
16
16
  module Annotate
17
+ TRUE_RE = /^(true|t|yes|y|1)$/i
18
+
17
19
  ##
18
20
  # The set of available options to customize the behavior of Annotate.
19
21
  #
20
- POSITION_OPTIONS=[
22
+ POSITION_OPTIONS = [
21
23
  :position_in_routes, :position_in_class, :position_in_test,
22
24
  :position_in_fixture, :position_in_factory, :position,
23
25
  :position_in_serializer
24
- ]
25
- FLAG_OPTIONS=[
26
+ ].freeze
27
+ FLAG_OPTIONS = [
26
28
  :show_indexes, :simple_indexes, :include_version, :exclude_tests,
27
29
  :exclude_fixtures, :exclude_factories, :ignore_model_sub_dir,
28
30
  :format_bare, :format_rdoc, :format_markdown, :sort, :force, :trace,
29
31
  :timestamp, :exclude_serializers, :classified_sort, :show_foreign_keys,
30
- :exclude_scaffolds, :exclude_controllers, :exclude_helpers, :ignore_unknown_models,
31
- ]
32
- OTHER_OPTIONS=[
32
+ :exclude_scaffolds, :exclude_controllers, :exclude_helpers, :ignore_unknown_models
33
+ ].freeze
34
+ OTHER_OPTIONS = [
33
35
  :ignore_columns, :skip_on_db_migrate, :wrapper_open, :wrapper_close, :wrapper, :routes,
34
- :hide_limit_column_types,
35
- ]
36
- PATH_OPTIONS=[
36
+ :hide_limit_column_types, :ignore_routes, :active_admin
37
+ ].freeze
38
+ PATH_OPTIONS = [
37
39
  :require, :model_dir, :root_dir
38
- ]
40
+ ].freeze
39
41
 
40
42
  ##
41
43
  # Set default values that can be overridden via environment variables.
42
44
  #
43
45
  def self.set_defaults(options = {})
44
- return if(@has_set_defaults)
46
+ return if @has_set_defaults
45
47
  @has_set_defaults = true
46
48
 
47
49
  options = HashWithIndifferentAccess.new(options)
48
50
 
49
51
  [POSITION_OPTIONS, FLAG_OPTIONS, PATH_OPTIONS, OTHER_OPTIONS].flatten.each do |key|
50
- if options.has_key?(key)
52
+ if options.key?(key)
51
53
  default_value = if options[key].is_a?(Array)
52
- options[key].join(",")
53
- else
54
- options[key]
54
+ options[key].join(',')
55
+ else
56
+ options[key]
55
57
  end
56
58
  end
57
59
 
58
- default_value = ENV[key.to_s] if !ENV[key.to_s].blank?
60
+ default_value = ENV[key.to_s] unless ENV[key.to_s].blank?
59
61
  ENV[key.to_s] = default_value.nil? ? nil : default_value.to_s
60
62
  end
61
63
  end
62
64
 
63
- TRUE_RE = /^(true|t|yes|y|1)$/i
65
+ ##
66
+ # TODO: what is the difference between this and set_defaults?
67
+ #
64
68
  def self.setup_options(options = {})
65
69
  POSITION_OPTIONS.each do |key|
66
70
  options[key] = fallback(ENV[key.to_s], ENV['position'], 'before')
@@ -69,24 +73,24 @@ module Annotate
69
73
  options[key] = true?(ENV[key.to_s])
70
74
  end
71
75
  OTHER_OPTIONS.each do |key|
72
- options[key] = (!ENV[key.to_s].blank?) ? ENV[key.to_s] : nil
76
+ options[key] = !ENV[key.to_s].blank? ? ENV[key.to_s] : nil
73
77
  end
74
78
  PATH_OPTIONS.each do |key|
75
- options[key] = (!ENV[key.to_s].blank?) ? ENV[key.to_s].split(',') : []
76
- end
77
-
78
- if(options[:model_dir].empty?)
79
- options[:model_dir] = ['app/models']
79
+ options[key] = !ENV[key.to_s].blank? ? ENV[key.to_s].split(',') : []
80
80
  end
81
81
 
82
- if(options[:root_dir].empty?)
83
- options[:root_dir] = ['']
84
- end
82
+ options[:model_dir] = ['app/models'] if options[:model_dir].empty?
83
+ options[:root_dir] = [''] if options[:root_dir].empty?
85
84
 
86
85
  options[:wrapper_open] ||= options[:wrapper]
87
86
  options[:wrapper_close] ||= options[:wrapper]
88
87
 
89
- return options
88
+ # These were added in 2.7.0 but so this is to revert to old behavior by default
89
+ options[:exclude_scaffolds] = Annotate.true?(ENV.fetch('exclude_scaffolds', 'true'))
90
+ options[:exclude_controllers] = Annotate.true?(ENV.fetch('exclude_controllers', 'true'))
91
+ options[:exclude_helpers] = Annotate.true?(ENV.fetch('exclude_helpers', 'true'))
92
+
93
+ options
90
94
  end
91
95
 
92
96
  def self.reset_options
@@ -107,11 +111,16 @@ module Annotate
107
111
  true
108
112
  end
109
113
 
110
- def self.loaded_tasks=(val); @loaded_tasks = val; end
111
- def self.loaded_tasks; return @loaded_tasks; end
114
+ def self.loaded_tasks=(val)
115
+ @loaded_tasks = val
116
+ end
117
+
118
+ def self.loaded_tasks
119
+ @loaded_tasks
120
+ end
112
121
 
113
122
  def self.load_tasks
114
- return if(self.loaded_tasks)
123
+ return if loaded_tasks
115
124
  self.loaded_tasks = true
116
125
 
117
126
  Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each { |rake| load rake }
@@ -122,11 +131,11 @@ module Annotate
122
131
  end
123
132
 
124
133
  def self.eager_load(options)
125
- self.load_requires(options)
126
- require "annotate/active_record_patch"
134
+ load_requires(options)
135
+ require 'annotate/active_record_patch'
127
136
 
128
- if(defined?(Rails))
129
- if(Rails.version.split('.').first.to_i < 3)
137
+ if defined?(Rails)
138
+ if Rails.version.split('.').first.to_i < 3
130
139
  Rails.configuration.eager_load_paths.each do |load_path|
131
140
  matcher = /\A#{Regexp.escape(load_path)}(.*)\.rb\Z/
132
141
  Dir.glob("#{load_path}/**/*.rb").sort.each do |file|
@@ -149,33 +158,38 @@ module Annotate
149
158
  def self.bootstrap_rake
150
159
  begin
151
160
  require 'rake/dsl_definition'
152
- rescue Exception
161
+ rescue Exception => e
153
162
  # We might just be on an old version of Rake...
163
+ puts e.message
164
+ exit e.status_code
154
165
  end
155
166
  require 'rake'
156
167
 
157
- if File.exists?('./Rakefile')
158
- load './Rakefile'
168
+ load './Rakefile' if File.exist?('./Rakefile')
169
+ begin
170
+ Rake::Task[:environment].invoke
171
+ rescue
172
+ nil
159
173
  end
160
- Rake::Task[:environment].invoke rescue nil
161
- if(!defined?(Rails))
174
+ unless defined?(Rails)
162
175
  # Not in a Rails project, so time to load up the parts of
163
176
  # ActiveSupport we need.
164
177
  require 'active_support'
165
178
  require 'active_support/core_ext/class/subclasses'
166
179
  require 'active_support/core_ext/string/inflections'
167
180
  end
168
- self.load_tasks
181
+
182
+ load_tasks
169
183
  Rake::Task[:set_annotation_options].invoke
170
184
  end
171
185
 
172
186
  def self.fallback(*args)
173
- return args.detect { |arg| !arg.blank? }
187
+ args.detect { |arg| !arg.blank? }
174
188
  end
175
189
 
176
190
  def self.true?(val)
177
- return false if(val.blank?)
178
- return false unless(val =~ TRUE_RE)
179
- return true
191
+ return false if val.blank?
192
+ return false unless val =~ TRUE_RE
193
+ true
180
194
  end
181
195
  end