Skip to content

Commit

Permalink
Merge pull request #540 from lab-kw/fix_parse_warnings_regex
Browse files Browse the repository at this point in the history
Fix Info#parse_warnings regex
  • Loading branch information
thiagofm committed Sep 13, 2022
2 parents 575ba0f + 31cd87f commit 2ed9959
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mini_magick/image/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def parse_warnings(raw_info)

raw_info.split("\n").each do |line|
# must match "%m %w %h %b"
return line if line.match?(/^[A-Z]+ \d+ \d+ \d+B$/)
return line if line.match?(/^[A-Z]+ \d+ \d+ \d+(|\.\d+)([KMGTPEZY]{0,1})B$/)
end
raise TypeError
end
Expand Down
Binary file added spec/fixtures/large_webp.webp
Binary file not shown.
7 changes: 7 additions & 0 deletions spec/lib/mini_magick/image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,13 @@ def create(path = image_path)
subject.size("20x20")
end

describe "#size" do
it "returns the correct value even if the log contains unit prefixes" do
subject = described_class.new(image_path(:large_webp))
expect(subject.size).to be_a(Integer)
end
end

describe "#exif" do
it "returns a hash of EXIF data" do
subject = described_class.new(image_path(:exif))
Expand Down
1 change: 1 addition & 0 deletions spec/support/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def image_path(type = :default)
when :rgb then "rgb.png"
when :rgb_tmp then "rgb_tmp.png"
when :non_ascii_filename then "スクリーンショット 2019-07-13 1.32.01.png"
when :large_webp then "large_webp.webp"
else
fail "image #{type.inspect} doesn't exist"
end
Expand Down

0 comments on commit 2ed9959

Please sign in to comment.