Class: IndieWeb::Endpoints::Parsers::BaseParser

Inherits:
Object
  • Object
show all
Defined in:
lib/indieweb/endpoints/parsers.rb

Constant Summary collapse

REGEXP_REG_REL_TYPE_PATTERN =

Ultra-orthodox pattern matching allowed values in Link header ‘rel` parameter tools.ietf.org/html/rfc8288#section-3.3

'[a-z\d][a-z\d\-\.]*'.freeze
REGEXP_TARGET_URI_PATTERN =

Liberal pattern matching a string of text between angle brackets tools.ietf.org/html/rfc5988#section-5.1

/^<(.*)>;/.freeze

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ BaseParser

Returns a new instance of BaseParser.

Raises:



15
16
17
18
19
# File 'lib/indieweb/endpoints/parsers.rb', line 15

def initialize(response)
  raise ArgumentError, "response must be an HTTP::Response (given #{response.class.name})" unless response.is_a?(HTTP::Response)

  @response = response
end

Instance Method Details

#resultsObject



21
22
23
24
25
26
27
# File 'lib/indieweb/endpoints/parsers.rb', line 21

def results
  return unless results_from_http_request

  @results ||= Absolutely.to_absolute_uri(base: @response.uri.to_s, relative: results_from_http_request)
rescue Absolutely::InvalidURIError => exception
  raise InvalidURIError, exception
end