webmention-endpoint 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/CONTRIBUTING.md +2 -2
- data/README.md +4 -3
- data/lib/webmention/endpoint/discover.rb +13 -18
- data/lib/webmention/endpoint/version.rb +1 -1
- data/lib/webmention/endpoint.rb +1 -0
- data/webmention-endpoint.gemspec +2 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00d58c80ff5ed751aca7f953de02800064dd9155
|
4
|
+
data.tar.gz: 6b8cc6c70b1bcae664173cd987013ea6d8a50bea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf48f7b374749c68727a346a111b818f5d7f59f740970339e3a304e724b784d4c4e45f47de51c4d22d9d3754f4434e7da81107bf90a3b23300b6a1f315938410
|
7
|
+
data.tar.gz: 866f1cb6ebfc5112726bd9ded282e8f441a45f74a08c1619fddb38e7edd7199bd120dfd1b3fdf24fe4e936062e594ef668eeebcc92497e4397fe357ea51c6f40
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.3.0 / 2018-07-05
|
4
|
+
|
5
|
+
- Adds [Absolutely](https://github.com/jgarber623/absolutely) gem dependency for handling conversion of relative URLs to absolute URLs ([2b8f924](https://github.com/jgarber623/webmention-endpoint-ruby/commit/2b8f924)).
|
6
|
+
|
3
7
|
## 0.2.0 / 2018-06-25
|
4
8
|
|
5
9
|
- Adds `Webmention::Endpoint::Error` class and subclasses ([f81852f](https://github.com/jgarber623/webmention-endpoint-ruby/commit/f81852f)).
|
data/CONTRIBUTING.md
CHANGED
@@ -33,5 +33,5 @@ Code formatting conventions are defined in the `.editorconfig` file which uses t
|
|
33
33
|
|
34
34
|
Your bug fix or feature addition won't be rejected if it runs afoul of any (or all) of these guidelines, but following the guidelines will definitely make everyone's lives a little easier.
|
35
35
|
|
36
|
-
[issues]: https://github.com/
|
37
|
-
[pulls]: https://github.com/
|
36
|
+
[issues]: https://github.com/jgarber623/webmention-endpoint-ruby/issues
|
37
|
+
[pulls]: https://github.com/jgarber623/webmention-endpoint-ruby/pulls
|
data/README.md
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
[![Gem](https://img.shields.io/gem/v/webmention-endpoint.svg?style=for-the-badge)](https://rubygems.org/gems/webmention-endpoint)
|
6
6
|
[![Downloads](https://img.shields.io/gem/dt/webmention-endpoint.svg?style=for-the-badge)](https://rubygems.org/gems/webmention-endpoint)
|
7
7
|
[![Build](https://img.shields.io/travis/com/jgarber623/webmention-endpoint-ruby/master.svg?style=for-the-badge)](https://travis-ci.com/jgarber623/webmention-endpoint-ruby)
|
8
|
+
[![Dependencies](https://img.shields.io/depfu/jgarber623/webmention-endpoint-ruby.svg?style=for-the-badge)](https://depfu.com/github/jgarber623/webmention-endpoint-ruby)
|
8
9
|
[![Maintainability](https://img.shields.io/codeclimate/maintainability/jgarber623/webmention-endpoint-ruby.svg?style=for-the-badge)](https://codeclimate.com/github/jgarber623/webmention-endpoint-ruby)
|
9
10
|
[![Coverage](https://img.shields.io/codeclimate/c/jgarber623/webmention-endpoint-ruby.svg?style=for-the-badge)](https://codeclimate.com/github/jgarber623/webmention-endpoint-ruby/code)
|
10
11
|
|
@@ -18,7 +19,7 @@
|
|
18
19
|
|
19
20
|
Before installing and using webmention-endpoint-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
21
|
|
21
|
-
webmention-endpoint-ruby is developed using Ruby 2.4.4 and is additionally tested against Ruby 2.5.1 using [Travis CI](https://travis-ci.
|
22
|
+
webmention-endpoint-ruby is developed using Ruby 2.4.4 and is additionally tested against Ruby 2.5.1 using [Travis CI](https://travis-ci.com/jgarber623/webmention-endpoint-ruby).
|
22
23
|
|
23
24
|
## Installation
|
24
25
|
|
@@ -82,7 +83,7 @@ puts discoverer.response # returns HTTP::Response
|
|
82
83
|
|
83
84
|
There are several exceptions that may be raised by webmention-endpoint-ruby's underlying dependencies. These errors are raised as subclasses of `Webmention::Endpoint::Error` (which itself is a subclass of `StandardError`).
|
84
85
|
|
85
|
-
From [sporkmonger/addressable](https://github.com/sporkmonger/addressable):
|
86
|
+
From [jgarber623/absolutely](https://github.com/jgarber623/absolutely) and [sporkmonger/addressable](https://github.com/sporkmonger/addressable):
|
86
87
|
|
87
88
|
- `Webmention::Endpoint::InvalidURIError`
|
88
89
|
|
@@ -94,7 +95,7 @@ From [httprb/http](https://github.com/httprb/http):
|
|
94
95
|
|
95
96
|
## Contributing
|
96
97
|
|
97
|
-
Interested in helping improve webmention-endpoint-ruby? Awesome! Your help is greatly appreciated. See [CONTRIBUTING.md](https://github.com/jgarber623/blob/master/CONTRIBUTING.md) for details.
|
98
|
+
Interested in helping improve webmention-endpoint-ruby? Awesome! Your help is greatly appreciated. See [CONTRIBUTING.md](https://github.com/jgarber623/webmention-endpoint-ruby/blob/master/CONTRIBUTING.md) for details.
|
98
99
|
|
99
100
|
## Acknowledgments
|
100
101
|
|
@@ -6,14 +6,14 @@ module Webmention
|
|
6
6
|
user_agent: 'Webmention Endpoint Discovery (https://rubygems.org/gems/webmention-endpoint)'
|
7
7
|
}.freeze
|
8
8
|
|
9
|
-
# Liberal pattern matching a string of text between angle brackets
|
10
|
-
# https://tools.ietf.org/html/rfc5988#section-5.1
|
11
|
-
REGEXP_TARGET_URI_PATTERN = /^<(.*)>;/
|
12
|
-
|
13
9
|
# Ultra-orthodox pattern matching allowed values in Link header `rel` parameter
|
14
10
|
# https://tools.ietf.org/html/rfc8288#section-3.3
|
15
11
|
REGEXP_REG_REL_TYPE_PATTERN = '[a-z\d][a-z\d\-\.]*'.freeze
|
16
12
|
|
13
|
+
# Liberal pattern matching a string of text between angle brackets
|
14
|
+
# https://tools.ietf.org/html/rfc5988#section-5.1
|
15
|
+
REGEXP_TARGET_URI_PATTERN = /^<(.*)>;/
|
16
|
+
|
17
17
|
# Ultra-orthodox pattern matching Link header `rel` parameter including a `webmention` value
|
18
18
|
# https://www.w3.org/TR/webmention/#sender-discovers-receiver-webmention-endpoint-p-1
|
19
19
|
REGEXP_WEBMENTION_REL_PATTERN = /(?:;|\s)rel="?(?:#{REGEXP_REG_REL_TYPE_PATTERN}+\s)?webmention(?:\s#{REGEXP_REG_REL_TYPE_PATTERN})?"?/
|
@@ -30,7 +30,11 @@ module Webmention
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def endpoint
|
33
|
-
|
33
|
+
return unless endpoint_from_http_request
|
34
|
+
|
35
|
+
@endpoint ||= Absolutely.to_absolute_uri(base: url, relative: endpoint_from_http_request)
|
36
|
+
rescue Absolutely::InvalidURIError => error
|
37
|
+
raise InvalidURIError, error
|
34
38
|
end
|
35
39
|
|
36
40
|
def response
|
@@ -48,19 +52,6 @@ module Webmention
|
|
48
52
|
|
49
53
|
private
|
50
54
|
|
51
|
-
def absolutize(base:, relative:)
|
52
|
-
return unless relative
|
53
|
-
|
54
|
-
base_uri = Addressable::URI.parse(base)
|
55
|
-
relative_uri = Addressable::URI.parse(relative)
|
56
|
-
|
57
|
-
return relative if relative_uri.absolute?
|
58
|
-
|
59
|
-
(base_uri + relative_uri).to_s
|
60
|
-
rescue Addressable::URI::InvalidURIError => error
|
61
|
-
raise InvalidURIError, error
|
62
|
-
end
|
63
|
-
|
64
55
|
def endpoint_from_body
|
65
56
|
return unless response.mime_type == 'text/html'
|
66
57
|
|
@@ -89,6 +80,10 @@ module Webmention
|
|
89
80
|
|
90
81
|
return endpoint_match_data[1] if endpoint_match_data
|
91
82
|
end
|
83
|
+
|
84
|
+
def endpoint_from_http_request
|
85
|
+
@endpoint_from_http_request ||= endpoint_from_headers || endpoint_from_body || nil
|
86
|
+
end
|
92
87
|
end
|
93
88
|
end
|
94
89
|
end
|
data/lib/webmention/endpoint.rb
CHANGED
data/webmention-endpoint.gemspec
CHANGED
@@ -28,7 +28,8 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency 'simplecov', '~> 0.16.1'
|
29
29
|
spec.add_development_dependency 'simplecov-console', '~> 0.4.2'
|
30
30
|
|
31
|
+
spec.add_runtime_dependency 'absolutely', '~> 1.0'
|
31
32
|
spec.add_runtime_dependency 'addressable', '~> 2.5', '>= 2.5.2'
|
32
33
|
spec.add_runtime_dependency 'http', '~> 3.3'
|
33
|
-
spec.add_runtime_dependency 'nokogiri', '~> 1.8', '>= 1.8.
|
34
|
+
spec.add_runtime_dependency 'nokogiri', '~> 1.8', '>= 1.8.4'
|
34
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webmention-endpoint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.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: 2018-
|
11
|
+
date: 2018-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -120,6 +120,20 @@ dependencies:
|
|
120
120
|
- - "~>"
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: 0.4.2
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: absolutely
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '1.0'
|
130
|
+
type: :runtime
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - "~>"
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '1.0'
|
123
137
|
- !ruby/object:Gem::Dependency
|
124
138
|
name: addressable
|
125
139
|
requirement: !ruby/object:Gem::Requirement
|
@@ -163,7 +177,7 @@ dependencies:
|
|
163
177
|
version: '1.8'
|
164
178
|
- - ">="
|
165
179
|
- !ruby/object:Gem::Version
|
166
|
-
version: 1.8.
|
180
|
+
version: 1.8.4
|
167
181
|
type: :runtime
|
168
182
|
prerelease: false
|
169
183
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -173,7 +187,7 @@ dependencies:
|
|
173
187
|
version: '1.8'
|
174
188
|
- - ">="
|
175
189
|
- !ruby/object:Gem::Version
|
176
|
-
version: 1.8.
|
190
|
+
version: 1.8.4
|
177
191
|
description: Discover a URL’s Webmention endpoint.
|
178
192
|
email:
|
179
193
|
- jason@sixtwothree.org
|