net_http_timeout_errors 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,16 +1,16 @@
1
- # Net::HTTP::TIMEOUT\_ERRORS
1
+ # NetHttpTimeoutErrors
2
2
 
3
3
  Tired of having to rescue an ever-growing list of Net::HTTP timeout error types?
4
4
 
5
5
  Just include this gem and then do:
6
6
 
7
- ```
7
+ ``` ruby
8
8
  begin
9
9
  uri = URI.parse("http://google.com/")
10
10
  response = Net::HTTP.get_response(uri)
11
- rescue *Net::HTTP::TIMEOUT_ERRORS
11
+ rescue *NetHttpTimeoutErrors.all
12
12
  puts "It timed out some way or other!"
13
- rescue AnotherError, *Net::HTTP::TIMEOUT_ERRORS
13
+ rescue AnotherError, *NetHttpTimeoutErrors.all
14
14
  puts "This works too."
15
15
  end
16
16
  ```
@@ -1,9 +1,9 @@
1
1
  require "net_http_timeout_errors/version"
2
2
  require "net/http"
3
3
 
4
- module Net
5
- class HTTP
6
- TIMEOUT_ERRORS = [
4
+ module NetHttpTimeoutErrors
5
+ def self.all
6
+ [
7
7
  Errno::ECONNREFUSED,
8
8
  Errno::ECONNRESET,
9
9
  Errno::EHOSTUNREACH,
@@ -1,3 +1,3 @@
1
1
  module NetHttpTimeoutErrors
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,8 +1,16 @@
1
1
  require "minitest/autorun"
2
2
  require "net_http_timeout_errors"
3
3
 
4
- describe Net::HTTP, "TIMEOUT_ERRORS" do
4
+ describe NetHttpTimeoutErrors, ".all" do
5
5
  it "has some" do
6
- Net::HTTP::TIMEOUT_ERRORS.wont_be_empty
6
+ NetHttpTimeoutErrors.all.wont_be_empty
7
+ end
8
+
9
+ # No assertions; more like runnable documentation.
10
+ it "works splatted" do
11
+ begin
12
+ raise Timeout::Error
13
+ rescue ZeroDivisionError, *NetHttpTimeoutErrors.all
14
+ end
7
15
  end
8
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net_http_timeout_errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: