Skip to content

Fix Ruby 2.7 keyword arguments warnings#74

Open
pocke wants to merge 1 commit intogdelugre:masterfrom
pocke:fix-ruby-2.7-kwargs-warnings
Open

Fix Ruby 2.7 keyword arguments warnings#74
pocke wants to merge 1 commit intogdelugre:masterfrom
pocke:fix-ruby-2.7-kwargs-warnings

Conversation

@pocke
Copy link

@pocke pocke commented Aug 15, 2020

This pull request resolves Ruby 2.7 keyword argument warnings.

The warnings are introduced since Ruby 2.7. In short, we need to keyword splat operator (**) to use a hash as keyword arguments.
details: https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/

We can confirm the warning from this repository with the test cases.

$ bundle exec rake
# Running:

............../path/to/origami/lib/origami/filters/predictors.rb:65: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/path/to/origami/lib/origami/filters/predictors.rb:83: warning: The called method `apply_pre_prediction' is defined here
/path/to/origami/lib/origami/filters/predictors.rb:71: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/path/to/origami/lib/origami/filters/predictors.rb:102: warning: The called method `apply_post_prediction' is defined here
................/path/to/origami/lib/origami/string.rb:440: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/path/to/origami/lib/origami/string.rb:377: warning: The called method `initialize' is defined here
/path/to/origami/lib/origami/string.rb:420: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/path/to/origami/lib/origami/string.rb:377: warning: The called method `initialize' is defined here
.......................

Finished in 0.556607s, 95.2198 runs/s, 767.1480 assertions/s.

53 runs, 427 assertions, 0 failures, 0 errors, 0 skips

And this pull request fixes all of them.

@ndbroadbent
Copy link

@gdelugre Sorry to bother you, but would it be possible to merge this PR and release a new version to fix the warnings?

My company is also actively using this gem, so I would be happy to help with maintaining it if you are looking for some help

@UniqueTokens
Copy link

Related: Ruby 3.0 & origami (2.1.0): Origami::Date.now throws ArgumentError #80

@corwinstephen
Copy link

@gdelugre seems to have completely disappeared. It may be worth officially migrating to a fork of this gem

@krtschmr
Copy link

so - shall we fork?

@ndbroadbent
Copy link

@corwinstephen @krtschmr yes it's probably time to fork. We still use Origami and need to keep it maintained. We will maintain a fork here: https://github.com/DocSpring/origami-docspring

And will release new Ruby gems under the name: origami-docspring

I'm getting some errors on Ruby 3.4.2 that I want to fix as well:

<internal:hash>:37:in 'initialize': unknown keywords: :operands, :render (ArgumentError)
	from /Users/ndbroadbent/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/bundler/gems/origami-a3685d675688/lib/origami/graphics/instruction.rb:31:in 'Class#new'
	from /Users/ndbroadbent/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/bundler/gems/origami-a3685d675688/lib/origami/graphics/instruction.rb:31:in '<class:Instruction>'

@ndbroadbent
Copy link

I've pushed origami-docspring v2.2.0 to Rubygems which includes this PR. (We've been running this fork in production for years.)

Please feel free to open PRs here: https://github.com/DocSpring/origami-docspring/pulls

I'm going to work on fixes for Ruby 3.4.2 now, and will also get the CI running on GitHub actions (instead of TravisCI)

@ndbroadbent
Copy link

ndbroadbent commented Mar 25, 2025

@corwinstephen @krtschmr Are you still using Origami, and if so, what minimum version of Ruby do we need to support in our fork?

See: https://www.ruby-lang.org/en/downloads/branches/

Ruby 3.1 is almost eol (end-of-life) so I am thinking that we will just support >= 3.2.

But if it's easy enough to keep it working for older versions, then anyone is more than welcome to open a PR and get CI passing.

@pocke
Copy link
Author

pocke commented May 29, 2025

@ndbroadbent Thank you for your work!
Unfortunately, I do not use this gem because I changed jobs. But feel free to use my patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants