Compare commits
12 Commits
f88892a326
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
ac5a17dbb8
|
|||
|
784543f32d
|
|||
| a070bb6a49 | |||
|
682f66f476
|
|||
| e1d514d905 | |||
|
339508bf41
|
|||
|
45a43ce73d
|
|||
|
f31800a2d4
|
|||
|
f46d5b938d
|
|||
|
1bdc3be17f
|
|||
|
aa1bd15427
|
|||
|
07e3b6ed54
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@
|
|||||||
/spec/reports/
|
/spec/reports/
|
||||||
/tmp/
|
/tmp/
|
||||||
.rspec_status
|
.rspec_status
|
||||||
|
*.gem
|
||||||
|
|||||||
65
Gemfile.lock
65
Gemfile.lock
@@ -1,40 +1,47 @@
|
|||||||
PATH
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
manifique (0.1.0)
|
manifique (1.1.0)
|
||||||
faraday (~> 2.7.11)
|
faraday (~> 2.9.0)
|
||||||
faraday-follow_redirects (= 0.3.0)
|
faraday-follow_redirects (= 0.3.0)
|
||||||
nokogiri (~> 1.15.4)
|
nokogiri (~> 1.16.0)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
addressable (2.8.5)
|
addressable (2.8.6)
|
||||||
public_suffix (>= 2.0.2, < 6.0)
|
public_suffix (>= 2.0.2, < 6.0)
|
||||||
base64 (0.1.1)
|
bigdecimal (3.1.6)
|
||||||
coderay (1.1.3)
|
coderay (1.1.3)
|
||||||
crack (0.4.5)
|
crack (0.4.6)
|
||||||
|
bigdecimal
|
||||||
rexml
|
rexml
|
||||||
diff-lcs (1.5.0)
|
diff-lcs (1.5.1)
|
||||||
faraday (2.7.11)
|
faraday (2.9.0)
|
||||||
base64
|
faraday-net_http (>= 2.0, < 3.2)
|
||||||
faraday-net_http (>= 2.0, < 3.1)
|
|
||||||
ruby2_keywords (>= 0.0.4)
|
|
||||||
faraday-follow_redirects (0.3.0)
|
faraday-follow_redirects (0.3.0)
|
||||||
faraday (>= 1, < 3)
|
faraday (>= 1, < 3)
|
||||||
faraday-net_http (3.0.2)
|
faraday-net_http (3.0.2)
|
||||||
hashdiff (1.0.1)
|
hashdiff (1.1.0)
|
||||||
method_source (1.0.0)
|
method_source (1.0.0)
|
||||||
mini_portile2 (2.8.4)
|
nokogiri (1.16.0-aarch64-linux)
|
||||||
nokogiri (1.15.4)
|
racc (~> 1.4)
|
||||||
mini_portile2 (~> 2.8.2)
|
nokogiri (1.16.0-arm-linux)
|
||||||
|
racc (~> 1.4)
|
||||||
|
nokogiri (1.16.0-arm64-darwin)
|
||||||
|
racc (~> 1.4)
|
||||||
|
nokogiri (1.16.0-x86-linux)
|
||||||
|
racc (~> 1.4)
|
||||||
|
nokogiri (1.16.0-x86_64-darwin)
|
||||||
|
racc (~> 1.4)
|
||||||
|
nokogiri (1.16.0-x86_64-linux)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
pry (0.14.2)
|
pry (0.14.2)
|
||||||
coderay (~> 1.1)
|
coderay (~> 1.1)
|
||||||
method_source (~> 1.0)
|
method_source (~> 1.0)
|
||||||
public_suffix (5.0.3)
|
public_suffix (5.0.4)
|
||||||
racc (1.7.1)
|
racc (1.7.3)
|
||||||
rake (13.0.6)
|
rake (13.1.0)
|
||||||
rexml (3.2.6)
|
rexml (3.2.6)
|
||||||
rspec (3.12.0)
|
rspec (3.12.0)
|
||||||
rspec-core (~> 3.12.0)
|
rspec-core (~> 3.12.0)
|
||||||
@@ -49,22 +56,26 @@ GEM
|
|||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.12.0)
|
rspec-support (~> 3.12.0)
|
||||||
rspec-support (3.12.1)
|
rspec-support (3.12.1)
|
||||||
ruby2_keywords (0.0.5)
|
webmock (3.19.1)
|
||||||
webmock (3.4.2)
|
addressable (>= 2.8.0)
|
||||||
addressable (>= 2.3.6)
|
|
||||||
crack (>= 0.3.2)
|
crack (>= 0.3.2)
|
||||||
hashdiff
|
hashdiff (>= 0.4.0, < 2.0.0)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
aarch64-linux
|
||||||
|
arm-linux
|
||||||
|
arm64-darwin
|
||||||
|
x86-linux
|
||||||
|
x86_64-darwin
|
||||||
|
x86_64-linux
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
bundler (~> 2.3.7)
|
bundler (~> 2.5.5)
|
||||||
manifique!
|
manifique!
|
||||||
pry (~> 0.14.2)
|
pry (~> 0.14.2)
|
||||||
rake (~> 13.0)
|
rake (~> 13.1.0)
|
||||||
rspec (~> 3.12)
|
rspec (~> 3.12)
|
||||||
webmock (~> 3.4.2)
|
webmock (~> 3.19.1)
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.3.7
|
2.5.5
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
[](https://rubygems.org/gems/manifique)
|
||||||
[](https://drone.kosmos.org/5apps/manifique)
|
[](https://drone.kosmos.org/5apps/manifique)
|
||||||
|
|
||||||
# Manifique
|
# Manifique
|
||||||
|
|||||||
@@ -43,11 +43,17 @@ module Manifique
|
|||||||
end
|
end
|
||||||
|
|
||||||
if options[:type]
|
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
|
end
|
||||||
|
|
||||||
if options[:sizes]
|
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"]) }
|
results.sort! { |a, b| sizes_to_i(b["sizes"]) <=> sizes_to_i(a["sizes"]) }
|
||||||
|
|
||||||
if icon = select_exact_size(results, options[:sizes])
|
if icon = select_exact_size(results, options[:sizes])
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
module Manifique
|
module Manifique
|
||||||
VERSION = "0.1.0"
|
VERSION = "1.1.0"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|||||||
spec.authors = ["Râu Cao"]
|
spec.authors = ["Râu Cao"]
|
||||||
spec.email = ["raucao@kosmos.org"]
|
spec.email = ["raucao@kosmos.org"]
|
||||||
spec.summary = "Fetch metadata and icons of Web applications"
|
spec.summary = "Fetch metadata and icons of Web applications"
|
||||||
spec.description = "Fetch and process metadata and icons of Web applications from Web App Manifest files, with fallbacks to HTML elements/attributes}"
|
spec.description = "Fetch and process metadata and icons of Web applications from Web App Manifest files, with fallbacks to HTML elements/attributes"
|
||||||
spec.homepage = "https://gitea.kosmos.org/5apps/manifique"
|
spec.homepage = "https://gitea.kosmos.org/5apps/manifique"
|
||||||
spec.metadata = {
|
spec.metadata = {
|
||||||
"bug_tracker_uri" => "https://gitea.kosmos.org/5apps/manifique/issues",
|
"bug_tracker_uri" => "https://gitea.kosmos.org/5apps/manifique/issues",
|
||||||
@@ -24,14 +24,15 @@ Gem::Specification.new do |spec|
|
|||||||
spec.bindir = "exe"
|
spec.bindir = "exe"
|
||||||
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
||||||
spec.require_paths = ["lib"]
|
spec.require_paths = ["lib"]
|
||||||
|
spec.required_ruby_version = '>= 3.1.4'
|
||||||
|
|
||||||
spec.add_development_dependency "bundler", "~> 2.3.7"
|
spec.add_development_dependency "bundler", "~> 2.5.5"
|
||||||
spec.add_development_dependency "rake", "~> 13.0"
|
spec.add_development_dependency "rake", "~> 13.1.0"
|
||||||
spec.add_development_dependency "rspec", "~> 3.12"
|
spec.add_development_dependency "rspec", "~> 3.12"
|
||||||
spec.add_development_dependency "webmock", "~> 3.4.2"
|
spec.add_development_dependency "webmock", "~> 3.19.1"
|
||||||
spec.add_development_dependency "pry", "~> 0.14.2"
|
spec.add_development_dependency "pry", "~> 0.14.2"
|
||||||
|
|
||||||
spec.add_runtime_dependency "faraday", "~> 2.7.11"
|
spec.add_runtime_dependency "faraday", "~> 2.9.0"
|
||||||
spec.add_runtime_dependency "faraday-follow_redirects", "0.3.0"
|
spec.add_runtime_dependency "faraday-follow_redirects", "0.3.0"
|
||||||
spec.add_runtime_dependency "nokogiri", "~> 1.15.4"
|
spec.add_runtime_dependency "nokogiri", "~> 1.16.0"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -68,6 +68,16 @@ RSpec.describe Manifique::Metadata do
|
|||||||
icon = metadata.select_icon(type: "image/png")
|
icon = metadata.select_icon(type: "image/png")
|
||||||
expect(icon["sizes"]).to eq("512x512")
|
expect(icon["sizes"]).to eq("512x512")
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe "by size" do
|
describe "by size" do
|
||||||
@@ -105,6 +115,7 @@ def icon_fixtures
|
|||||||
{"src"=>"/application_icon_x228.png", "sizes"=>"228x228", "type"=>"image/png"},
|
{"src"=>"/application_icon_x228.png", "sizes"=>"228x228", "type"=>"image/png"},
|
||||||
{"src"=>"/application_icon_x196.png", "sizes"=>"196x196", "type"=>"image/png"},
|
{"src"=>"/application_icon_x196.png", "sizes"=>"196x196", "type"=>"image/png"},
|
||||||
{"src"=>"/application_icon_x192.png", "sizes"=>"192x192", "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.png", "sizes"=>"180x180", "type"=>"image/png" },
|
||||||
{"purpose"=>"apple-touch-icon", "src"=>"/apple-touch-icon-57px.png", "sizes"=>"57x57", "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"}
|
{"purpose"=>"mask-icon", "src"=>"/mask-icon.svg", "type"=>"image/svg", "color"=>"#2b90d9"}
|
||||||
|
|||||||
Reference in New Issue
Block a user