gull 0.3.0 → 0.3.1

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: 85f0268b1bbaa2d578bd56d7009ae77e6677844d
4
- data.tar.gz: 36044cbee5417556bd2957b12617ac28fc9d97b2
3
+ metadata.gz: 6dd83076a56a80eb80bc1ff60c6952a74519d2f3
4
+ data.tar.gz: 4c9993c1ab28823f63face88678630c49e938074
5
5
  SHA512:
6
- metadata.gz: f5a27d2ce025475eb49c36be539f36776836ce4bd817cad9293aa87b18004972720262a969cb57acab801566986da218bdb0b1faf45decddce7cab590dce0e52
7
- data.tar.gz: 9fe4fc8c1eb48d41200f0b469cc8334c05adc6684ef8836d9489edd6f04936906887d6097cfbf5bd3c9344fbe9dacf6ebcb98d3b0f39d3043c5e3abec46dabeb
6
+ metadata.gz: 865775c7a423600f941f4811a80309aa24cb3a6a8315f30f142b579899bb15ddd577d76906b2d8dbeb3ad2ec856cec993eeed62ff16fe7d0a43824298dc009f2
7
+ data.tar.gz: 0d2d2bc96c97ef7198cb580cf0ce08d2582efdd568ba6286af6f918177abd2d69ebe3bee9c54c12486175560b20d32f86d3eb7c08d94973558d8d4d21faf20d2
@@ -1,3 +1,5 @@
1
+ #### 0.3.1 (6/25/2015)
2
+ Added nested exception handling for other HTTPClient errors. HttpError has original attribute exposing the root exception.
1
3
  #### 0.3.0 (6/23/2015)
2
4
  Added Client class for error handling (bad entries accessed via errors array). Exposed option to turn on strict XML parsing for debugging. Alert.fetch uses new Client but is backwards compatible, however it doesn't give you access to errors array.
3
5
  ***
@@ -31,6 +31,8 @@ module Gull
31
31
  return client.get_content @options[:url]
32
32
  rescue HTTPClient::TimeoutError
33
33
  raise TimeoutError, 'Timeout while connecting to NWS web service'
34
+ rescue HTTPClient::KeepAliveDisconnected, SocketError
35
+ raise HttpError, 'HTTP error while connecting to NWS web service'
34
36
  end
35
37
  end
36
38
 
@@ -1,4 +1,15 @@
1
+ require 'English'
2
+
1
3
  module Gull
2
- class TimeoutError < StandardError
4
+ class HttpError < StandardError
5
+ attr_reader :original
6
+
7
+ def initialize(message, original = $ERROR_INFO)
8
+ super(message)
9
+ @original = original
10
+ end
11
+ end
12
+
13
+ class TimeoutError < HttpError
3
14
  end
4
15
  end
@@ -1,3 +1,3 @@
1
1
  module Gull
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -100,15 +100,6 @@ describe Gull::Alert do
100
100
  expect(alerts.size).to eq(0)
101
101
  end
102
102
 
103
- it 'should raise own error if timeout occurs' do
104
- stub_request(:get, 'http://alerts.weather.gov/cap/us.php?x=1')
105
- .with(headers: { 'Accept' => '*/*' }).to_timeout
106
-
107
- message = 'Timeout while connecting to NWS web service'
108
- expect { Gull::Alert.fetch }
109
- .to raise_error(Gull::TimeoutError, message)
110
- end
111
-
112
103
  it 'should handle missing cap section' do
113
104
  xml = File.read 'spec/fixtures/missing_cap.xml'
114
105
 
@@ -46,4 +46,36 @@ describe Gull::Client do
46
46
  expect(alerts.size).to eq 0
47
47
  expect(client.errors.size).to eq 1
48
48
  end
49
+
50
+ it 'should raise own error if timeout occurs' do
51
+ stub_request(:get, 'http://alerts.weather.gov/cap/us.php?x=1')
52
+ .with(headers: { 'Accept' => '*/*' })
53
+ .to_timeout
54
+
55
+ message = 'Timeout while connecting to NWS web service'
56
+ client = Gull::Client.new
57
+ expect { client.fetch }.to raise_error(Gull::TimeoutError, message)
58
+ end
59
+
60
+ it 'should raise own error if http error occurs' do
61
+ stub_request(:get, 'http://alerts.weather.gov/cap/us.php?x=1')
62
+ .with(headers: { 'Accept' => '*/*' })
63
+ .to_raise(HTTPClient::KeepAliveDisconnected)
64
+
65
+ message = 'HTTP error while connecting to NWS web service'
66
+ client = Gull::Client.new
67
+ expect { client.fetch }.to raise_error(Gull::HttpError, message) do |error|
68
+ expect(error.original).to be_a(HTTPClient::KeepAliveDisconnected)
69
+ end
70
+
71
+ stub_request(:get, 'http://alerts.weather.gov/cap/us.php?x=1')
72
+ .with(headers: { 'Accept' => '*/*' })
73
+ .to_raise(SocketError)
74
+
75
+ message = 'HTTP error while connecting to NWS web service'
76
+ client = Gull::Client.new
77
+ expect { client.fetch }.to raise_error(Gull::HttpError, message) do |error|
78
+ expect(error.original).to be_a(SocketError)
79
+ end
80
+ end
49
81
  end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gull::HttpError do
4
+ it 'should instantiate and set original with current exception' do
5
+ error = StandardError.new 'inner'
6
+ begin
7
+ fail error
8
+ rescue StandardError
9
+ http_error = Gull::HttpError.new 'test'
10
+ expect(http_error.original).to eq error
11
+ expect(http_error.original.message). to eq 'inner'
12
+ end
13
+ end
14
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gull
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Deckard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-23 00:00:00.000000000 Z
11
+ date: 2015-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -120,9 +120,10 @@ files:
120
120
  - lib/gull/polygon.rb
121
121
  - lib/gull/version.rb
122
122
  - spec/alert_spec.rb
123
+ - spec/client_spec.rb
124
+ - spec/error_spec.rb
123
125
  - spec/fixtures/alerts.xml
124
126
  - spec/fixtures/bad.xml
125
- - spec/fixtures/client_spec.rb
126
127
  - spec/fixtures/empty.xml
127
128
  - spec/fixtures/missing_cap.xml
128
129
  - spec/polygon_spec.rb
@@ -153,9 +154,10 @@ specification_version: 4
153
154
  summary: Client for parsing NOAA/NWS alerts, warnings, and watches.
154
155
  test_files:
155
156
  - spec/alert_spec.rb
157
+ - spec/client_spec.rb
158
+ - spec/error_spec.rb
156
159
  - spec/fixtures/alerts.xml
157
160
  - spec/fixtures/bad.xml
158
- - spec/fixtures/client_spec.rb
159
161
  - spec/fixtures/empty.xml
160
162
  - spec/fixtures/missing_cap.xml
161
163
  - spec/polygon_spec.rb