diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc index b004220..5405b11 100644 --- a/CHANGELOG.rdoc +++ b/CHANGELOG.rdoc @@ -7,6 +7,8 @@ The file documents the changes to this library over the different versions. === Unreleased changes +- Fixed functionality of #from_file within non-main Ractors. + === 1.4.0 - 2020-12-28 - Add compatibility for Ruby 3.0. diff --git a/lib/chunky_png.rb b/lib/chunky_png.rb index b0c6675..654d1d1 100644 --- a/lib/chunky_png.rb +++ b/lib/chunky_png.rb @@ -143,7 +143,7 @@ class UnitsUnknown < ChunkyPNG::Exception # Null-byte, with the encoding set correctly to ASCII-8BIT (binary) in Ruby 1.9. # @return [String] A binary string, consisting of one NULL-byte. # @private - EXTRA_BYTE = "\0".b + EXTRA_BYTE = "\0".b.freeze end require "chunky_png/version" diff --git a/lib/chunky_png/chunk.rb b/lib/chunky_png/chunk.rb index 866f8ec..6bf10ad 100644 --- a/lib/chunky_png/chunk.rb +++ b/lib/chunky_png/chunk.rb @@ -467,6 +467,6 @@ def content "zTXt" => CompressedText, "iTXt" => InternationalText, "pHYs" => Physical, - } + }.freeze end end diff --git a/lib/chunky_png/color.rb b/lib/chunky_png/color.rb index a96b793..96a3304 100644 --- a/lib/chunky_png/color.rb +++ b/lib/chunky_png/color.rb @@ -888,7 +888,7 @@ def euclidean_distance_rgba(pixel_after, pixel_before) whitesmoke: 0xf5f5f500, yellow: 0xffff0000, yellowgreen: 0x9acd3200, - } + }.freeze # Gets a color value based on a HTML color name. # diff --git a/spec/chunky_png/canvas_spec.rb b/spec/chunky_png/canvas_spec.rb index 5e3c19c..c4bc1c9 100644 --- a/spec/chunky_png/canvas_spec.rb +++ b/spec/chunky_png/canvas_spec.rb @@ -237,4 +237,11 @@ expect(subject.inspect).to eql "" end end + + it "should behave properly with the new Ruby 3.0 Ractors" do + filename = resource_file("operations.png") + ractor = Ractor.new { ChunkyPNG::Canvas.from_file(Ractor.receive) } + ractor.send(filename) + expect(ractor.take).to eql ChunkyPNG::Canvas.from_file(filename) + end end