Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
ac5a17dbb8 | |||
784543f32d | |||
a070bb6a49 | |||
682f66f476 | |||
e1d514d905 | |||
339508bf41 | |||
45a43ce73d | |||
f31800a2d4 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@
|
||||
/spec/reports/
|
||||
/tmp/
|
||||
.rspec_status
|
||||
*.gem
|
||||
|
@ -1,7 +1,7 @@
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
manifique (1.0.0)
|
||||
manifique (1.1.0)
|
||||
faraday (~> 2.9.0)
|
||||
faraday-follow_redirects (= 0.3.0)
|
||||
nokogiri (~> 1.16.0)
|
||||
|
@ -1,3 +1,4 @@
|
||||
[](https://rubygems.org/gems/manifique)
|
||||
[](https://drone.kosmos.org/5apps/manifique)
|
||||
|
||||
# Manifique
|
||||
|
@ -43,11 +43,17 @@ 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]
|
||||
results.reject! { |r| r["sizes"].nil? }
|
||||
results.reject! { |r| r["sizes"].nil? || r["sizes"].match(/(\d+)x/).nil? }
|
||||
results.sort! { |a, b| sizes_to_i(b["sizes"]) <=> sizes_to_i(a["sizes"]) }
|
||||
|
||||
if icon = select_exact_size(results, options[:sizes])
|
||||
|
@ -1,3 +1,3 @@
|
||||
module Manifique
|
||||
VERSION = "1.0.1"
|
||||
VERSION = "1.1.0"
|
||||
end
|
||||
|
@ -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
|
||||
@ -105,6 +115,7 @@ def icon_fixtures
|
||||
{"src"=>"/application_icon_x228.png", "sizes"=>"228x228", "type"=>"image/png"},
|
||||
{"src"=>"/application_icon_x196.png", "sizes"=>"196x196", "type"=>"image/png"},
|
||||
{"src"=>"/application_icon_x192.png", "sizes"=>"192x192", "type"=>"image/png"},
|
||||
{"src"=>"/icon-maskable.svg", "type"=>"image/svg+xml", "sizes"=>"any", "purpose"=>"maskable"},
|
||||
{"purpose"=>"apple-touch-icon", "src"=>"/apple-touch-icon.png", "sizes"=>"180x180", "type"=>"image/png" },
|
||||
{"purpose"=>"apple-touch-icon", "src"=>"/apple-touch-icon-57px.png", "sizes"=>"57x57", "type"=>"image/png"},
|
||||
{"purpose"=>"mask-icon", "src"=>"/mask-icon.svg", "type"=>"image/svg", "color"=>"#2b90d9"}
|
||||
|
Loading…
x
Reference in New Issue
Block a user