micropub-endpoint 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bbc2dfb68b80f95e2fb6bdcc8146597dbd0fbbf1
4
- data.tar.gz: b6d1c604d7e6d74a0feb909eecb2fab8b056520e
3
+ metadata.gz: a6241a2f87a2ed02d0aa63794793b1af4a6188a7
4
+ data.tar.gz: 403b5e14381412d58ba15e1b96a355ad573c4c76
5
5
  SHA512:
6
- metadata.gz: 681b8cda4b0c6aa053a7ec7cc3a467347283694c4d8a01197ded82bf27c79aeecca391ec59df1a358f202705bb160008e96aa91dd30fc18b52e4ca0bad697368
7
- data.tar.gz: bb27d44678d41714b76ff1e9673619e2c1c9cc6e08f4fbe983d1a33fc6c7a5efa63d37d0812daa9f115e7a50871c715f553eb3d20338cb09e5cc32531da7ec05
6
+ metadata.gz: cb99051e43d51898e638e09c514e08a4b25cdc08aad828c11219c3baf50f6d2f6f94a258ea77301652853b864651b8e1257e2731a92d7d6e5c8ca2a51b2cee8a
7
+ data.tar.gz: fd405635d6f864e65aa6c72050ca6f1857bcf07844be358dc938bc7dc9239f39b198f437b3be6bd39ea0307d63e53b79640e945c3d3662afeaa824e94c9784a4
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 / 2018-07-05
4
+
5
+ - Add [Absolutely](https://github.com/jgarber623/absolutely) gem dependency for handling conversion of relative URLs to absolute URLs ([d17fe1e](https://github.com/jgarber623/micropub-endpoint-ruby/commit/d17fe1e)).
6
+
7
+ ## 0.1.0 / 2018-06-30
8
+
9
+ - Initial release!
data/README.md CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  Before installing and using micropub-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
20
 
21
- micropub-endpoint-ruby is developed using Ruby 2.4.4 and is additionally tested against Ruby 2.5.1 using [Travis CI](https://travis-ci.org/indieweb/micropub-endpoint-ruby).
21
+ micropub-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/micropub-endpoint-ruby).
22
22
 
23
23
  ## Installation
24
24
 
@@ -82,7 +82,7 @@ puts discoverer.response # returns HTTP::Response
82
82
 
83
83
  There are several exceptions that may be raised by micropub-endpoint-ruby's underlying dependencies. These errors are raised as subclasses of `Micropub::Endpoint::Error` (which itself is a subclass of `StandardError`).
84
84
 
85
- From [sporkmonger/addressable](https://github.com/sporkmonger/addressable):
85
+ From [jgarber623/absolutely](https://github.com/jgarber623/absolutely) and [sporkmonger/addressable](https://github.com/sporkmonger/addressable):
86
86
 
87
87
  - `Micropub::Endpoint::InvalidURIError`
88
88
 
@@ -1,3 +1,4 @@
1
+ require 'absolutely'
1
2
  require 'addressable/uri'
2
3
  require 'http'
3
4
  require 'nokogiri'
@@ -30,7 +30,11 @@ module Micropub
30
30
  end
31
31
 
32
32
  def endpoint
33
- @endpoint ||= absolutize(base: url, relative: (endpoint_from_headers || endpoint_from_body)) || nil
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 Micropub
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
 
@@ -88,6 +79,10 @@ module Micropub
88
79
 
89
80
  return endpoint_match_data[1] if endpoint_match_data
90
81
  end
82
+
83
+ def endpoint_from_http_request
84
+ @endpoint_from_http_request ||= endpoint_from_headers || endpoint_from_body || nil
85
+ end
91
86
  end
92
87
  end
93
88
  end
@@ -1,5 +1,5 @@
1
1
  module Micropub
2
2
  module Endpoint
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
5
5
  end
@@ -29,7 +29,8 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'simplecov-console', '~> 0.4.2'
30
30
  spec.add_development_dependency 'webmock', '~> 3.4', '>= 3.4.2'
31
31
 
32
+ spec.add_runtime_dependency 'absolutely', '~> 1.0'
32
33
  spec.add_runtime_dependency 'addressable', '~> 2.5', '>= 2.5.2'
33
34
  spec.add_runtime_dependency 'http', '~> 3.3'
34
- spec.add_runtime_dependency 'nokogiri', '~> 1.8', '>= 1.8.3'
35
+ spec.add_runtime_dependency 'nokogiri', '~> 1.8', '>= 1.8.4'
35
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: micropub-endpoint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.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-06-30 00:00:00.000000000 Z
11
+ date: 2018-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -140,6 +140,20 @@ dependencies:
140
140
  - - ">="
141
141
  - !ruby/object:Gem::Version
142
142
  version: 3.4.2
143
+ - !ruby/object:Gem::Dependency
144
+ name: absolutely
145
+ requirement: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - "~>"
148
+ - !ruby/object:Gem::Version
149
+ version: '1.0'
150
+ type: :runtime
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - "~>"
155
+ - !ruby/object:Gem::Version
156
+ version: '1.0'
143
157
  - !ruby/object:Gem::Dependency
144
158
  name: addressable
145
159
  requirement: !ruby/object:Gem::Requirement
@@ -183,7 +197,7 @@ dependencies:
183
197
  version: '1.8'
184
198
  - - ">="
185
199
  - !ruby/object:Gem::Version
186
- version: 1.8.3
200
+ version: 1.8.4
187
201
  type: :runtime
188
202
  prerelease: false
189
203
  version_requirements: !ruby/object:Gem::Requirement
@@ -193,7 +207,7 @@ dependencies:
193
207
  version: '1.8'
194
208
  - - ">="
195
209
  - !ruby/object:Gem::Version
196
- version: 1.8.3
210
+ version: 1.8.4
197
211
  description: Discover a URL’s Micropub endpoint.
198
212
  email:
199
213
  - jason@sixtwothree.org
@@ -209,6 +223,7 @@ files:
209
223
  - ".ruby-version"
210
224
  - ".simplecov"
211
225
  - ".travis.yml"
226
+ - CHANGELOG.md
212
227
  - CONTRIBUTING.md
213
228
  - Gemfile
214
229
  - LICENSE