Skip to content

Commit cad47f5

Browse files
authored
Make --additional_file_patterns consistent by using dashes (#654)
Changed references to `--additional_file_patterns` to be `--additional-file-patterns` to make it consistent with other flags.
1 parent 05ee216 commit cad47f5

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

README.rdoc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ you can do so with a simple environment variable, instead of editing the
163163
== Options
164164

165165
Usage: annotate [options] [model_file]*
166-
--additional_file_patterns Additional file paths or globs to annotate, separated by commas (e.g. `/foo/bar/%model_name%/*.rb,/baz/%model_name%.rb`)
166+
--additional-file-patterns Additional file paths or globs to annotate, separated by commas (e.g. `/foo/bar/%model_name%/*.rb,/baz/%model_name%.rb`)
167167
-d, --delete Remove annotations from all model files or the routes.rb file
168168
-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)
169169
--position
@@ -216,18 +216,18 @@ you can do so with a simple environment variable, instead of editing the
216216
--ignore-unknown-models don't display warnings for bad model files
217217
--with-comment include database comments in model annotations
218218

219-
=== Option: +additional_file_patterns+
219+
=== Option: +additional-file-patterns+
220220

221-
CLI: +--additional_file_patterns+<br>
222-
Ruby: +:additional_file_patterns+
221+
CLI: +--additional-file-patterns+<br>
222+
Ruby: +:additional-file-patterns+
223223

224224
Provide additional paths for the gem to annotate. These paths can include globs.
225225
It is recommended to use absolute paths. Here are some examples:
226226

227227

228-
- <code>/app/lib/decorates/%MODEL_NAME%/&ast;.rb</code>
229-
- <code>/app/lib/forms/%PLURALIZED_MODEL_NAME%/&ast;&ast;/&ast;.rb</code>
230-
- <code>/app/lib/forms/%TABLE_NAME%/&ast;.rb</code>
228+
- <code>/app/lib/decorates/%MODEL_NAME%/*.rb</code>
229+
- <code>/app/lib/forms/%PLURALIZED_MODEL_NAME%/**/*.rb</code>
230+
- <code>/app/lib/forms/%TABLE_NAME%/*.rb</code>
231231

232232
The appropriate model will be inferred using the <code>%*%</code> syntax, annotating any matching files.
233233
It works with existing filename resolutions (options for which can be found in the +resolve_filename+ method of

lib/annotate/parser.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,14 @@ def add_options_to_parser(option_parser) # rubocop:disable Metrics/MethodLength
4949

5050
option_parser.banner = 'Usage: annotate [options] [model_file]*'
5151

52-
option_parser.on('--additional_file_patterns path1,path2,path3', Array, "Additional file paths or globs to annotate, separated by commas (e.g. `/foo/bar/%model_name%/*.rb,/baz/%model_name%.rb`)") do |additional_file_patterns|
52+
option_parser.on('--additional-file-patterns path1,path2,path3', Array, "Additional file paths or globs to annotate, separated by commas (e.g. `/foo/bar/%model_name%/*.rb,/baz/%model_name%.rb`)") do |additional_file_patterns|
5353
ENV['additional_file_patterns'] = additional_file_patterns
5454
end
5555

5656
option_parser.on('-d', '--delete', 'Remove annotations from all model files or the routes.rb file') do
5757
@options[:target_action] = :remove_annotations
5858
end
5959

60-
option_parser.on('--additional_file_patterns path1,path2,path3', Array, "Additional file paths or globs to annotate") do |additional_file_patterns|
61-
ENV['additional_file_patterns'] = additional_file_patterns
62-
end
63-
6460
option_parser.on('-p', '--position [before|top|after|bottom]', positions,
6561
'Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route/serializer file(s)') do |p|
6662
env['position'] = p

spec/lib/annotate/parser_spec.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@ module Annotate # rubocop:disable Metrics/ModuleLength
1414
end
1515
end
1616

17-
%w[--additional_file_patterns].each do |option|
17+
%w[--additional-file-patterns].each do |option|
1818
describe option do
1919
it 'sets array of paths to :additional_file_patterns' do
20-
# options = "-a ${('foo/bar' 'baz')}"
21-
# Parser.parse(options)
22-
# expect(ENV['additional_file_patterns']).to eq(['foo/bar', 'baz'])
23-
2420
paths = 'foo/bar,baz'
2521
allow(ENV).to receive(:[]=)
2622
Parser.parse([option, paths])

0 commit comments

Comments
 (0)