Class: IndieWeb::Endpoints::Parser Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Parser

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Parser.



8
9
10
# File 'lib/indieweb/endpoints/parser.rb', line 8

def initialize(response)
  @response = response
end

Instance Method Details

#match(identifier, **kwargs) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
# File 'lib/indieweb/endpoints/parser.rb', line 30

def match(identifier, **kwargs)
  matches(identifier, **kwargs).first
end

#matches(identifier, node_names: ["link"]) ⇒ Array<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:



18
19
20
21
22
23
24
25
# File 'lib/indieweb/endpoints/parser.rb', line 18

def matches(identifier, node_names: ["link"])
  results = (matches_from_headers(identifier) + matches_from_body(identifier, node_names)).compact

  results.uniq!
  results.sort!

  results
end

#to_hHash{Symbol => String, Array, nil}

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/indieweb/endpoints/parser.rb', line 35

def to_h
  {
    authorization_endpoint: match("authorization_endpoint"),
    "indieauth-metadata": match("indieauth-metadata"),
    micropub: match("micropub"),
    microsub: match("microsub"),
    redirect_uri: (redirect_uri = matches("redirect_uri")).any? ? redirect_uri : nil,
    token_endpoint: match("token_endpoint"),
    webmention: match("webmention", node_names: ["link", "a"]),
  }
end