Class: IndieWeb::Endpoints::Client
- Inherits:
-
Object
- Object
- IndieWeb::Endpoints::Client
- Defined in:
- lib/indieweb/endpoints/client.rb
Instance Method Summary collapse
-
#endpoints ⇒ Hash{Symbol => String, Array, nil}
A Hash of the discovered IndieWeb endpoints from the provided URL.
-
#initialize(url) ⇒ Client
constructor
Create a new client with a URL to parse for IndieWeb endpoints.
-
#inspect ⇒ String
:nocov:.
-
#response ⇒ HTTP::Response
The
HTTP::Responseobject.
Constructor Details
#initialize(url) ⇒ Client
Create a new client with a URL to parse for IndieWeb endpoints.
14 15 16 17 18 |
# File 'lib/indieweb/endpoints/client.rb', line 14 def initialize(url) @uri = HTTP::URI.parse(url) rescue Addressable::URI::InvalidURIError => e raise InvalidURIError, e end |
Instance Method Details
#endpoints ⇒ Hash{Symbol => String, Array, nil}
A Hash of the discovered IndieWeb endpoints from the provided URL.
33 34 35 |
# File 'lib/indieweb/endpoints/client.rb', line 33 def endpoints @endpoints ||= Parser.new(response).to_h end |
#inspect ⇒ String
:nocov:
22 23 24 25 26 27 |
# File 'lib/indieweb/endpoints/client.rb', line 22 def inspect format "#<%<class>s:%<id>#0x @uri=%<uri>s>", class: self.class, id: object_id << 1, uri: uri.inspect end |
#response ⇒ HTTP::Response
The HTTP::Response object.
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/indieweb/endpoints/client.rb', line 42 def response @response ||= HTTP .follow(max_hops: 20) .headers(accept: "*/*", user_agent: user_agent) .timeout(connect: 5, read: 5) .get(uri) rescue HTTP::Error => e raise HttpError, e rescue OpenSSL::SSL::SSLError => e raise SSLError, e end |