class IndieWeb::Endpoints::Client
Constants
- HTTP_HEADERS_OPTS
Attributes
url[RW]
Public Class Methods
new(url)
click to toggle source
Create a new client with a URL to parse for IndieWeb
endpoints
client = IndieWeb::Endpoints::Client.new('https://aaronparecki.com')
@param url [String] an absolute URL
# File lib/indieweb/endpoints/client.rb, line 14 def initialize(url) @url = url.to_str end
Public Instance Methods
endpoints()
click to toggle source
@return [Hash{Symbol => String, Array, nil}]
# File lib/indieweb/endpoints/client.rb, line 24 def endpoints @endpoints ||= Parsers.registered.transform_values { |parser| parser.new(response).results } end
inspect()
click to toggle source
@return [String]
# File lib/indieweb/endpoints/client.rb, line 19 def inspect format(%(#<#{self.class.name}:%#0x url: #{url.inspect}>), object_id) end
response()
click to toggle source
@see www.w3.org/TR/webmention/#limits-on-get-requests
@return [HTTP::Response]
# File lib/indieweb/endpoints/client.rb, line 31 def response @response ||= HTTP.follow(max_hops: 20).headers(HTTP_HEADERS_OPTS).timeout(connect: 5, read: 5).get(uri) rescue HTTP::Error => exception raise HttpError, exception end
Private Instance Methods
uri()
click to toggle source
# File lib/indieweb/endpoints/client.rb, line 41 def uri @uri ||= Addressable::URI.parse(url) rescue Addressable::URI::InvalidURIError => exception raise InvalidURIError, exception end