-
Notifications
You must be signed in to change notification settings - Fork 19
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
Ruby 2.7 compatibility #28
Conversation
.travis.yml
Outdated
@@ -19,13 +19,16 @@ rvm: | |||
# Include JRuby first because it takes the longest | |||
- jruby-9.1.13.0 | |||
- 2.2 | |||
- 2.3.4 | |||
- 2.4.1 | |||
- 2.3 |
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 need to support those anymore.
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.
Thank you!
lib/http/form_data/composite_io.rb
Outdated
outbuf = outbuf.to_s.clear | ||
# buffer in JRuby is sometimes US-ASCII, force to ASCII-8BIT | ||
outbuf.force_encoding(Encoding::BINARY) | ||
data = outbuf ? outbuf.clear.force_encoding(Encoding::BINARY) : "".b |
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 feel neutral, but probably safenave here will look better:
data = outbuf ? outbuf.clear.force_encoding(Encoding::BINARY) : "".b | |
data = outbuf&.clear&.force_encoding(Encoding::BINARY) || "".b |
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.
Or two lines 😂:
data = outbuf ? outbuf.clear.force_encoding(Encoding::BINARY) : "".b | |
outbuf &&= outbuf.clear.force_encoding(Encoding::BINARY) | |
outbuf ||= "".b |
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.
Just to make it clear - I'm fine to keep the code the way it is now in the PR. Just throwing in ideas how to avoid ternary operator (I usually don't like it unless it's something super simple - like when branches are simple variables or literals).
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.
Makes sense about avoiding the ternary operator. I want the data
variable in order to make a distinction between outbuf
being set and not, so how about this?
data = outbuf.clear.force_encoding(Encoding::BINARY) if outbuf
data ||= "".b
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.
Works for me 👍
.rubocop.yml
Outdated
Metrics/CyclomaticComplexity: | ||
Max: 7 | ||
|
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.
Let me think a bit on how to avoid changing this.
.rubocop.yml
Outdated
|
||
Style/Next: | ||
Enabled: false |
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.
Same about this one.
@ixti I was able to fix both |
@ixti Any chance we could get this merged and released? Normally if it were only kwargs warnings it wouldn't be a big deal, but these are actual errors, so it would be useful to get the fix released 😃 Afterwards, we can bump This would help a lot in getting Shrine updated for Ruby 2.7 🙏 |
I believe this option was changed in RubyGems 3.0.
These have reached EOL.
I don't think we need to specify Bundler at all in the gemspec, so we remove it.
As of Ruby 2.7, Nil#to_s returns a frozen string. We update the code to ensure a mutable string is returned for the output buffer.
b3df1d6
to
1095586
Compare
I also cleaned up the commit history 😅 |
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.
Please make supported list of rubies explicit, and then it will be fine. ))
README.md
Outdated
* Ruby 2.3.x | ||
* Ruby 2.4.x | ||
* JRuby 9.1.x.x | ||
* Ruby 2.4+ |
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.
After recent incident in http gem I would like to keep this list explicit
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.
Updated 👍
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.
Looks awesome. Thank you very much.
I'll cut release shortly. |
Released as v2.2.0 |
Update ruby-http-form_data to 2.3.0. pkgsrc change: add "USE_LANGAUGES= # none". ## 2.3.0 (2020-03-08) * [#29](httprb/form_data#29) Enhance HTTP::FormData::Urlencoded with per-instance encoder. [@summera][] ## 2.2.0 (2020-01-09) * [#28](httprb/form_data#28) Ruby 2.7 compatibility. [@janko][]
In Ruby 2.7
Nil#to_s
now returns a frozen string, which causedFrozenError
exceptions inCompositeIO#read
whenoutbuf
wasnil
. So, we update the code to handle this properly.Ruby 2.7 also added deprecation warnings for the upcoming separation of positional and keyword arguments that is planned for Ruby 3.0. There were couple of specs that triggered the warning, so I updated the code to use the correct syntax.
I updated the Travis CI matrix to add 2.5, 2.6, and 2.7.