-
Notifications
You must be signed in to change notification settings - Fork 649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option for additional file patterns #633
Conversation
case pattern_type | ||
when 'test' then test_files(root_directory) | ||
when 'fixture' then fixture_files(root_directory) | ||
when 'scaffold' then scaffold_files(root_directory) | ||
when 'factory' then factory_files(root_directory) | ||
when 'serializer' then serialize_files(root_directory) | ||
when 'additional_file_patterns' | ||
[options[:additional_file_patterns] || []].flatten |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate what's going on here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will return the config setting additional_file_patterns
, which is a list of files and/or globs. This allows the gem to infer models based on file structure or naming and annotate additional files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should've been more specific - I'm curious about:
[options[:additional_file_patterns] || []].flatten
Is there any special reason behind it? Couldn't it also be:
options[:additional_file_patterns] || []
Ah, yes. It's to handle when the input setting is an array of arrays. We
could validate the input to make sure it's a 1D array of strings if there's
a good place for that.
On Wed, Jul 10, 2019 at 01:49 Andrew W. Lee ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In lib/annotate/annotate_models.rb
<#633 (comment)>:
> case pattern_type
when 'test' then test_files(root_directory)
when 'fixture' then fixture_files(root_directory)
when 'scaffold' then scaffold_files(root_directory)
when 'factory' then factory_files(root_directory)
when 'serializer' then serialize_files(root_directory)
+ when 'additional_file_patterns'
+ [options[:additional_file_patterns] || []].flatten
I should've been more specific - I'm curious about:
[options[:additional_file_patterns] || []].flatten
Is there any special reason behind it? Couldn't it also be:
options[:additional_file_patterns] || []
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#633?email_source=notifications&email_token=AAFAT3X77HSHE3LA3Z6MJNDP6VZ6PA5CNFSM4H4A5FS2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOB56XMRA#discussion_r301894826>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAFAT3Q5CS6ENIQNIE4J5ELP6VZ6PANCNFSM4H4A5FSQ>
.
--
…--
Ryan Jackson
[email protected]
|
Oh no problem, I didn't consider that possibility. So right now it looks like this can be used by invoking Annotate in code. Do you think this should and could be invoked using command line arguments? This would be covered in |
Also nice to see a fellow xooyalan! 👋 |
8bb7a92
to
58d61b1
Compare
Looks good thanks for adding tests and adding it to the CLI. |
Adds option for additional file patterns (implemented in #633) in the CLI.
This PR adds an option named `additional_file_patterns`. You can specify custom path patterns (including globs) that the gem will use to annotate. For example, I used it like this on a project: ```ruby Annotate.set_defaults( 'additional_file_patterns' => [ File.join(Rails.application.root, 'app/lib/forms/%PLURALIZED_MODEL_NAME%/**/*.rb'), File.join(Rails.application.root, 'spec/lib/forms/%PLURALIZED_MODEL_NAME%/**/*.rb') ], ... ) ``` This makes it possible to have files nested under a directory which corresponds to the model. I believe this fixes ctran#594.
Adds option for additional file patterns (implemented in ctran#633) in the CLI.
This PR adds an option named `additional_file_patterns`. You can specify custom path patterns (including globs) that the gem will use to annotate. For example, I used it like this on a project: ```ruby Annotate.set_defaults( 'additional_file_patterns' => [ File.join(Rails.application.root, 'app/lib/forms/%PLURALIZED_MODEL_NAME%/**/*.rb'), File.join(Rails.application.root, 'spec/lib/forms/%PLURALIZED_MODEL_NAME%/**/*.rb') ], ... ) ``` This makes it possible to have files nested under a directory which corresponds to the model. I believe this fixes ctran#594.
Adds option for additional file patterns (implemented in ctran#633) in the CLI.
This PR adds an option named
additional_file_patterns
. You can specify custom path patterns (including globs) that the gem will use to annotate.For example, I used it like this on a project:
This makes it possible to have files nested under a directory which corresponds to the model.
I believe this fixes #594.