gull 0.2.12 → 0.2.13
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 +4 -4
- data/CHANGELOG.md +2 -0
- data/lib/gull/alert.rb +15 -2
- data/lib/gull/version.rb +1 -1
- data/spec/alert_spec.rb +11 -0
- data/spec/fixtures/missing_cap.xml +56 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7841c6854343d87ee16705b0606bea985d8d27cf
|
4
|
+
data.tar.gz: 1102c41588ddeab4435d344420e47c1ba0b09956
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc13ad4a90732adcde90db23e27c948306f98ac8a23fe6a3726446627708be4803bd4d475396e2ebe156692cfd1d14f20d57165f80784288961ef0cc2ad4fd8f
|
7
|
+
data.tar.gz: 73965ce13979a9ba0962a845f86f86797b78bb6811541a69f9dfd889c7423407c5d57b6a061917580c8753148dab20a21f94622b871e926edfa8f9c91993c0ad
|
data/CHANGELOG.md
CHANGED
data/lib/gull/alert.rb
CHANGED
@@ -18,7 +18,7 @@ module Gull
|
|
18
18
|
|
19
19
|
content = response options
|
20
20
|
document = Nokogiri::XML content
|
21
|
-
process document.
|
21
|
+
process document.xpath('//xmlns:feed/xmlns:entry', namespaces)
|
22
22
|
end
|
23
23
|
|
24
24
|
def parse(element)
|
@@ -33,6 +33,16 @@ module Gull
|
|
33
33
|
|
34
34
|
private
|
35
35
|
|
36
|
+
def self.namespaces
|
37
|
+
{ 'xmlns' => 'http://www.w3.org/2005/Atom',
|
38
|
+
'cap' => 'urn:oasis:names:tc:emergency:cap:1.1',
|
39
|
+
'ha' => 'http://www.alerting.net/namespace/index_1.0' }
|
40
|
+
end
|
41
|
+
|
42
|
+
def namespaces
|
43
|
+
Alert.namespaces
|
44
|
+
end
|
45
|
+
|
36
46
|
def self.response(options)
|
37
47
|
client = HTTPClient.new
|
38
48
|
begin
|
@@ -45,13 +55,16 @@ module Gull
|
|
45
55
|
def self.process(entries)
|
46
56
|
alerts = []
|
47
57
|
entries.each do |entry|
|
48
|
-
|
58
|
+
alert = create_instance entry
|
59
|
+
alerts.push alert unless alert.nil?
|
49
60
|
end
|
50
61
|
|
51
62
|
alerts
|
52
63
|
end
|
53
64
|
|
54
65
|
def self.create_instance(entry)
|
66
|
+
return if entry.xpath('cap:event').empty?
|
67
|
+
|
55
68
|
alert = Alert.new
|
56
69
|
alert.parse entry
|
57
70
|
alert
|
data/lib/gull/version.rb
CHANGED
data/spec/alert_spec.rb
CHANGED
@@ -97,4 +97,15 @@ describe Gull::Alert do
|
|
97
97
|
expect { Gull::Alert.fetch }
|
98
98
|
.to raise_error(Gull::TimeoutError, message)
|
99
99
|
end
|
100
|
+
|
101
|
+
it 'should handle missing cap section' do
|
102
|
+
xml = File.read 'spec/fixtures/missing_cap.xml'
|
103
|
+
|
104
|
+
stub_request(:get, 'http://alerts.weather.gov/cap/us.php?x=1')
|
105
|
+
.with(headers: { 'Accept' => '*/*' })
|
106
|
+
.to_return(status: 200, body: xml, headers: {})
|
107
|
+
|
108
|
+
alerts = Gull::Alert.fetch
|
109
|
+
expect(alerts.size).to eq 0
|
110
|
+
end
|
100
111
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
|
2
|
+
<?xml version = '1.0' encoding = 'UTF-8' standalone = 'yes'?>
|
3
|
+
<?xml-stylesheet href='http://alerts.weather.gov/cap/capatom.xsl' type='text/xsl'?>
|
4
|
+
|
5
|
+
<!--
|
6
|
+
This atom/xml feed is an index to active advisories, watches and warnings
|
7
|
+
issued by the National Weather Service. This index file is not the complete
|
8
|
+
Common Alerting Protocol (CAP) alert message. To obtain the complete CAP
|
9
|
+
alert, please follow the links for each entry in this index. Also note the
|
10
|
+
CAP message uses a style sheet to convey the information in a human readable
|
11
|
+
format. Please view the source of the CAP message to see the complete data
|
12
|
+
set. Not all information in the CAP message is contained in this index of
|
13
|
+
active alerts.
|
14
|
+
-->
|
15
|
+
|
16
|
+
|
17
|
+
<feed
|
18
|
+
xmlns = 'http://www.w3.org/2005/Atom'
|
19
|
+
xmlns:cap = 'urn:oasis:names:tc:emergency:cap:1.1'
|
20
|
+
xmlns:ha = 'http://www.alerting.net/namespace/index_1.0'
|
21
|
+
>
|
22
|
+
<!-- http-date = Sat, 20 Jun 2015 01:23:00 GMT -->
|
23
|
+
|
24
|
+
<id>http://alerts.weather.gov/cap/us.atom</id>
|
25
|
+
<logo>http://alerts.weather.gov/images/xml_logo.gif</logo>
|
26
|
+
<generator>NWS CAP Server</generator>
|
27
|
+
<updated>2015-06-20T08:23:00-05:00</updated>
|
28
|
+
<author>
|
29
|
+
<name>w-nws.webmaster@noaa.gov</name>
|
30
|
+
</author>
|
31
|
+
<title>Current Watches, Warnings and Advisories for the United States Issued by the National Weather Service</title>
|
32
|
+
<link href='http://alerts.weather.gov/cap/us.atom'/>
|
33
|
+
|
34
|
+
<entry>
|
35
|
+
<id>http://alerts.weather.gov/cap/wwacapget.php?x=LA1253AE8E0B98.FloodWarning.1253AEBAFBE4LA.SHVFLSSHV.3908c4d415c0ed7efa65ce2f6eea425e</id>
|
36
|
+
<updated>2015-06-20T08:02:00-05:00</updated>
|
37
|
+
<published>2015-06-20T08:02:00-05:00</published>
|
38
|
+
<author>
|
39
|
+
<name>w-nws.webmaster@noaa.gov</name>
|
40
|
+
</author>
|
41
|
+
<title>Flood Warning issued June 20 at 8:02AM CDT until June 23 at 2:53AM CDT by NWS</title>
|
42
|
+
<link href='http://alerts.weather.gov/cap/wwacapget.php?x=LA1253AE8E0B98.FloodWarning.1253AEBAFBE4LA.SHVFLSSHV.3908c4d415c0ed7efa65ce2f6eea425e'/>
|
43
|
+
<summary>The flood warning continues for the Red Chute Bayou At Sligo, Louisiana. * until late Monday night...or until the warning is cancelled. * At 70 AM Saturday the stage was 32.0 feet. * Minor flooding is occurring and minor flooding is forecast. * Flood stage is 31 feet.</summary>
|
44
|
+
<valueName>FIPS6</valueName>
|
45
|
+
<value>022013 022015</value>
|
46
|
+
<valueName>UGC</valueName>
|
47
|
+
<value>LAC013 LAC015</value>
|
48
|
+
</cap:geocode>
|
49
|
+
<cap:parameter>
|
50
|
+
<valueName>VTEC</valueName>
|
51
|
+
<value>/O.EXT.KSHV.FL.W.0168.000000T0000Z-150623T0753Z/
|
52
|
+
/SLGL1.1.ER.150618T1228Z.150619T1330Z.150622T1353Z.NO/</value>
|
53
|
+
</cap:parameter>
|
54
|
+
</entry>
|
55
|
+
|
56
|
+
</feed>
|
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.2.
|
4
|
+
version: 0.2.13
|
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-
|
11
|
+
date: 2015-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- spec/fixtures/alerts.xml
|
123
123
|
- spec/fixtures/bad.xml
|
124
124
|
- spec/fixtures/empty.xml
|
125
|
+
- spec/fixtures/missing_cap.xml
|
125
126
|
- spec/polygon_spec.rb
|
126
127
|
- spec/spec_helper.rb
|
127
128
|
homepage: https://github.com/sethdeckard/gull
|
@@ -153,5 +154,6 @@ test_files:
|
|
153
154
|
- spec/fixtures/alerts.xml
|
154
155
|
- spec/fixtures/bad.xml
|
155
156
|
- spec/fixtures/empty.xml
|
157
|
+
- spec/fixtures/missing_cap.xml
|
156
158
|
- spec/polygon_spec.rb
|
157
159
|
- spec/spec_helper.rb
|