-
Notifications
You must be signed in to change notification settings - Fork 1
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
Support Ruby 3 #38
Support Ruby 3 #38
Conversation
Ruby 3 separates positional and keyword arguments. Hence, double splat must be used to turn hashes into positional arguments. See: https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
relaton-bib.gemspec
Outdated
@@ -36,4 +36,5 @@ Gem::Specification.new do |spec| | |||
spec.add_dependency "bibtex-ruby" | |||
spec.add_dependency "iso639" | |||
spec.add_dependency "nokogiri" | |||
spec.add_dependency "rexml" |
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's very strange -- we don't use REXML...?
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.
We do. Or more precisely, BibTeX-Ruby uses it (see inukshuk/bibtex-ruby#146).
Ruby Standard Library is in the process of moving into gems. REXML has been degraded to a bundled gem in Ruby 3.0, therefore has to be specified as dependency somewhere (see https://stdgems.org/rexml/). BibTeX-Ruby maintainer has decided to make it an optional dependency, so we got to specify it ourselves.
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.
We don't write out to BibTeXML though, so that functionality is not needed 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.
Indeed. Initially it wasn't working without REXML, but it has been fixed in inukshuk/bibtex-ruby@4308f93. I'll remove this commit from the pull request.
Older versions do not work with Ruby 3.0.
@andrew2net @skalee this is also blocking metanorma-standoc: |
And we need a rebase please, thanks! |
Hi there, @skalee we have an issue with relaton: https://github.com/metanorma/metanorma-standoc/pull/459/checks?check_run_id=2377920739
|
@ronaldtse relaton fully supports Ruby 3.0 now. We don't need this PR anymore. |
Thanks @andrew2net @skalee , closing. |
@w00lf the issue is in the
To work in Ruby 3.0 it should call |
I confirm that relaton-bib works in Ruby 3 now. Thanks! |
Tried to apply your hotfix but encountered a situation when specs fail on ruby version less than 2.7 with error:
It seems that ruby version less than 2.7 does not support string keys, if i try to use |
@w00lf sorry, it's my mistake. Try to replace the line
with this
|
That works, all tests are passing. Thanks! |
This pull request adds Ruby 3.0 compatibility, or at least makes tests passing locally. It's likely that other Relaton gems require changes too. I was experimenting with Ruby 3.0 compatibility on this gem only.
The only significant change is that double splat operator (
**
) is used when passing a hash to a method which expects keyword arguments rather than actual hash. This is required because Ruby 3.0 no longer decomposes such hashes implicitly (see https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/).I am not sure if these are the only required changes, but they are enough to make tests passing.
Neither I'm sure if all these methods really should accept keyword arguments. Perhaps it'd be better to accept hash as a single positional argument. I wasn't analyzing that.
Apart from codebase itself, some dependencies also aren't compatible with Ruby 3.0 yet:
bibtex-ruby
(waiting for Support Ruby 3.0 inukshuk/bibtex-ruby#146)debase
ruby-debug-ide