-
Notifications
You must be signed in to change notification settings - Fork 259
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
Extend gemspec pattern matching #246
Conversation
If there are multiple values in a licenses array I suspect the best match for current functionality would be to return |
lib/licensee/matchers/gemspec.rb
Outdated
|
||
# this will capture each value in the license array | ||
# for now only return the first match | ||
match = @file.content.match LICENSE_ARRAY_REGEX |
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.
Ideally, we'd abstract things such that a project file could have multiple licenses, but for now, I agree with @mlinksva that "other" would be the consistent response here (but I'd leave the other logic intact to allow for that). Perhaps expose a matches
method for now (in addition to match
)?
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 avoided adding any new fields at a broad scope because I wasn't sure how they would be used. It definitely seems worth thinking about for the future.
@benbalter @mlinksva thanks for taking a look! I've updated per feedback, though I'm not sure why the |
Probably just added that to test the service. No idea. Safe to ignore. |
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.
👾
Found a few issues with parsing the
license
field out of a gemspec.licenses
array field that wasn't found and captured."mit".freeze
Ruby allows regex's to be interpolated inside other regex's which makes the array regex much easier to understand and work with. It also made it simpler to ensure values were treated equally among all of the regular expressions.
The only captured group in these regex's is the license text. All other groups are non-capturing with
(?: ...)
. Meaning in an array like["mit", "bsd-3-clause"]
,match[1] == "mit"
andmatch[2] == "bsd-3-clause"
Only the first array value is used, to match current functionality.