Class: Portage::Ucp::Check
- Inherits:
-
Object
- Object
- Portage::Ucp::Check
- Defined in:
- lib/portage/ucp/check.rb
Overview
portage-ucp-check <url> — point it at any storefront and find out what
portage-ucp can do with it. Checks for a native /.well-known/ucp
manifest first (the store may already speak UCP without this gem, see
README's "Why /.well-known/ucp?"), then a <link rel="ucp" href=...>
manifest pointer in the homepage (the same fallback portage buy
follows); if there isn't one, detects the
commerce platform from the page itself (see Resolver) and names
the matching portage-ucp-
Constant Summary collapse
- MANIFEST_PATH =
"/.well-known/ucp".freeze
- REDIRECT_LIMIT =
5
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(url) ⇒ Check
constructor
A new instance of Check.
Constructor Details
#initialize(url) ⇒ Check
Returns a new instance of Check.
24 25 26 27 28 |
# File 'lib/portage/ucp/check.rb', line 24 def initialize(url) raw = url.to_s.strip raw = "https://#{raw}" unless raw =~ %r{\Ahttps?://}i @uri = URI.parse(raw) end |
Class Method Details
.call(url) ⇒ Object
22 |
# File 'lib/portage/ucp/check.rb', line 22 def self.call(url) = new(url).call |
Instance Method Details
#call ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/portage/ucp/check.rb', line 30 def call manifest = fetch_manifest return { url: @uri.to_s, native_ucp: manifest } if manifest body, headers = fetch_homepage linked = manifest_link(body) manifest = linked && fetch_json(linked) return { url: @uri.to_s, native_ucp: manifest, manifest_url: linked.to_s } if manifest platform = Resolver.detect_platform(body, headers) report = { url: @uri.to_s, native_ucp: nil, platform: platform&.name, recommended_gem: platform&.gem } report[:live_probe] = probe(platform) if platform report end |