Compare commits

11 Commits

Author SHA1 Message Date
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
e1d514d905 Merge pull request 'Don't break on icon size "any"' (#5) from bugfix/size_any into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #5
2024-08-14 13:52:04 +00:00
339508bf41 Don't break on icon size "any"
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
... and any other strings failing to match the "sizes" number format
for that matter
2024-08-14 15:46:58 +02:00
45a43ce73d Update lockfile
All checks were successful
continuous-integration/drone/push Build is passing
2024-08-14 15:46:35 +02:00
f31800a2d4 Ignore build files
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-02 17:50:54 +02:00
f46d5b938d Release v1.0.1
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2024-02-02 17:49:44 +02:00
1bdc3be17f Improve gemspec
Add required Ruby version, fix typo
2024-02-02 17:49:09 +02:00
aa1bd15427 Update version
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2024-02-02 13:43:56 +02:00
07e3b6ed54 Update dependencies, require Ruby 3.x
All checks were successful
continuous-integration/drone/push Build is passing
2024-02-02 13:07:02 +02:00
6 changed files with 66 additions and 36 deletions

1
.gitignore vendored
View File

@@ -7,3 +7,4 @@
/spec/reports/
/tmp/
.rspec_status
*.gem

View File

@@ -1,40 +1,47 @@
PATH
remote: .
specs:
manifique (0.1.0)
faraday (~> 2.7.11)
manifique (1.1.0)
faraday (~> 2.9.0)
faraday-follow_redirects (= 0.3.0)
nokogiri (~> 1.15.4)
nokogiri (~> 1.16.0)
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.5)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
base64 (0.1.1)
bigdecimal (3.1.6)
coderay (1.1.3)
crack (0.4.5)
crack (0.4.6)
bigdecimal
rexml
diff-lcs (1.5.0)
faraday (2.7.11)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
diff-lcs (1.5.1)
faraday (2.9.0)
faraday-net_http (>= 2.0, < 3.2)
faraday-follow_redirects (0.3.0)
faraday (>= 1, < 3)
faraday-net_http (3.0.2)
hashdiff (1.0.1)
hashdiff (1.1.0)
method_source (1.0.0)
mini_portile2 (2.8.4)
nokogiri (1.15.4)
mini_portile2 (~> 2.8.2)
nokogiri (1.16.0-aarch64-linux)
racc (~> 1.4)
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)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.0.3)
racc (1.7.1)
rake (13.0.6)
public_suffix (5.0.4)
racc (1.7.3)
rake (13.1.0)
rexml (3.2.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
@@ -49,22 +56,26 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
ruby2_keywords (0.0.5)
webmock (3.4.2)
addressable (>= 2.3.6)
webmock (3.19.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff
hashdiff (>= 0.4.0, < 2.0.0)
PLATFORMS
ruby
aarch64-linux
arm-linux
arm64-darwin
x86-linux
x86_64-darwin
x86_64-linux
DEPENDENCIES
bundler (~> 2.3.7)
bundler (~> 2.5.5)
manifique!
pry (~> 0.14.2)
rake (~> 13.0)
rake (~> 13.1.0)
rspec (~> 3.12)
webmock (~> 3.4.2)
webmock (~> 3.19.1)
BUNDLED WITH
2.3.7
2.5.5

View File

@@ -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])

View File

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

View File

@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
spec.authors = ["Râu Cao"]
spec.email = ["raucao@kosmos.org"]
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.metadata = {
"bug_tracker_uri" => "https://gitea.kosmos.org/5apps/manifique/issues",
@@ -24,14 +24,15 @@ Gem::Specification.new do |spec|
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.required_ruby_version = '>= 3.1.4'
spec.add_development_dependency "bundler", "~> 2.3.7"
spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "bundler", "~> 2.5.5"
spec.add_development_dependency "rake", "~> 13.1.0"
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_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 "nokogiri", "~> 1.15.4"
spec.add_runtime_dependency "nokogiri", "~> 1.16.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
@@ -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"}