annotate 2.6.3 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,331 @@
1
+ ## Annotate (aka AnnotateModels)
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/annotate.svg)](http://badge.fury.io/rb/annotate)
4
+ [![Downloads count](https://img.shields.io/gem/dt/annotate.svg?style=flat)](https://rubygems.org/gems/annotate)
5
+ [![Build status](https://travis-ci.org/ctran/annotate_models.svg?branch=develop)](https://travis-ci.org/ctran/annotate_models)
6
+ [![CI Status](https://github.com/ctran/annotate_models/workflows/CI/badge.svg)](https://github.com/ctran/annotate_models/actions?workflow=CI)
7
+ [![Coveralls](https://coveralls.io/repos/ctran/annotate_models/badge.svg?branch=develop)](https://coveralls.io/r/ctran/annotate_models?branch=develop)
8
+ [![Maintenability](https://codeclimate.com/github/ctran/annotate_models/badges/gpa.svg)](https://codeclimate.com/github/ctran/annotate_models)
9
+ [![Inline docs](http://inch-ci.org/github/ctran/annotate_models.svg?branch=develop)](http://inch-ci.org/github/ctran/annotate_models)
10
+
11
+ Add a comment summarizing the current schema to the top or bottom of each of your...
12
+
13
+ - ActiveRecord models
14
+ - Fixture files
15
+ - Tests and Specs
16
+ - Object Daddy exemplars
17
+ - Machinist blueprints
18
+ - Fabrication fabricators
19
+ - Thoughtbot's factory_bot factories, i.e. the `(spec|test)/factories/<model>_factory.rb` files
20
+ - `routes.rb` file (for Rails projects)
21
+
22
+
23
+ The schema comment looks like this:
24
+
25
+ ```ruby
26
+ # == Schema Info
27
+ #
28
+ # Table name: line_items
29
+ #
30
+ # id :integer(11) not null, primary key
31
+ # quantity :integer(11) not null
32
+ # product_id :integer(11) not null
33
+ # unit_price :float
34
+ # order_id :integer(11)
35
+ #
36
+
37
+ class LineItem < ActiveRecord::Base
38
+ belongs_to :product
39
+ . . .
40
+ ```
41
+
42
+ It also annotates geometrical columns, `geom` type and `srid`,
43
+ when using `SpatialAdapter`, `PostgisAdapter` or `PostGISAdapter`:
44
+
45
+ ```ruby
46
+ # == Schema Info
47
+ #
48
+ # Table name: trips
49
+ #
50
+ # local :geometry point, 4326
51
+ # path :geometry line_string, 4326
52
+ ```
53
+
54
+ Also, if you pass the `-r` option, it'll annotate `routes.rb` with the output of `rake routes`.
55
+
56
+
57
+ ## Upgrading to 3.X and annotate models not working?
58
+
59
+ In versions 2.7.X the annotate gem defaulted to annotating models if no arguments were passed in.
60
+ The annotate gem by default would not allow for routes and models to be annotated together.
61
+ A [change was added in #647](https://github.com/ctran/annotate_models/pull/647).
62
+ You [can read more here](https://github.com/ctran/annotate_models/issues/663).
63
+
64
+ There are a few ways of fixing this:
65
+
66
+ - If using CLI explicitly pass in models flag using `--models`
67
+
68
+ OR
69
+
70
+ a) Running `rails g annotate:install` will overwrite your defaults with the annotating `models` option set to `'true'`.
71
+
72
+ b) In `lib/tasks/auto_annotate_models.rake` add the `models` key-value option:
73
+
74
+ ```ruby
75
+ Annotate.set_defaults(
76
+ ...
77
+ 'models' => 'true',
78
+ ...
79
+ ```
80
+
81
+ ## Install
82
+
83
+ Into Gemfile from rubygems.org:
84
+
85
+ ```ruby
86
+ group :development do
87
+ gem 'annotate'
88
+ end
89
+ ```
90
+
91
+ Into Gemfile from Github:
92
+
93
+ ```ruby
94
+ group :development do
95
+ gem 'annotate', git: 'https://github.com/ctran/annotate_models.git'
96
+ end
97
+ ```
98
+
99
+ Into environment gems from rubygems.org:
100
+
101
+ gem install annotate
102
+
103
+ Into environment gems from Github checkout:
104
+
105
+ git clone https://github.com/ctran/annotate_models.git annotate_models
106
+ cd annotate_models
107
+ rake gem
108
+ gem install dist/annotate-*.gem
109
+
110
+ ## Usage
111
+
112
+ (If you used the Gemfile install, prefix the below commands with `bundle exec`.)
113
+
114
+ ### Usage in Rails
115
+
116
+ To annotate all your models, tests, fixtures, and factories:
117
+
118
+ cd /path/to/app
119
+ annotate
120
+
121
+ To annotate just your models, tests, and factories:
122
+
123
+ annotate --models --exclude fixtures
124
+
125
+ To annotate just your models:
126
+
127
+ annotate --models
128
+
129
+ To annotate routes.rb:
130
+
131
+ annotate --routes
132
+
133
+ To remove model/test/fixture/factory/serializer annotations:
134
+
135
+ annotate --delete
136
+
137
+ To remove routes.rb annotations:
138
+
139
+ annotate --routes --delete
140
+
141
+ To automatically annotate every time you run `db:migrate`,
142
+ either run `rails g annotate:install`
143
+ or add `Annotate.load_tasks` to your `Rakefile`.
144
+
145
+ See the [configuration in Rails](#configuration-in-rails) section for more info.
146
+
147
+ ### Usage Outside of Rails
148
+
149
+ Everything above applies, except that `--routes` is not meaningful,
150
+ and you will probably need to explicitly set one or more `--require` option(s), and/or one or more `--model-dir` options
151
+ to inform `annotate` about the structure of your project and help it bootstrap and load the relevant code.
152
+
153
+ ## Configuration
154
+
155
+ If you want to always skip annotations on a particular model, add this string
156
+ anywhere in the file:
157
+
158
+ # -*- SkipSchemaAnnotations
159
+
160
+ ### Configuration in Rails
161
+
162
+ To generate a configuration file (in the form of a `.rake` file), to set
163
+ default options:
164
+
165
+ rails g annotate:install
166
+
167
+ Edit this file to control things like output format, where annotations are
168
+ added (top or bottom of file), and in which artifacts.
169
+
170
+ The generated rakefile `lib/tasks/auto_annotate_models.rake` also contains
171
+ `Annotate.load_tasks`. This adds a few rake tasks which duplicate command-line
172
+ functionality:
173
+
174
+ rake annotate_models # Add schema information (as comments) to model and fixture files
175
+ rake annotate_routes # Adds the route map to routes.rb
176
+ rake remove_annotation # Remove schema information from model and fixture files
177
+
178
+ By default, once you've generated a configuration file, annotate will be
179
+ executed whenever you run `rake db:migrate` (but only in development mode).
180
+ If you want to disable this behavior permanently,
181
+ edit the `.rake` file and change:
182
+
183
+ ```ruby
184
+ 'skip_on_db_migrate' => 'false',
185
+ ```
186
+
187
+ To:
188
+
189
+ ```ruby
190
+ 'skip_on_db_migrate' => 'true',
191
+ ```
192
+
193
+ If you want to run `rake db:migrate` as a one-off without running annotate,
194
+ you can do so with a simple environment variable, instead of editing the
195
+ `.rake` file:
196
+
197
+ ANNOTATE_SKIP_ON_DB_MIGRATE=1 rake db:migrate
198
+
199
+ ## Options
200
+
201
+ Usage: annotate [options] [model_file]*
202
+ --additional-file-patterns Additional file paths or globs to annotate, separated by commas (e.g. `/foo/bar/%model_name%/*.rb,/baz/%model_name%.rb`)
203
+ -d, --delete Remove annotations from all model files or the routes.rb file
204
+ -p [before|top|after|bottom], Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route/serializer file(s)
205
+ --position
206
+ --pc, --position-in-class [before|top|after|bottom]
207
+ Place the annotations at the top (before) or the bottom (after) of the model file
208
+ --pf, --position-in-factory [before|top|after|bottom]
209
+ Place the annotations at the top (before) or the bottom (after) of any factory files
210
+ --px, --position-in-fixture [before|top|after|bottom]
211
+ Place the annotations at the top (before) or the bottom (after) of any fixture files
212
+ --pt, --position-in-test [before|top|after|bottom]
213
+ Place the annotations at the top (before) or the bottom (after) of any test files
214
+ --pr, --position-in-routes [before|top|after|bottom]
215
+ Place the annotations at the top (before) or the bottom (after) of the routes.rb file
216
+ --ps, --position-in-serializer [before|top|after|bottom]
217
+ Place the annotations at the top (before) or the bottom (after) of the serializer files
218
+ --w, --wrapper STR Wrap annotation with the text passed as parameter.
219
+ If --w option is used, the same text will be used as opening and closing
220
+ --wo, --wrapper-open STR Annotation wrapper opening.
221
+ --wc, --wrapper-close STR Annotation wrapper closing
222
+ -r, --routes Annotate routes.rb with the output of 'rake routes'
223
+ --models Annotate ActiveRecord models
224
+ -a, --active-admin Annotate active_admin models
225
+ -v, --version Show the current version of this gem
226
+ -m, --show-migration Include the migration version number in the annotation
227
+ -k, --show-foreign-keys List the table's foreign key constraints in the annotation
228
+ --ck, --complete-foreign-keys
229
+ Complete foreign key names in the annotation
230
+ -i, --show-indexes List the table's database indexes in the annotation
231
+ -s, --simple-indexes Concat the column's related indexes in the annotation
232
+ --model-dir dir Annotate model files stored in dir rather than app/models, separate multiple dirs with commas
233
+ --root-dir dir Annotate files stored within root dir projects, separate multiple dirs with commas
234
+ --ignore-model-subdirects Ignore subdirectories of the models directory
235
+ --sort Sort columns alphabetically, rather than in creation order
236
+ --classified-sort Sort columns alphabetically, but first goes id, then the rest columns, then the timestamp columns and then the association columns
237
+ -R, --require path Additional file to require before loading models, may be used multiple times
238
+ -e [tests,fixtures,factories,serializers],
239
+ --exclude Do not annotate fixtures, test files, factories, and/or serializers
240
+ -f [bare|rdoc|yard|markdown], Render Schema Infomation as plain/RDoc/YARD/Markdown
241
+ --format
242
+ --force Force new annotations even if there are no changes.
243
+ --frozen Do not allow to change annotations. Exits non-zero if there are going to be changes to files.
244
+ --timestamp Include timestamp in (routes) annotation
245
+ --trace If unable to annotate a file, print the full stack trace, not just the exception message.
246
+ -I, --ignore-columns REGEX don't annotate columns that match a given REGEX (e.g. `annotate -I '^(id|updated_at|created_at)'`)
247
+ --ignore-routes REGEX don't annotate routes that match a given REGEX (e.g. `annotate -I '(mobile|resque|pghero)'`)_
248
+ --hide-limit-column-types VALUES
249
+ don't show limit for given column types, separated by commas (e.g. `integer,boolean,text`)
250
+ --hide-default-column-types VALUES
251
+ don't show default for given column types, separated by commas (e.g. `json,jsonb,hstore`)
252
+ --ignore-unknown-models don't display warnings for bad model files
253
+ --with-comment include database comments in model annotations
254
+
255
+ ### Option: `additional_file_patterns`
256
+
257
+ CLI: `--additional-file-patterns`<br>
258
+ Ruby: `:additional_file_patterns`
259
+
260
+ Provide additional paths for the gem to annotate. These paths can include
261
+ globs. It is recommended to use absolute paths. Here are some examples:
262
+
263
+ * `/app/lib/decorates/%MODEL_NAME%/*.rb`
264
+ * `/app/lib/forms/%PLURALIZED_MODEL_NAME%/**/*.rb`
265
+ * `/app/lib/forms/%TABLE_NAME%/*.rb`
266
+
267
+
268
+ The appropriate model will be inferred using the `%*%` syntax, annotating any
269
+ matching files. It works with existing filename resolutions (options for which
270
+ can be found in the `resolve_filename` method of `annotate_models.rb`).
271
+
272
+ When using in a Rails config, you can use the following:
273
+
274
+ `File.join(Rails.application.root,
275
+ 'app/lib/forms/%PLURALIZED_MODEL_NAME%/***/**.rb')`
276
+
277
+ ## Sorting
278
+
279
+ By default, columns will be sorted in database order (i.e. the order in which
280
+ migrations were run).
281
+
282
+ If you prefer to sort alphabetically so that the results of annotation are
283
+ consistent regardless of what order migrations are executed in, use `--sort`.
284
+
285
+ ## Markdown
286
+
287
+ The format produced is actually MultiMarkdown, making use of the syntax
288
+ extension for tables. It's recommended you use `kramdown` as your parser if
289
+ you want to use this format. If you're using `yard` to generate
290
+ documentation, specify a format of markdown with `kramdown` as the provider by
291
+ adding this to your `.yardopts` file:
292
+
293
+ --markup markdown
294
+ --markup-provider kramdown
295
+
296
+ Be sure to add this to your `Gemfile` as well:
297
+
298
+ gem 'kramdown', groups => [:development], require => false
299
+
300
+ ## WARNING
301
+
302
+ **Don't add text after an automatically-created comment block.** This tool
303
+ will blow away the initial/final comment block in your models if it looks like
304
+ it was previously added by this gem.
305
+
306
+ Be sure to check the changes that this tool makes! If you are using Git, you
307
+ may simply check your project's status after running `annotate`:
308
+
309
+ $ git status
310
+
311
+ If you are not using a VCS (like Git, Subversion or similar), please tread
312
+ extra carefully, and consider using one.
313
+
314
+ ## Links
315
+
316
+ * Factory Bot: http://github.com/thoughtbot/factory_bot
317
+ * Object Daddy: http://github.com/flogic/object_daddy
318
+ * Machinist: http://github.com/notahat/machinist
319
+ * Fabrication: http://github.com/paulelliott/fabrication
320
+ * SpatialAdapter: http://github.com/pdeffendol/spatial_adapter
321
+ * PostgisAdapter: http://github.com/nofxx/postgis_adapter
322
+ * PostGISAdapter: https://github.com/dazuma/activerecord-postgis-adapter
323
+
324
+
325
+ ## License
326
+
327
+ Released under the same license as Ruby. No Support. No Warranty.
328
+
329
+ ## Authors
330
+
331
+ [See AUTHORS.md](AUTHORS.md).
data/RELEASE.md ADDED
@@ -0,0 +1,19 @@
1
+ ## Prerequisite
2
+
3
+ - Install "git-flow" (`brew install git-flow`)
4
+ - Install "bump" gem (`gem install bump`)
5
+
6
+
7
+ ## Perform a release
8
+
9
+ - `git flow release start <release>`
10
+ - Update the `CHANGELOG.md` file
11
+ - `bump current`
12
+ - `bump patch`
13
+ - `rm -rf dist`
14
+ - `rake spec`
15
+ - `rake gem`
16
+ - `git flow release finish <release>`
17
+
18
+ - `rake gem:publish`
19
+
data/annotate.gemspec CHANGED
@@ -1,39 +1,32 @@
1
- # This file is auto-generated!
2
- # DO NOT EDIT THIS FILE DIRECTLY!
3
- # Instead, edit the Rakefile and run 'rake gems:gemspec'.# -*- encoding: utf-8 -*-
4
- # stub: annotate 2.6.3 ruby lib
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'annotate/version'
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = "annotate"
8
- s.version = "2.6.3"
7
+ s.name = 'annotate'
8
+ s.version = Annotate.version
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.require_paths = ["lib"]
12
- s.authors = ["Alex Chaffee", "Cuong Tran", "Marcos Piccinini", "Turadg Aleahmad", "Jon Frisby"]
13
- s.date = "2014-04-05"
14
- s.description = "Annotates Rails/ActiveRecord Models, routes, fixtures, and others based on the database schema."
15
- s.email = ["alex@stinky.com", "cuong@gmail.com", "x@nofxx.com", "turadg@aleahmad.net", "jon@cloudability.com"]
16
- s.executables = ["annotate"]
17
- s.extra_rdoc_files = ["README.rdoc", "CHANGELOG.rdoc", "TODO.rdoc"]
18
- s.files = [".travis.yml", "AUTHORS.rdoc", "CHANGELOG.rdoc", "LICENSE.txt", "README.rdoc", "TODO.rdoc", "annotate.gemspec", "bin/annotate", "lib/annotate.rb", "lib/annotate/active_record_patch.rb", "lib/annotate/annotate_models.rb", "lib/annotate/annotate_routes.rb", "lib/annotate/tasks.rb", "lib/annotate/version.rb", "lib/generators/annotate/USAGE", "lib/generators/annotate/install_generator.rb", "lib/generators/annotate/templates/auto_annotate_models.rake", "lib/tasks/annotate_models.rake", "lib/tasks/annotate_routes.rake", "lib/tasks/migrate.rake"]
19
- s.homepage = "http://github.com/ctran/annotate_models"
20
- s.licenses = ["Ruby"]
21
- s.rubyforge_project = "annotate"
22
- s.rubygems_version = "2.2.2"
23
- s.summary = "Annotates Rails Models, routes, fixtures, and others based on the database schema."
10
+ s.required_ruby_version = '>= 2.4.0'
11
+ s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
12
+ s.authors = ['Alex Chaffee', 'Cuong Tran', 'Marcos Piccinini', 'Turadg Aleahmad', 'Jon Frisby']
13
+ s.description = 'Annotates Rails/ActiveRecord Models, routes, fixtures, and others based on the database schema.'
14
+ s.email = ['alex@stinky.com', 'cuong.tran@gmail.com', 'x@nofxx.com', 'turadg@aleahmad.net', 'jon@cloudability.com']
15
+ s.executables = ['annotate']
16
+ s.extra_rdoc_files = ['README.md', 'CHANGELOG.md']
17
+ s.files = `git ls-files -z LICENSE.txt *.md *.gemspec bin lib`.split("\x0")
18
+ s.homepage = 'https://github.com/ctran/annotate_models'
19
+ s.licenses = ['Ruby']
20
+ s.require_paths = ['lib']
21
+ s.rubygems_version = '2.1.11'
22
+ s.summary = 'Annotates Rails Models, routes, fixtures, and others based on the database schema.'
24
23
 
25
- if s.respond_to? :specification_version then
26
- s.specification_version = 4
24
+ s.specification_version = 4 if s.respond_to? :specification_version
25
+ s.add_runtime_dependency(%q<rake>, '>= 10.4', '< 14.0')
26
+ s.add_runtime_dependency(%q<activerecord>, ['>= 3.2', '< 8.0'])
27
27
 
28
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
29
- s.add_runtime_dependency(%q<rake>, [">= 0.8.7"])
30
- s.add_runtime_dependency(%q<activerecord>, [">= 2.3.0"])
31
- else
32
- s.add_dependency(%q<rake>, [">= 0.8.7"])
33
- s.add_dependency(%q<activerecord>, [">= 2.3.0"])
34
- end
35
- else
36
- s.add_dependency(%q<rake>, [">= 0.8.7"])
37
- s.add_dependency(%q<activerecord>, [">= 2.3.0"])
38
- end
28
+ s.metadata = {
29
+ "bug_tracker_uri" => "https://github.com/ctran/annotate_models/issues/",
30
+ "source_code_uri" => "https://github.com/ctran/annotate_models.git"
31
+ }
39
32
  end
data/bin/annotate CHANGED
@@ -1,148 +1,32 @@
1
1
  #!/usr/bin/env ruby
2
+
3
+ unless File.exist?('./Rakefile') || File.exist?('./Gemfile')
4
+ abort 'Please run annotate from the root of the project.'
5
+ end
6
+
2
7
  require 'rubygems'
3
8
  begin
4
9
  require 'bundler'
5
10
  Bundler.setup
6
- rescue Exception => e
11
+ rescue StandardError
7
12
  end
8
13
 
9
14
  here = File.expand_path(File.dirname __FILE__)
10
- $:<< "#{here}/../lib"
15
+ $LOAD_PATH << "#{here}/../lib"
11
16
 
12
- require 'optparse'
13
17
  require 'annotate'
14
- Annotate.bootstrap_rake
15
-
16
- target = {
17
- :klass => AnnotateModels,
18
- :task => :do_annotations,
19
- }
20
- has_set_position = {}
21
- OptionParser.new do |opts|
22
- opts.banner = "Usage: annotate [options] [model_file]*"
23
-
24
- opts.on('-d', '--delete',
25
- "Remove annotations from all model files or the routes.rb file") do
26
-
27
- target[:task] = :remove_annotations
28
- end
29
-
30
- opts.on('-p', '--position [before|after]', ['before', 'after'],
31
- "Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/routes file(s)") do |p|
32
- ENV['position'] = p
33
- [
34
- 'position_in_class','position_in_factory','position_in_fixture','position_in_test', 'position_in_routes'
35
- ].each do |key|
36
- ENV[key] = p unless(has_set_position[key])
37
- end
38
- end
39
-
40
- opts.on('--pc', '--position-in-class [before|after]', ['before', 'after'],
41
- "Place the annotations at the top (before) or the bottom (after) of the model file") do |p|
42
- ENV['position_in_class'] = p
43
- has_set_position['position_in_class'] = true
44
- end
45
-
46
- opts.on('--pf', '--position-in-factory [before|after]', ['before', 'after'],
47
- "Place the annotations at the top (before) or the bottom (after) of any factory files") do |p|
48
- ENV['position_in_factory'] = p
49
- has_set_position['position_in_factory'] = true
50
- end
51
-
52
- opts.on('--px', '--position-in-fixture [before|after]', ['before', 'after'],
53
- "Place the annotations at the top (before) or the bottom (after) of any fixture files") do |p|
54
- ENV['position_in_fixture'] = p
55
- has_set_position['position_in_fixture'] = true
56
- end
57
-
58
- opts.on('--pt', '--position-in-test [before|after]', ['before', 'after'],
59
- "Place the annotations at the top (before) or the bottom (after) of any test files") do |p|
60
- ENV['position_in_test'] = p
61
- has_set_position['position_in_test'] = true
62
- end
63
-
64
- opts.on('--pr', '--position-in-routes [before|after]', ['before', 'after'],
65
- "Place the annotations at the top (before) or the bottom (after) of the routes.rb file") do |p|
66
- ENV['position_in_routes'] = p
67
- has_set_position['position_in_routes'] = true
68
- end
18
+ require 'annotate/parser'
69
19
 
70
- opts.on('-r', '--routes',
71
- "Annotate routes.rb with the output of 'rake routes'") do
72
- target = {
73
- :klass => AnnotateRoutes,
74
- :task => :do_annotations
75
- }
76
- end
77
-
78
- opts.on('-v', '--version',
79
- "Show the current version of this gem") do
80
- puts "annotate v#{Annotate.version}"; exit
81
- end
82
-
83
- opts.on('-m', '--show-migration',
84
- "Include the migration version number in the annotation") do
85
- ENV['include_version'] = "yes"
86
- end
87
-
88
- opts.on('-i', '--show-indexes',
89
- "List the table's database indexes in the annotation") do
90
- ENV['show_indexes'] = "yes"
91
- end
92
-
93
- opts.on('-s', '--simple-indexes',
94
- "Concat the column's related indexes in the annotation") do
95
- ENV['simple_indexes'] = "yes"
96
- end
97
-
98
- opts.on('--model-dir dir',
99
- "Annotate model files stored in dir rather than app/models") do |dir|
100
- ENV['model_dir'] = dir
101
- end
102
-
103
- opts.on('--ignore-model-subdirects',
104
- "Ignore subdirectories of the models directory") do |dir|
105
- ENV['ignore_model_sub_dir'] = "yes"
106
- end
107
-
108
- opts.on('--sort',
109
- "Sort columns alphabetically, rather than in creation order") do |dir|
110
- ENV['sort'] = "yes"
111
- end
112
-
113
- opts.on('-R', '--require path',
114
- "Additional file to require before loading models, may be used multiple times") do |path|
115
- if !ENV['require'].blank?
116
- ENV['require'] = ENV['require'] + ",#{path}"
117
- else
118
- ENV['require'] = path
119
- end
120
- end
121
-
122
- opts.on('-e', '--exclude [tests,fixtures,factories]', Array, "Do not annotate fixtures, test files, and/or factories") do |exclusions|
123
- exclusions ||= %w(tests fixtures factories)
124
- exclusions.each { |exclusion| ENV["exclude_#{exclusion}"] = "yes" }
125
- end
126
-
127
- opts.on('-f', '--format [bare|rdoc|markdown]', ['bare', 'rdoc', 'markdown'], 'Render Schema Infomation as plain/RDoc/Markdown') do |fmt|
128
- ENV["format_#{fmt}"] = 'yes'
129
- end
130
-
131
- opts.on('--force', 'Force new annotations even if there are no changes.') do |force|
132
- ENV['force'] = 'yes'
133
- end
134
-
135
- opts.on('--trace', 'If unable to annotate a file, print the full stack trace, not just the exception message.') do |value|
136
- ENV['trace'] = 'yes'
137
- end
20
+ Annotate.bootstrap_rake
138
21
 
139
- 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|
140
- ENV['ignore_columns'] = regex
141
- end
22
+ options_result = Annotate::Parser.parse(ARGV)
142
23
 
143
- end.parse!
24
+ exit if options_result[:exit]
144
25
 
26
+ options = Annotate.setup_options(
27
+ is_rake: ENV['is_rake'] && !ENV['is_rake'].empty?
28
+ )
29
+ Annotate.eager_load(options) if Annotate::Helpers.include_models?
145
30
 
146
- options=Annotate.setup_options({ :is_rake => !ENV['is_rake'].blank? })
147
- Annotate.eager_load(options)
148
- target[:klass].send(target[:task], options)
31
+ AnnotateModels.send(options_result[:target_action], options) if Annotate::Helpers.include_models?
32
+ AnnotateRoutes.send(options_result[:target_action], options) if Annotate::Helpers.include_routes?
@@ -2,7 +2,7 @@
2
2
 
3
3
  module ::ActiveRecord
4
4
  class Base
5
- def self.method_missing(name, *args)
5
+ def self.method_missing(_name, *_args)
6
6
  # ignore this, so unknown/unloaded macros won't cause parsing to fail
7
7
  end
8
8
  end