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
-
#response ⇒ HTTP::Response
The
HTTP::Response
object returned by the provided URL.
Constructor Details
#initialize(url) ⇒ Client
Create a new client with a URL to parse for IndieWeb endpoints.
20 21 22 23 24 |
# File 'lib/indieweb/endpoints/client.rb', line 20 def initialize(url) @uri = HTTP::URI.parse(url.to_s) 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.
34 35 36 |
# File 'lib/indieweb/endpoints/client.rb', line 34 def endpoints @endpoints ||= Parser.new(response).results end |
#inspect ⇒ String
27 28 29 |
# File 'lib/indieweb/endpoints/client.rb', line 27 def inspect %(#<#{self.class.name}:#{format("%#0x", object_id)} uri: "#{uri}">) end |
#response ⇒ HTTP::Response
The HTTP::Response
object returned by the provided URL.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/indieweb/endpoints/client.rb', line 42 def response @response ||= HTTP .follow(max_hops: 20) .headers(HTTP_HEADERS_OPTS) .timeout(connect: 5, read: 5) .get(uri) rescue HTTP::Error => e raise HttpError, e rescue OpenSSL::SSL::SSLError => e raise SSLError, e end |