Class: BrandLogo::Strategies::ManifestStrategy
- Inherits:
-
BaseStrategy
- Object
- BaseStrategy
- BrandLogo::Strategies::ManifestStrategy
- Extended by:
- T::Sig
- Defined in:
- lib/brand_logo/strategies/manifest_strategy.rb
Overview
Fetches icons from the Web App Manifest (PWA manifest). Modern progressive web apps store high-resolution icons (192x192, 512x512) in a manifest.json or .webmanifest file linked from the HTML.
Flow:
1. Fetch HTML → find <link rel="manifest" href="...">
2. Fetch manifest JSON
3. Parse icons[] array → build Icons
Constant Summary collapse
- MIME_TO_FORMAT =
T.let({ 'image/png' => 'png', 'image/svg+xml' => 'svg', 'image/jpeg' => 'jpg', 'image/webp' => 'webp', 'image/gif' => 'gif' }.freeze, T::Hash[String, String])
Constants inherited from BaseStrategy
BaseStrategy::UNKNOWN_DIMENSION_SCORE
Instance Method Summary collapse
- #fetch_all(domain) ⇒ Object
-
#initialize(config:, http_client:, html_parser:, image_analyzer:) ⇒ ManifestStrategy
constructor
A new instance of ManifestStrategy.
Methods inherited from BaseStrategy
Constructor Details
#initialize(config:, http_client:, html_parser:, image_analyzer:) ⇒ ManifestStrategy
Returns a new instance of ManifestStrategy.
36 37 38 39 40 41 |
# File 'lib/brand_logo/strategies/manifest_strategy.rb', line 36 def initialize(config:, http_client:, html_parser:, image_analyzer:) super(config: config) @http_client = T.let(http_client, HttpClient) @html_parser = T.let(html_parser, HtmlParser) @image_analyzer = T.let(image_analyzer, ImageAnalyzer) end |
Instance Method Details
#fetch_all(domain) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/brand_logo/strategies/manifest_strategy.rb', line 44 def fetch_all(domain) manifest_url = find_manifest_url(domain) return [] unless manifest_url parse_manifest_icons(manifest_url) rescue StandardError => e BrandLogo::Logging.logger.error("ManifestStrategy error for #{domain}: #{e.}") [] end |