-
Notifications
You must be signed in to change notification settings - Fork 61
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
Use double-splat for Ruby 3.0 compatibility #150
base: master
Are you sure you want to change the base?
Conversation
Hi @qnighy thank you for your PR.
|
Because in the old Ruby, SyntaxError would be raised before executing the whole |
any updates on this PR? I really need these changes. |
@guillaumebesse any chance you could fix up the PR and merge it? |
require 'simple_enum/translation' | ||
begin | ||
require 'simple_enum/translation' | ||
rescue SyntaxError |
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 am not a maintainer, or contributor to this project, probably should also be ArgumentError here. On Ruby 2.6 i get ArgumentError rather than SyntaxError. Just sharing my thoughts
@@ -15,7 +15,7 @@ def human_enum_name(enum, key, options = {}) | |||
defaults << key.to_s.humanize | |||
|
|||
options.reverse_merge! count: 1, default: defaults | |||
I18n.translate(defaults.shift, options) | |||
I18n.translate(defaults.shift, **options) |
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 am not a maintainer, or contributor to this project, but seems brittle to me to have this whole file duplicated to fix a single line.
We could rescue here the exception so we avoid duplicating unnecessary code. Just my thoughts
Ruby 3.0 separates keyword arguments from positional arguments. https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
This PR makes
simple_enum
compatible with the new behavior. As**
isn't supported in Ruby 1.9, this PR falls back to the old source code without**
when a syntax error occurs.