Compare commits

4 Commits

Author SHA1 Message Date
ac5a17dbb8 Add badge with gem version and link
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-14 16:21:53 +02:00
784543f32d Release 1.1.0
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2024-08-14 16:17:27 +02:00
a070bb6a49 Merge pull request 'Allow selecting image type via Regexp' (#6) from feature/select_type_regex into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #6
2024-08-14 14:14:34 +00:00
682f66f476 Allow selecting image type via Regexp
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
For example, SVG images might be of type "image/svg" or "image/svg+xml"
2024-08-14 16:13:50 +02:00
5 changed files with 20 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
PATH
remote: .
specs:
manifique (1.0.1)
manifique (1.1.0)
faraday (~> 2.9.0)
faraday-follow_redirects (= 0.3.0)
nokogiri (~> 1.16.0)

View File

@@ -1,3 +1,4 @@
[![Ruby Gem version](https://img.shields.io/gem/v/manifique)](https://rubygems.org/gems/manifique)
[![Build Status](https://drone.kosmos.org/api/badges/5apps/manifique/status.svg)](https://drone.kosmos.org/5apps/manifique)
# Manifique

View File

@@ -43,7 +43,13 @@ module Manifique
end
if options[:type]
results.reject! { |r| r["type"] != options[:type] }
if options[:type].is_a?(String)
results.reject! { |r| r["type"] != options[:type] }
elsif options[:type].is_a?(Regexp)
results.reject! { |r| r["type"].match(options[:type]).nil? }
else
raise ArgumentError, "Type must be a string or a regular expression"
end
end
if options[:sizes]

View File

@@ -1,3 +1,3 @@
module Manifique
VERSION = "1.0.1"
VERSION = "1.1.0"
end

View File

@@ -68,6 +68,16 @@ RSpec.describe Manifique::Metadata do
icon = metadata.select_icon(type: "image/png")
expect(icon["sizes"]).to eq("512x512")
end
it "matches strings exactly" do
icon = metadata.select_icon(type: "image/svg")
expect(icon["type"]).to eq("image/svg")
end
it "works with a regex" do
icon = metadata.select_icon(type: /image\/svg/)
expect(icon["type"]).to eq("image/svg+xml")
end
end
describe "by size" do