Skip to content
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

Support test matchers with only Vips #2767

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions lib/carrierwave/test/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ class ImageLoader # :nodoc:
def self.load_image(filename)
if defined? ::MiniMagick
MiniMagickWrapper.new(filename)
elsif defined? ::Vips
VipsWrapper.new(filename)
else
unless defined? ::Magick
begin
Expand Down Expand Up @@ -393,6 +395,28 @@ def initialize(filename)
end
end

class VipsWrapper # :nodoc:
attr_reader :image

def width
image.width
end

def height
image.height
end

def format
# This returns the name of the vips loader (e.g. pngload) as Vips
# doesn't do content detection.
image.get("vips-loader").delete_suffix("load")
end

def initialize(filename)
@image = ::Vips::Image.new_from_file(filename)
end
end

end # Matchers
end # Test
end # CarrierWave