yt-support 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52850660c93460a274efca68349e3b6a1cdaf53c
4
- data.tar.gz: bd1b2f4d5a3e4c0005dfd2d15ad5b8508c49f33e
3
+ metadata.gz: c6a662f825d0c472754909155714397c84cf600c
4
+ data.tar.gz: 4999e00a754f796f8b9d5a00fed15fa538dc69bd
5
5
  SHA512:
6
- metadata.gz: 0b804979d3bd2d49ef3841e5a0c43f1d692d634b38ef348409396c642257062eaf9cb76db6f0aa107807f9736e532713be08fc4a509978295add768c0490bcf5
7
- data.tar.gz: 612a312b478a97225a0b35508fd2f4f40f7e52745f6f1b8bc44c7d6e3e49ea3380d9ec9f2eb65b1d72b5531a73f0e39f719ef971d12235e9247d8f13635b9254
6
+ metadata.gz: d91e68dea4b16beb241f28eb8808f56bd35536988c7e2565d463badf90d0568c5c4b9a64e2ee0d11dd90dc1240c1c22968e9afa8274e1189b63d26691c6c7ca1
7
+ data.tar.gz: 45245e9ec74c83598d767d472df76e88c2a375ab34d92f770b5e5e7e52890d848f061cf39288bbc8b7b75c498554c5e9062fcfdb063f3812b755defdf0047dff
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ For more information about changelogs, check
6
6
  [Keep a Changelog](http://keepachangelog.com) and
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
+ ## 0.1.2 - 2017-04-02
10
+
11
+ * [FEATURE] Add Yt::ConnectionError to deal with connection/server errors
12
+
9
13
  ## 0.1.1 - 2017-03-29
10
14
 
11
15
  * [FEATURE] Extracted Yt::HTTPRequest and Yt::HTTPError from Yt::Auth
data/README.md CHANGED
@@ -19,6 +19,7 @@ Yt::Support provides:
19
19
  * [Yt::Configuration](http://www.rubydoc.info/gems/yt-support/Yt/Configuration)
20
20
  * [Yt::HTTPRequest](http://www.rubydoc.info/gems/yt-support/Yt/HTTPRequest)
21
21
  * [Yt::HTTPError](http://www.rubydoc.info/gems/yt-support/Yt/HTTPError)
22
+ * [Yt::ConnectionError](http://www.rubydoc.info/gems/yt-support/Yt/ConnectionError)
22
23
 
23
24
  How to contribute
24
25
  =================
@@ -0,0 +1,5 @@
1
+ module Yt
2
+ # A wrapper around StandardError.
3
+ class ConnectionError < StandardError
4
+ end
5
+ end
@@ -1,5 +1,6 @@
1
1
  require 'net/http'
2
2
  require 'json'
3
+ require 'yt/connection_error'
3
4
  require 'yt/http_error'
4
5
 
5
6
  module Yt
@@ -111,6 +112,17 @@ module Yt
111
112
  @response ||= Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
112
113
  http.request http_request
113
114
  end
115
+ rescue *server_errors => e
116
+ raise Yt::ConnectionError, e.message
117
+ end
118
+
119
+ # Returns the list of server errors worth retrying the request once.
120
+ def server_errors
121
+ [
122
+ Errno::ECONNRESET, Errno::EHOSTUNREACH, Errno::ENETUNREACH,
123
+ Errno::ETIMEDOUT, Net::HTTPServerError, Net::OpenTimeout,
124
+ OpenSSL::SSL::SSLError, OpenSSL::SSL::SSLErrorWaitReadable, SocketError,
125
+ ]
114
126
  end
115
127
 
116
128
  # Replaces the body of the response with the parsed version of the body,
@@ -2,6 +2,6 @@ module Yt
2
2
  # Provides common functionality to all Yt gems.
3
3
  module Support
4
4
  # current version of gem
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yt-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-03-29 00:00:00.000000000 Z
12
+ date: 2017-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -117,6 +117,7 @@ files:
117
117
  - bin/setup
118
118
  - lib/yt/config.rb
119
119
  - lib/yt/configuration.rb
120
+ - lib/yt/connection_error.rb
120
121
  - lib/yt/http_error.rb
121
122
  - lib/yt/http_request.rb
122
123
  - lib/yt/support.rb