Skip to content

Commit

Permalink
Make tests pass with JRuby and reinstate 2.2 compat (#112)
Browse files Browse the repository at this point in the history
Fixes #99

Rename the `String#encode` argument to `undef:` so that
jRuby becomes compatible again.

Also remove uses of the save navigation operator to restore
compatibility with MRI 2.2, since we can have it so easily
  • Loading branch information
kostyadubinin authored and julik committed May 3, 2018
1 parent bc2b5a3 commit 4b7aa2c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
rvm:
- 2.2.0
- 2.3.0
- 2.4.2
- 2.5.0
- jruby-9.0
sudo: false
cache: bundler
matrix:
allow_failures:
- rvm: jruby-9.0
script:
- bundle exec rubocop
- bundle exec rspec
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased
* Add support for Ruby 2.2.0
* Fix support for JRuby 9.0

## 0.12.0
* Relay upstream status from `RemoteIO` in the `status_code` attribute (returns an `Integer`)

Expand Down Expand Up @@ -127,4 +131,4 @@
## 0.1.0
* Add parsers for PNG, JPG, TIFF, PSD
* Add GIF parser
* Add DPX parser
* Add DPX parser
6 changes: 3 additions & 3 deletions lib/parsers/jpeg_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def scan
format: :jpg,
width_px: @width,
height_px: @height,
display_width_px: @exif_data&.rotated? ? @height : @width,
display_height_px: @exif_data&.rotated? ? @width : @height,
orientation: @exif_data&.orientation,
display_width_px: @exif_data && @exif_data.rotated? ? @height : @width,
display_height_px: @exif_data && @exif_data.rotated? ? @width : @height,
orientation: @exif_data && @exif_data.orientation,
intrinsics: {exif: @exif_data},
)

Expand Down
2 changes: 1 addition & 1 deletion lib/parsers/zip_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def directory?(zip_entry)

def decode_filename(filename, likely_unicode:)
filename.force_encoding(Encoding::UTF_8) if likely_unicode
filename.encode(Encoding::UTF_8, undefined: :replace, replace: UNICODE_REPLACEMENT_CHAR)
filename.encode(Encoding::UTF_8, undef: :replace, replace: UNICODE_REPLACEMENT_CHAR)
end

def decode_filename_of(zip_entry)
Expand Down

0 comments on commit 4b7aa2c

Please sign in to comment.