indieweb-endpoints 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +7 -1
- data/CONTRIBUTING.md +1 -1
- data/README.md +4 -4
- data/indieweb-endpoints.gemspec +9 -2
- data/lib/indieweb/endpoints.rb +9 -2
- data/lib/indieweb/endpoints/client.rb +3 -12
- data/lib/indieweb/endpoints/exceptions.rb +6 -6
- data/lib/indieweb/endpoints/http_request.rb +18 -0
- data/lib/indieweb/endpoints/parsers.rb +1 -1
- data/lib/indieweb/endpoints/parsers/redirect_uri_parser.rb +1 -1
- data/lib/indieweb/endpoints/version.rb +1 -1
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1788ffc5ea1dd7ec1a6d4c1839e19c4b208b38044a05aef7d618bad2485b7638
|
4
|
+
data.tar.gz: 4458a1d611d045035916ec9fc6f69c752f628a6c65776fbfdc0fdfc4bb823c83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd530923575c34d392253a090fb9458c0709f6049ba055e9665879c067cc9571814b6079806773b3080c1b63def074b9331d8e9415855c91987acc56679090bb
|
7
|
+
data.tar.gz: 4f2836abdae4e424d2981b654d1d9a8b07cf84a970ee47571dca2235f85905c788136cc63ecde32d3ffbcc632e6f77e96d90aa6f3fc2c4f4bcb1d556d07ad587
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.4.0 / 2019-05-01
|
4
|
+
|
5
|
+
- Add `IndieWeb::Endpoints.client` method ([c4d42d0](https://github.com/indieweb/indieweb-endpoints-ruby/commit/c4d42d0)).
|
6
|
+
- Rename base `Error` class to `IndieWebEndpointsError` ([d6d6f98](https://github.com/indieweb/indieweb-endpoints-ruby/commit/d6d6f98)).
|
7
|
+
- Add `HttpRequest` class ([7864cbd](https://github.com/indieweb/indieweb-endpoints-ruby/commit/7864cbd)).
|
8
|
+
|
3
9
|
## 0.3.0 / 2019-04-30
|
4
10
|
|
5
|
-
- `IndieWeb::Endpoints::Client#endpoints` returns an `OpenStruct` instead of a `Hash` ([c209b0b](https://github.com/indieweb/indieweb-endpoints-ruby/commit/c209b0b))
|
11
|
+
- `IndieWeb::Endpoints::Client#endpoints` returns an `OpenStruct` instead of a `Hash` ([c209b0b](https://github.com/indieweb/indieweb-endpoints-ruby/commit/c209b0b)).
|
6
12
|
|
7
13
|
## 0.2.0 / 2019-04-25
|
8
14
|
|
data/CONTRIBUTING.md
CHANGED
@@ -8,7 +8,7 @@ There are a couple ways you can help improve indieweb-endpoints-ruby:
|
|
8
8
|
|
9
9
|
## Getting Started
|
10
10
|
|
11
|
-
indieweb-endpoints-ruby is developed using Ruby 2.4.6 and is additionally tested against Ruby 2.5.5 and 2.6.
|
11
|
+
indieweb-endpoints-ruby is developed using Ruby 2.4.6 and is additionally tested against Ruby 2.5.5 and 2.6.3 using [Travis CI](https://travis-ci.com/indieweb/indieweb-endpoints-ruby).
|
12
12
|
|
13
13
|
Before making changes to indieweb-endpoints-ruby, you'll want to install Ruby 2.4.6. It's recommended that you use a Ruby version managment tool like [rbenv](https://github.com/rbenv/rbenv), [chruby](https://github.com/postmodern/chruby), or [rvm](https://github.com/rvm/rvm). Once you've installed Ruby 2.4.6 using your method of choice, install the project's gems by running:
|
14
14
|
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
Before installing and using indieweb-endpoints-ruby, you'll want to have [Ruby](https://www.ruby-lang.org) 2.4 (or newer) installed. It's recommended that you use a Ruby version managment tool like [rbenv](https://github.com/rbenv/rbenv), [chruby](https://github.com/postmodern/chruby), or [rvm](https://github.com/rvm/rvm).
|
20
20
|
|
21
|
-
indieweb-endpoints-ruby is developed using Ruby 2.4.6 and is additionally tested against Ruby 2.5.5 and 2.6.
|
21
|
+
indieweb-endpoints-ruby is developed using Ruby 2.4.6 and is additionally tested against Ruby 2.5.5 and 2.6.3 using [Travis CI](https://travis-ci.com/indieweb/indieweb-endpoints-ruby).
|
22
22
|
|
23
23
|
## Installation
|
24
24
|
|
@@ -66,12 +66,12 @@ Each attribute will return either a `String` representing a URL or `nil`. The `r
|
|
66
66
|
|
67
67
|
### Advanced Usage
|
68
68
|
|
69
|
-
Should the need arise, you may work
|
69
|
+
Should the need arise, you may work with the `IndieWeb::Endpoints::Client` class:
|
70
70
|
|
71
71
|
```ruby
|
72
72
|
require 'indieweb/endpoints'
|
73
73
|
|
74
|
-
client = IndieWeb::Endpoints
|
74
|
+
client = IndieWeb::Endpoints.client('https://aaronparecki.com')
|
75
75
|
|
76
76
|
puts client.response # => #<HTTP::Response …>
|
77
77
|
puts client.endpoints # => #<OpenStruct …>
|
@@ -80,7 +80,7 @@ puts client.endpoints.webmention # => 'https://webmention.io/aaronpk/webmention'
|
|
80
80
|
|
81
81
|
### Exception Handling
|
82
82
|
|
83
|
-
There are several exceptions that may be raised by indieweb-endpoints-ruby's underlying dependencies. These errors are raised as subclasses of `
|
83
|
+
There are several exceptions that may be raised by indieweb-endpoints-ruby's underlying dependencies. These errors are raised as subclasses of `IndieWebEndpointsError` (which itself is a subclass of `StandardError`).
|
84
84
|
|
85
85
|
From [jgarber623/absolutely](https://github.com/jgarber623/absolutely) and [sporkmonger/addressable](https://github.com/sporkmonger/addressable):
|
86
86
|
|
data/indieweb-endpoints.gemspec
CHANGED
@@ -3,6 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
require 'indieweb/endpoints/version'
|
5
5
|
|
6
|
+
# rubocop:disable Metrics/BlockLength
|
6
7
|
Gem::Specification.new do |spec|
|
7
8
|
spec.required_ruby_version = ['>= 2.4', '< 2.7']
|
8
9
|
|
@@ -20,18 +21,24 @@ Gem::Specification.new do |spec|
|
|
20
21
|
|
21
22
|
spec.require_paths = ['lib']
|
22
23
|
|
24
|
+
spec.metadata = {
|
25
|
+
'bug_tracker_uri' => "#{spec.homepage}/issues",
|
26
|
+
'changelog_uri' => "#{spec.homepage}/blob/v#{spec.version}/CHANGELOG.md"
|
27
|
+
}
|
28
|
+
|
23
29
|
spec.add_development_dependency 'rake', '~> 12.3'
|
24
30
|
spec.add_development_dependency 'reek', '~> 5.4'
|
25
31
|
spec.add_development_dependency 'rspec', '~> 3.8'
|
26
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
32
|
+
spec.add_development_dependency 'rubocop', '~> 0.68.1'
|
27
33
|
spec.add_development_dependency 'rubocop-performance', '~> 1.1'
|
28
34
|
spec.add_development_dependency 'rubocop-rspec', '~> 1.32'
|
29
35
|
spec.add_development_dependency 'simplecov', '~> 0.16.1'
|
30
36
|
spec.add_development_dependency 'simplecov-console', '~> 0.4.2'
|
31
37
|
spec.add_development_dependency 'webmock', '~> 3.5'
|
32
38
|
|
33
|
-
spec.add_runtime_dependency 'absolutely', '~> 2.
|
39
|
+
spec.add_runtime_dependency 'absolutely', '~> 2.1'
|
34
40
|
spec.add_runtime_dependency 'addressable', '~> 2.6'
|
35
41
|
spec.add_runtime_dependency 'http', '~> 5.0.0.pre'
|
36
42
|
spec.add_runtime_dependency 'nokogiri', '~> 1.10'
|
37
43
|
end
|
44
|
+
# rubocop:enable Metrics/BlockLength
|
data/lib/indieweb/endpoints.rb
CHANGED
@@ -7,6 +7,7 @@ require 'indieweb/endpoints/version'
|
|
7
7
|
require 'indieweb/endpoints/exceptions'
|
8
8
|
|
9
9
|
require 'indieweb/endpoints/client'
|
10
|
+
require 'indieweb/endpoints/http_request'
|
10
11
|
require 'indieweb/endpoints/registerable'
|
11
12
|
|
12
13
|
require 'indieweb/endpoints/parsers'
|
@@ -18,8 +19,14 @@ require 'indieweb/endpoints/parsers/webmention_parser'
|
|
18
19
|
|
19
20
|
module IndieWeb
|
20
21
|
module Endpoints
|
21
|
-
|
22
|
-
|
22
|
+
class << self
|
23
|
+
def client(url)
|
24
|
+
Client.new(url)
|
25
|
+
end
|
26
|
+
|
27
|
+
def get(url)
|
28
|
+
client(url).endpoints
|
29
|
+
end
|
23
30
|
end
|
24
31
|
end
|
25
32
|
end
|
@@ -1,17 +1,12 @@
|
|
1
1
|
module IndieWeb
|
2
2
|
module Endpoints
|
3
3
|
class Client
|
4
|
-
HTTP_HEADERS_OPTS = {
|
5
|
-
accept: '*/*',
|
6
|
-
user_agent: 'IndieAuth, Micropub, and Webmention Endpoint Discovery (https://rubygems.org/gems/indieweb-endpoints)'
|
7
|
-
}.freeze
|
8
|
-
|
9
4
|
def initialize(url)
|
10
5
|
raise ArgumentError, "url must be a String (given #{url.class.name})" unless url.is_a?(String)
|
11
6
|
|
12
|
-
@
|
7
|
+
@uri = Addressable::URI.parse(url)
|
13
8
|
|
14
|
-
raise ArgumentError, 'url must be an absolute URL (e.g. https://example.com)' unless @
|
9
|
+
raise ArgumentError, 'url must be an absolute URL (e.g. https://example.com)' unless @uri.absolute?
|
15
10
|
rescue Addressable::URI::InvalidURIError => exception
|
16
11
|
raise InvalidURIError, exception
|
17
12
|
end
|
@@ -21,11 +16,7 @@ module IndieWeb
|
|
21
16
|
end
|
22
17
|
|
23
18
|
def response
|
24
|
-
@response ||=
|
25
|
-
rescue HTTP::ConnectionError,
|
26
|
-
HTTP::TimeoutError,
|
27
|
-
HTTP::Redirector::TooManyRedirectsError => exception
|
28
|
-
raise IndieWeb::Endpoints.const_get(exception.class.name.split('::').last), exception
|
19
|
+
@response ||= HttpRequest.get(@uri)
|
29
20
|
end
|
30
21
|
end
|
31
22
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
module IndieWeb
|
2
2
|
module Endpoints
|
3
|
-
class
|
3
|
+
class IndieWebEndpointsError < StandardError; end
|
4
4
|
|
5
|
-
class ArgumentError <
|
5
|
+
class ArgumentError < IndieWebEndpointsError; end
|
6
6
|
|
7
|
-
class ConnectionError <
|
7
|
+
class ConnectionError < IndieWebEndpointsError; end
|
8
8
|
|
9
|
-
class InvalidURIError <
|
9
|
+
class InvalidURIError < IndieWebEndpointsError; end
|
10
10
|
|
11
|
-
class TimeoutError <
|
11
|
+
class TimeoutError < IndieWebEndpointsError; end
|
12
12
|
|
13
|
-
class TooManyRedirectsError <
|
13
|
+
class TooManyRedirectsError < IndieWebEndpointsError; end
|
14
14
|
end
|
15
15
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module IndieWeb
|
2
|
+
module Endpoints
|
3
|
+
class HttpRequest
|
4
|
+
HTTP_HEADERS_OPTS = {
|
5
|
+
accept: '*/*',
|
6
|
+
user_agent: 'IndieAuth, Micropub, and Webmention Endpoint Discovery (https://rubygems.org/gems/indieweb-endpoints)'
|
7
|
+
}.freeze
|
8
|
+
|
9
|
+
def self.get(uri)
|
10
|
+
HTTP.follow.headers(HTTP_HEADERS_OPTS).timeout(connect: 10, read: 10).get(uri)
|
11
|
+
rescue HTTP::ConnectionError,
|
12
|
+
HTTP::TimeoutError,
|
13
|
+
HTTP::Redirector::TooManyRedirectsError => exception
|
14
|
+
raise IndieWeb::Endpoints.const_get(exception.class.name.split('::').last), exception
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -21,7 +21,7 @@ module IndieWeb
|
|
21
21
|
def results
|
22
22
|
return unless results_from_http_request
|
23
23
|
|
24
|
-
@results ||= Absolutely.
|
24
|
+
@results ||= Absolutely.to_abs(base: @response.uri.to_s, relative: results_from_http_request)
|
25
25
|
rescue Absolutely::InvalidURIError => exception
|
26
26
|
raise InvalidURIError, exception
|
27
27
|
end
|
@@ -11,7 +11,7 @@ module IndieWeb
|
|
11
11
|
def results
|
12
12
|
return unless results_from_http_request.any?
|
13
13
|
|
14
|
-
@results ||= results_from_http_request.map { |endpoint| Absolutely.
|
14
|
+
@results ||= results_from_http_request.map { |endpoint| Absolutely.to_abs(base: @response.uri.to_s, relative: endpoint) }.uniq.sort
|
15
15
|
rescue Absolutely::InvalidURIError => exception
|
16
16
|
raise InvalidURIError, exception
|
17
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: indieweb-endpoints
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Garber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.68.1
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.68.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubocop-performance
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '2.
|
145
|
+
version: '2.1'
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '2.
|
152
|
+
version: '2.1'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: addressable
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,6 +220,7 @@ files:
|
|
220
220
|
- lib/indieweb/endpoints.rb
|
221
221
|
- lib/indieweb/endpoints/client.rb
|
222
222
|
- lib/indieweb/endpoints/exceptions.rb
|
223
|
+
- lib/indieweb/endpoints/http_request.rb
|
223
224
|
- lib/indieweb/endpoints/parsers.rb
|
224
225
|
- lib/indieweb/endpoints/parsers/authorization_endpoint_parser.rb
|
225
226
|
- lib/indieweb/endpoints/parsers/micropub_parser.rb
|
@@ -231,7 +232,9 @@ files:
|
|
231
232
|
homepage: https://github.com/indieweb/indieweb-endpoints-ruby
|
232
233
|
licenses:
|
233
234
|
- MIT
|
234
|
-
metadata:
|
235
|
+
metadata:
|
236
|
+
bug_tracker_uri: https://github.com/indieweb/indieweb-endpoints-ruby/issues
|
237
|
+
changelog_uri: https://github.com/indieweb/indieweb-endpoints-ruby/blob/v0.4.0/CHANGELOG.md
|
235
238
|
post_install_message:
|
236
239
|
rdoc_options: []
|
237
240
|
require_paths:
|