-
Notifications
You must be signed in to change notification settings - Fork 34
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
Move bundle_report rails compatibility logic into a class #137
base: main
Are you sure you want to change the base?
Conversation
|
||
incompatible_gems.each { |gem| gem.find_latest_compatible(rails_version: rails_version) } |
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.
@arielj I noticed you wrote this code, could you please elavorate a bit on this line? why is it needed? how is used? I do not get it. Thanks!
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.
incompatible_gems
is an array of gems that, given the current version they are in, are not compatible with the desired version of Rails
then this line loops through that array and looks for the newest version of each of those gems that is compatible with the desired version of Rails, that information is stored in the gem
object itself https://github.com/fastruby/next_rails/blob/main/lib/next_rails/gem_info.rb#L137 and it's used to print the target version of that gem in line 32
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.
That makes sense, yeah I noticed it was related to finding the latest compatible rails version for the gem, but didn't realize it. thanks! now that I have your attention what do you think about the PR? can you review it please?
61699bf
to
7f7a9df
Compare
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 added some comments
end | ||
|
||
def incompatible_gems | ||
@gems.reject { |gem| incompatible?(gem) }.sort_by(&:name) |
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.
@gems.reject { |gem| incompatible?(gem) }.sort_by(&:name) | |
@incompatible_gems ||= @gems.reject { |gem| incompatible?(gem) }.sort_by(&:name) |
this method is called twice in incompatible_gems_by_state
, this way it won't do all the reject->sort
thing twice
@options[:rails_version] | ||
end | ||
|
||
def incompatible?(gem) |
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 name correct? the method is called incompatible?
but internally it calls gem.compatible_with_rails?...
so I imagine true
means compatible, not incompatible
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.
also, it's used in the incompatible_gems
method to reject the compatible ones and keep the incompatible ones
I extracted it into a class because I think it will be easier to use the `incompatible_gems_by_state` data there.
Based on the code review
b8e927b
to
74e4bf6
Compare
Description
I extracted it into its own class
Motivation and Context
I think it will be easier to understand the
BundleReport.compatibility
method and its usagealso I will need to use data from the
incompatible_gems_by_state
method in another code.How Has This Been Tested?
There was an existing test case for the
erb_output
method, and I run it locally to make sure it still works.Screenshots:
I will abide by the code of conduct