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?"); 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.
21 22 23 24 25 |
# File 'lib/portage/ucp/check.rb', line 21 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
19 |
# File 'lib/portage/ucp/check.rb', line 19 def self.call(url) = new(url).call |
Instance Method Details
#call ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/portage/ucp/check.rb', line 27 def call manifest = fetch_manifest return { url: @uri.to_s, native_ucp: manifest } if manifest body, headers = fetch_homepage 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 |