-
Notifications
You must be signed in to change notification settings - Fork 4
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 Support for Ignoring Models with config.ignored_models
#16
base: master
Are you sure you want to change the base?
Conversation
Sorry I didn't mention this earlier but I don't think we need another means of configuration since the gem already has one. Could you please just add the |
Jeez that sucks. I guess I didn't read the readme well enough because there is no configurator example shown. |
13fe838
to
72c38e7
Compare
config.ignored_models
11ff57e
to
86a26ed
Compare
I've added specs however I cannot test ignored_models during annotation as the test suite doesn't seem to support the implemented method for translating the file name to class. Likely you would need to add a full Rails app to the test suite. |
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.
It seems like you are testing in the wrong place. You changed the Annotate.models
method but you are testing it in the specs for Annotate::File
which doesn't call it.
Actually it's the reverse - Annotate.annotate
uses Annotate.models
to get a list of models to annotate and then calls Annotate::File#annotate_with
on each of them.
I would suggest adding a test for Annotate.models
to check that it doesn't include the ignored models.
|
||
class User < ActiveRecord::Base | ||
### Define User constant | ||
end |
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.
Is this being used anywhere?
# config.yard = false | ||
# | ||
# # Define any models to be skipped by Annotate | ||
# config.ignored_models = [SomeIgnoredModel, AnotherIgnoredModel] |
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 see a potential problem here: AFAIK rails runs initializers before loading the application code so referring to the model classes as constants here will either fail or autoload them, possibly before other initializers are fired (and this doesn't sound good to me).
What if instead of class constants themselves we will use their names as strings? Like %w[SomeIgnoredModel AnotherIgnoredModel]
. What do you think?
private | ||
|
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 prefer to add empty lines only before public
/protected
/private
keywords, not after them; please don't change it.
def configurator | ||
@configurator ||= Configurator.new | ||
end | ||
|
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 empy line is redundant.
private | ||
|
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.
And here.
end | ||
|
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.
And here.
# enCoding: utf-8 | ||
# frozen_string_literal: true | ||
# warn_indent: true | ||
|
||
class User < ActiveRecord::Base | ||
has_many :posts | ||
end |
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 is not the expected result here as the ignored file will not be touched at all - the gem won't erase the old annotation. This is what should be expected.
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.
But since this is a wrong place to test ignored_models
you can just delete this.
I have some other more important tasks on the go right now. Do you have any interest in picking up this PR and finishing the specs for it? |
@westonganger currently I can't, sorry. Maybe in a few weeks. |
Solves #13