webmention-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: 4666da2892037b8191954b2454929a8094c24c3f
4
- data.tar.gz: b800c17e27f8b9069a3b6204aadf3fe79d333a1c
3
+ metadata.gz: 0f8949affbb9a7d11b3a7921836df000df533090
4
+ data.tar.gz: 6d8feea53689bb397ad3257eb8d2f27238887357
5
5
  SHA512:
6
- metadata.gz: 10a81ebbad3379a0b8e7245bd9a8603c29b135ff8bf528ab2eba4105edbcc054ef160ecd5b0dc201d5e3c68c8838124d42e3f9d6a0dddf969a8c8385f0b6dd24
7
- data.tar.gz: c2154f9d69135002509c847d16dbd02791d3d75c6236d2f9952ee72fda12882eebf41ef1be79a9a00fe44b7f33aa56540a37dbeb9e3d938c93c4778528cd1f6c
6
+ metadata.gz: ca338aef70ea4d02e959be264088c528dd9b4ea4959079d0b13e03abff4fade24ce83a5f0ac7065d1a582dae13054d7bc7d1bb6fed137e36d96a0c64296eaeb8
7
+ data.tar.gz: 9a2043839ba89dadc1944ead1a606276dabaa8eba495bf7f14175253348944521d194c39171f469a4f971a5f625a2f991a509e7b383102187df75036a50081a4
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 / 2018-06-25
4
+
5
+ - Adds `Webmention::Endpoint::Error` class and subclasses ([f81852f](https://github.com/jgarber623/webmention-endpoint-ruby/commit/f81852f)).
6
+
7
+ ## 0.1.0 / 2018-06-24
8
+
9
+ - Initial release!
data/README.md CHANGED
@@ -80,17 +80,17 @@ puts discoverer.response # returns HTTP::Response
80
80
 
81
81
  ### Exception Handling
82
82
 
83
- There are several exceptions that may be raised by webmention-endpoint-ruby's underlying dependencies:
83
+ 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
84
 
85
- - `Addressable::URI::InvalidURIError`
86
- - `HTTP::ConnectionError`
87
- - `HTTP::TimeoutError`
88
- - `HTTP::Redirector::TooManyRedirectsError`
85
+ From [sporkmonger/addressable](https://github.com/sporkmonger/addressable):
89
86
 
90
- You'll want to make sure your code gracefully handles these exceptions. For more on each of these exceptions, see:
87
+ - `Webmention::Endpoint::InvalidURIError`
91
88
 
92
- - [sporkmonger/addressable](https://github.com/sporkmonger/addressable) – Source code for the Addressable Ruby gem
93
- - [httprb/http](https://github.com/httprb/http) – Source code for the HTTP Ruby gem
89
+ From [httprb/http](https://github.com/httprb/http):
90
+
91
+ - `Webmention::Endpoint::ConnectionError`
92
+ - `Webmention::Endpoint::TimeoutError`
93
+ - `Webmention::Endpoint::TooManyRedirectsError`
94
94
 
95
95
  ## Contributing
96
96
 
@@ -3,6 +3,7 @@ require 'http'
3
3
  require 'nokogiri'
4
4
 
5
5
  require 'webmention/endpoint/version'
6
+ require 'webmention/endpoint/error'
6
7
  require 'webmention/endpoint/discover'
7
8
 
8
9
  module Webmention
@@ -25,6 +25,8 @@ module Webmention
25
25
 
26
26
  @url = url
27
27
  @uri = Addressable::URI.parse(url)
28
+ rescue Addressable::URI::InvalidURIError => error
29
+ raise InvalidURIError, error
28
30
  end
29
31
 
30
32
  def endpoint
@@ -36,6 +38,12 @@ module Webmention
36
38
  connect: 10,
37
39
  read: 10
38
40
  ).get(uri)
41
+ rescue HTTP::ConnectionError => error
42
+ raise ConnectionError, error
43
+ rescue HTTP::TimeoutError => error
44
+ raise TimeoutError, error
45
+ rescue HTTP::Redirector::TooManyRedirectsError => error
46
+ raise TooManyRedirectsError, error
39
47
  end
40
48
 
41
49
  private
@@ -49,6 +57,8 @@ module Webmention
49
57
  return relative if relative_uri.absolute?
50
58
 
51
59
  (base_uri + relative_uri).to_s
60
+ rescue Addressable::URI::InvalidURIError => error
61
+ raise InvalidURIError, error
52
62
  end
53
63
 
54
64
  def endpoint_from_body
@@ -0,0 +1,15 @@
1
+ module Webmention
2
+ module Endpoint
3
+ class Error < StandardError; end
4
+
5
+ class ArgumentError < Error; end
6
+
7
+ class ConnectionError < Error; end
8
+
9
+ class InvalidURIError < Error; end
10
+
11
+ class TimeoutError < Error; end
12
+
13
+ class TooManyRedirectsError < Error; end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  module Webmention
2
2
  module Endpoint
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
5
5
  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.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-24 00:00:00.000000000 Z
11
+ date: 2018-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -189,6 +189,7 @@ files:
189
189
  - ".ruby-version"
190
190
  - ".simplecov"
191
191
  - ".travis.yml"
192
+ - CHANGELOG.md
192
193
  - CONTRIBUTING.md
193
194
  - Gemfile
194
195
  - LICENSE
@@ -196,6 +197,7 @@ files:
196
197
  - Rakefile
197
198
  - lib/webmention/endpoint.rb
198
199
  - lib/webmention/endpoint/discover.rb
200
+ - lib/webmention/endpoint/error.rb
199
201
  - lib/webmention/endpoint/version.rb
200
202
  - webmention-endpoint.gemspec
201
203
  homepage: https://github.com/jgarber623/webmention-endpoint-ruby