indieweb-endpoints 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.reek.yml +0 -3
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/lib/indieweb/endpoints/client.rb +5 -10
- data/lib/indieweb/endpoints/exceptions.rb +7 -5
- data/lib/indieweb/endpoints/parsers.rb +2 -2
- data/lib/indieweb/endpoints/parsers/authorization_endpoint_parser.rb +4 -6
- data/lib/indieweb/endpoints/parsers/micropub_parser.rb +4 -6
- data/lib/indieweb/endpoints/parsers/redirect_uri_parser.rb +5 -5
- data/lib/indieweb/endpoints/parsers/token_endpoint_parser.rb +4 -6
- data/lib/indieweb/endpoints/parsers/webmention_parser.rb +6 -6
- data/lib/indieweb/endpoints/registerable.rb +2 -2
- data/lib/indieweb/endpoints/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2168f56d7a493faa4d1bd7a61e5ecc1cf52ca405baf43254ad3149fa6ad62460
|
4
|
+
data.tar.gz: 93c838259316804108f5a5b9c9950235f9283c08109aa1b1c2eb9f89c6d3eac2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a685fc02841e5433b183103679df93b9e6d2b0c530a0d6b3b8acf01adb41d17814a2778ac74ec876b3b70671ebbbfe76edcd414f1c6f8195838834d62d826b15
|
7
|
+
data.tar.gz: fbb870ada2afdb2b5b217fa224a6e43166e6faed8aa422d6e26c9cbd2375a2313ead2db29ec2e1d703423b856a6b80768d69100737c5a3709b8297a615b980f2
|
data/.reek.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.2.0 / 2019-04-25
|
4
|
+
|
5
|
+
- Subclass exceptions under `IndieWeb::Endpoints::Error` ([667eec7](https://github.com/indieweb/indieweb-endpoints-ruby/commit/667eec7)).
|
6
|
+
- Refactor parsers and `Registerable` module ([3b96858](https://github.com/indieweb/indieweb-endpoints-ruby/commit/3b96858)).
|
7
|
+
- Refactor Client#response method ([c36fda3](https://github.com/indieweb/indieweb-endpoints-ruby/commit/c36fda3)).
|
8
|
+
|
3
9
|
## 0.1.0 / 2019-04-24
|
4
10
|
|
5
11
|
- Initial release!
|
data/README.md
CHANGED
@@ -79,7 +79,7 @@ puts client.endpoints # => Hash
|
|
79
79
|
|
80
80
|
### Exception Handling
|
81
81
|
|
82
|
-
There are several exceptions that may be raised by indieweb-endpoints-ruby's underlying dependencies. These errors are raised as subclasses of `StandardError
|
82
|
+
There are several exceptions that may be raised by indieweb-endpoints-ruby's underlying dependencies. These errors are raised as subclasses of `IndieWeb::Endpoints::Error` (which itself is a subclass of `StandardError`).
|
83
83
|
|
84
84
|
From [jgarber623/absolutely](https://github.com/jgarber623/absolutely) and [sporkmonger/addressable](https://github.com/sporkmonger/addressable):
|
85
85
|
|
@@ -21,16 +21,11 @@ module IndieWeb
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def response
|
24
|
-
@response ||= HTTP.follow.headers(HTTP_HEADERS_OPTS).timeout(
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
raise ConnectionError, exception
|
30
|
-
rescue HTTP::TimeoutError => exception
|
31
|
-
raise TimeoutError, exception
|
32
|
-
rescue HTTP::Redirector::TooManyRedirectsError => exception
|
33
|
-
raise TooManyRedirectsError, exception
|
24
|
+
@response ||= HTTP.follow.headers(HTTP_HEADERS_OPTS).timeout(connect: 10, read: 10).get(@url)
|
25
|
+
rescue HTTP::ConnectionError,
|
26
|
+
HTTP::TimeoutError,
|
27
|
+
HTTP::Redirector::TooManyRedirectsError => exception
|
28
|
+
raise IndieWeb::Endpoints.const_get(exception.class.name.split('::').last), exception
|
34
29
|
end
|
35
30
|
end
|
36
31
|
end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
module IndieWeb
|
2
2
|
module Endpoints
|
3
|
-
class
|
3
|
+
class Error < StandardError; end
|
4
4
|
|
5
|
-
class
|
5
|
+
class ArgumentError < Error; end
|
6
6
|
|
7
|
-
class
|
7
|
+
class ConnectionError < Error; end
|
8
8
|
|
9
|
-
class
|
9
|
+
class InvalidURIError < Error; end
|
10
10
|
|
11
|
-
class
|
11
|
+
class TimeoutError < Error; end
|
12
|
+
|
13
|
+
class TooManyRedirectsError < Error; end
|
12
14
|
end
|
13
15
|
end
|
@@ -50,7 +50,7 @@ module IndieWeb
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def link_elements_css_selector
|
53
|
-
@link_elements_css_selector ||= %(link[rel~="#{identifier}"][href])
|
53
|
+
@link_elements_css_selector ||= %(link[rel~="#{self.class.identifier}"][href])
|
54
54
|
end
|
55
55
|
|
56
56
|
def link_header
|
@@ -65,7 +65,7 @@ module IndieWeb
|
|
65
65
|
def regexp_rel_paramater_pattern
|
66
66
|
# Ultra-orthodox pattern matching Link header `rel` parameter including a matching identifier value
|
67
67
|
# https://www.w3.org/TR/webmention/#sender-discovers-receiver-webmention-endpoint
|
68
|
-
@regexp_rel_paramater_pattern ||= /(?:;|\s)rel="?(?:#{REGEXP_REG_REL_TYPE_PATTERN}+\s)?#{identifier}(?:\s#{REGEXP_REG_REL_TYPE_PATTERN})?"?/
|
68
|
+
@regexp_rel_paramater_pattern ||= /(?:;|\s)rel="?(?:#{REGEXP_REG_REL_TYPE_PATTERN}+\s)?#{self.class.identifier}(?:\s#{REGEXP_REG_REL_TYPE_PATTERN})?"?/
|
69
69
|
end
|
70
70
|
|
71
71
|
def results_from_body
|
@@ -2,13 +2,11 @@ module IndieWeb
|
|
2
2
|
module Endpoints
|
3
3
|
module Parsers
|
4
4
|
class AuthorizationEndpointParser < BaseParser
|
5
|
-
|
6
|
-
|
7
|
-
private
|
8
|
-
|
9
|
-
def identifier
|
10
|
-
@identifier ||= :authorization_endpoint
|
5
|
+
def self.identifier
|
6
|
+
:authorization_endpoint
|
11
7
|
end
|
8
|
+
|
9
|
+
Parsers.register(self)
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
@@ -2,13 +2,11 @@ module IndieWeb
|
|
2
2
|
module Endpoints
|
3
3
|
module Parsers
|
4
4
|
class MicropubParser < BaseParser
|
5
|
-
|
6
|
-
|
7
|
-
private
|
8
|
-
|
9
|
-
def identifier
|
10
|
-
@identifier ||= :micropub
|
5
|
+
def self.identifier
|
6
|
+
:micropub
|
11
7
|
end
|
8
|
+
|
9
|
+
Parsers.register(self)
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
@@ -2,7 +2,11 @@ module IndieWeb
|
|
2
2
|
module Endpoints
|
3
3
|
module Parsers
|
4
4
|
class RedirectUriParser < BaseParser
|
5
|
-
|
5
|
+
def self.identifier
|
6
|
+
:redirect_uri
|
7
|
+
end
|
8
|
+
|
9
|
+
Parsers.register(self)
|
6
10
|
|
7
11
|
def results
|
8
12
|
return unless results_from_http_request.any?
|
@@ -14,10 +18,6 @@ module IndieWeb
|
|
14
18
|
|
15
19
|
private
|
16
20
|
|
17
|
-
def identifier
|
18
|
-
@identifier ||= :redirect_uri
|
19
|
-
end
|
20
|
-
|
21
21
|
def results_from_body
|
22
22
|
link_elements.map { |element| element['href'] } if response_is_html && link_elements.any?
|
23
23
|
end
|
@@ -2,13 +2,11 @@ module IndieWeb
|
|
2
2
|
module Endpoints
|
3
3
|
module Parsers
|
4
4
|
class TokenEndpointParser < BaseParser
|
5
|
-
|
6
|
-
|
7
|
-
private
|
8
|
-
|
9
|
-
def identifier
|
10
|
-
@identifier ||= :token_endpoint
|
5
|
+
def self.identifier
|
6
|
+
:token_endpoint
|
11
7
|
end
|
8
|
+
|
9
|
+
Parsers.register(self)
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
@@ -2,13 +2,13 @@ module IndieWeb
|
|
2
2
|
module Endpoints
|
3
3
|
module Parsers
|
4
4
|
class WebmentionParser < BaseParser
|
5
|
-
|
5
|
+
def self.identifier
|
6
|
+
:webmention
|
7
|
+
end
|
6
8
|
|
7
|
-
|
9
|
+
Parsers.register(self)
|
8
10
|
|
9
|
-
|
10
|
-
@identifier ||= :webmention
|
11
|
-
end
|
11
|
+
private
|
12
12
|
|
13
13
|
def link_element
|
14
14
|
# Return first `a` or `link` element with valid `rel` attribute
|
@@ -17,7 +17,7 @@ module IndieWeb
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def link_elements_css_selector
|
20
|
-
@link_elements_css_selector ||= %([rel~="#{identifier}"][href])
|
20
|
+
@link_elements_css_selector ||= %([rel~="#{self.class.identifier}"][href])
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|