Skip to content

Commit

Permalink
Output MuTool Version info
Browse files Browse the repository at this point in the history
  • Loading branch information
malomalo committed Nov 22, 2023
1 parent fb1dee7 commit 1845e3a
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 15 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
strategy:
matrix:
vips-version:
- 8.14.5
- 8.15.0
im-version:
- 7.1.1-17
- 7.1.1-21
ruby-version:
- 3.0.5
backend:
Expand Down Expand Up @@ -116,8 +116,11 @@ jobs:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

- run: |
- env:
VIPS_WARNING: 1
run: |
vips --version
identify --version
ffmpeg -version
mutool -v
bundle exec rake test:${{ matrix.backend }}
4 changes: 4 additions & 0 deletions lib/bob_ross/backends/imagemagick.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ module BobRoss::ImageMagickBackend

class <<self

def key
:im
end

def version
return @version if @version
version_cmd = Terrapin::CommandLine.new("identify", '-version')
Expand Down
4 changes: 4 additions & 0 deletions lib/bob_ross/backends/libvips.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ module BobRoss::LibVipsBackend

class <<self

def key
:vips
end

def version
Vips.version_string
end
Expand Down
11 changes: 10 additions & 1 deletion test/bob_ross/server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,16 @@ def create_server(configs={})

response = server.get("/flyer")
assert_equal 'image/jpeg', response.headers['Content-Type']
assert_includes ['7d5daa0941b10cb47277e954a77413b2', '2f4645b128d93f5d9304b79baabb9fdd'], Digest::MD5.hexdigest(response.body)
assert_includes key_for_version(key_for_backend(key_for_version({
'>= 1.19.0' => {
im: {
'>= 7.1.1-21' => '7d5daa0941b10cb47277e954a77413b2'
},
vips: {
'>= 8.15.0' => '2f4645b128d93f5d9304b79baabb9fdd'
}
}
}, mupdf_version))), Digest::MD5.hexdigest(response.body)

response = server.get("/S100/floorplan")
assert_equal 'image/jpeg', response.headers['Content-Type']
Expand Down
36 changes: 25 additions & 11 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ def self.test(name, requires: nil, &block)
end
end
end


def mupdf_version
return @version if @version
version_cmd = Terrapin::CommandLine.new("mutool", '-v')
version_cmd.run
@version = version_cmd.output.error_output.match(/version\s+(\S+)/)[1]
end

def wait_until
while !yield
sleep 0.1
Expand Down Expand Up @@ -83,19 +90,26 @@ def assert_geometry(geom, image)
assert_equal geom, "#{image.width}x#{image.height}"
end

def backend
BobRoss.backend.key
end

def key_for_backend(hash, backend=nil)
hash[backend || BobRoss.backend.key]
end

def key_for_version(hash, version=nil)
version ||= BobRoss.backend.version

hash.find do |k,v|
Gem::Dependency.new('a', k).match?('a', version.gsub('-', '.'))
end&.[](1)
end

# exp is the signature or [IM sig, libvips sig]
def assert_signature(expected, image)
if expected.is_a?(Hash)
case BobRoss.backend.name
when 'BobRoss::ImageMagickBackend'
expected = expected[:im].find do |k,v|
Gem::Dependency.new('a', k).match?('a', BobRoss.backend.version.gsub('-', '.'))
end&.[](1)
when 'BobRoss::LibVipsBackend'
expected = expected[:vips].find do |k,v|
Gem::Dependency.new('a', k).match?('a', BobRoss.backend.version.gsub('-', '.'))
end&.[](1)
end
expected = key_for_version(key_for_backend(expected))
end

signature = `identify -verbose '#{image.path}'`.match(/signature: (\w+)/)[1]
Expand Down

0 comments on commit 1845e3a

Please sign in to comment.