rails / jbuilder

Jbuilder: generate JSON objects with a Builder-style DSL
MIT License
4.34k stars 438 forks source link

ruby 3.4.0dev deprecates OpenStruct #561

Closed yahonda closed 6 months ago

yahonda commented 6 months ago

jbuilder has OpenStruct that will be deprecated in Ruby 3.4.0dev. https://bugs.ruby-lang.org/issues/20309

gemfile(true) do source "https://rubygems.org" gem "jbuilder" end p RUBY_VERSION


### Expected behavior
It should not show any warnings as executed against Ruby 3.3.0.

```ruby
$ ruby foo.rb
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
"3.3.0"

Actual behavior

It raises warning: ostruct was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.5.0. Add ostruct to your Gemfile or gemspec. warning.

$ ruby foo.rb
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
/home/yahonda/.rbenv/versions/trunk/lib/ruby/gems/3.4.0+0/gems/jbuilder-2.11.5/lib/jbuilder.rb:7: warning: ostruct was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.5.0. Add ostruct to your Gemfile or gemspec.
"3.4.0"
yahonda commented 6 months ago

Here are the lines OpenStruct is used.

https://github.com/rails/jbuilder/blob/387561395daf471f05287fc67d28e0a296988f57/lib/jbuilder.rb#L7

https://github.com/rails/jbuilder/blob/387561395daf471f05287fc67d28e0a296988f57/lib/jbuilder.rb#L31