gull 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +2 -0
- data/Guardfile +5 -0
- data/README.md +10 -3
- data/gull.gemspec +1 -1
- data/lib/gull/alert.rb +3 -1
- data/lib/gull/version.rb +1 -1
- data/spec/alert_spec.rb +9 -4
- data/spec/fixtures/alerts.xml +9 -13
- data/spec/spec_helper.rb +2 -2
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e31bf5dcc237447beaebab3385d8d87b2615d88
|
4
|
+
data.tar.gz: c123ff556c38b50041abd35bf2211406a4da70cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 014efe76f247bbdcb3a2159617ce700c5b291b141071f6cb74a546ee93a8126264128f0858ba15d882f2bbdd05a1a7ddb976d6a7a4131367aabdf9138006901b
|
7
|
+
data.tar.gz: 21a3d3fe3471ff03773a6958ed6af9908f198d284259b809e77f89a6219f1d21c14216304eb36f3b96d96b182162acccd1a8ad208f1c58aab321b98068ce09e9
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.3
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Guardfile
ADDED
data/README.md
CHANGED
@@ -50,12 +50,14 @@ alert.vtec
|
|
50
50
|
```
|
51
51
|
|
52
52
|
To get alerts for a single state, territory, or marine zone just pass an optional URL
|
53
|
+
|
53
54
|
```ruby
|
54
55
|
oklahoma_url = 'http://alerts.weather.gov/cap/ok.php?x=1'
|
55
56
|
alerts = Gull::Alert.fetch(url: oklahoma_url)
|
56
57
|
```
|
57
58
|
|
58
59
|
You can also generate a map (a really long URL pointing to a map) of the polygon if alert has one (requires Google Static Maps API Key)
|
60
|
+
|
59
61
|
```ruby
|
60
62
|
alert.polygon.image_url 'YOUR_GOOGLE_API_KEY'
|
61
63
|
|
@@ -63,6 +65,7 @@ alert.polygon.image_url 'YOUR_GOOGLE_API_KEY'
|
|
63
65
|
```
|
64
66
|
|
65
67
|
Options can be passed for map to override defaults
|
68
|
+
|
66
69
|
```ruby
|
67
70
|
options = { width: 600, height: 300, color: '0xfbf000', weight: 4,
|
68
71
|
fillcolor: '0xfbf00070', maptype: 'hybrid' }
|
@@ -70,15 +73,19 @@ alert.polygon.image_url 'YOUR_GOOGLE_API_KEY', options
|
|
70
73
|
```
|
71
74
|
|
72
75
|
Get the centroid of the polygon (to display a map pin, etc.)
|
76
|
+
|
73
77
|
```ruby
|
74
78
|
alert.polygon.centroid
|
75
79
|
|
76
80
|
=> [34.835, -91.205]
|
77
81
|
```
|
78
82
|
|
79
|
-
##Notes
|
80
|
-
|
83
|
+
##Notes, Caveats
|
84
|
+
This library provides a simplified/flattened model of the [Common Alerting Protocol](http://docs.oasis-open.org/emergency/cap/v1.2/CAP-v1.2-os.html) based only on the elements NWS utilizes in their public RSS feeds. If you need a complete CAP parser I suggest looking at [RCAP](https://github.com/farrel/RCAP).
|
85
|
+
|
86
|
+
The NWS will often cancel or update alerts before their expiration time. The public alert feed only provides current active alerts and does not include these separate update and cancellation CAP messages. If you're persisting these alerts you need to design for this scenario.
|
81
87
|
|
88
|
+
The public RSS feeds are not always reliable, if you are using this for critical purposes then you should explore other options.
|
82
89
|
|
83
90
|
### Urgency
|
84
91
|
|
@@ -115,7 +122,7 @@ The NWS will sometimes expire warnings before their expiration date/time, for ex
|
|
115
122
|
|
116
123
|
1. Fork it ( https://github.com/sethdeckard/gull/fork )
|
117
124
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
118
|
-
3. Run the specs, make sure they pass and that new features are covered
|
125
|
+
3. Run the specs, make sure they pass and that new features are covered. Code coverage should be 100%.
|
119
126
|
4. Commit your changes (`git commit -am 'Add some feature'`)
|
120
127
|
5. Push to the branch (`git push origin my-new-feature`)
|
121
128
|
6. Create a new Pull Request
|
data/gull.gemspec
CHANGED
@@ -23,6 +23,6 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler', '>= 1.6'
|
25
25
|
spec.add_development_dependency 'rake'
|
26
|
-
spec.add_development_dependency 'rspec', '>=
|
26
|
+
spec.add_development_dependency 'rspec', '>= 3.0'
|
27
27
|
spec.add_development_dependency 'webmock'
|
28
28
|
end
|
data/lib/gull/alert.rb
CHANGED
@@ -63,6 +63,8 @@ module Gull
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def parse_geocode(element)
|
66
|
+
return if element.children.css('value').first.nil?
|
67
|
+
|
66
68
|
geocode.fips6 = element.children.css('value').first.inner_text
|
67
69
|
geocode.ugc = element.children.css('value').last.inner_text
|
68
70
|
end
|
@@ -73,7 +75,7 @@ module Gull
|
|
73
75
|
end
|
74
76
|
|
75
77
|
def code_to_symbol(code)
|
76
|
-
code.
|
78
|
+
code.tr(' ', '_').downcase.to_sym
|
77
79
|
end
|
78
80
|
end
|
79
81
|
end
|
data/lib/gull/version.rb
CHANGED
data/spec/alert_spec.rb
CHANGED
@@ -40,15 +40,20 @@ describe Gull::Alert do
|
|
40
40
|
expect(first.severity).to eq :minor
|
41
41
|
expect(first.certainty).to eq :very_likely
|
42
42
|
|
43
|
-
expect(first.geocode.fips6).to
|
44
|
-
|
45
|
-
expect(first.geocode.ugc).to eq 'CAZ006 CAZ505 CAZ506 CAZ507 CAZ508 ' \
|
46
|
-
'CAZ509 CAZ510 CAZ511 CAZ512'
|
43
|
+
expect(first.geocode.fips6).to be_nil
|
44
|
+
expect(first.geocode.ugc).to be_nil
|
47
45
|
|
48
46
|
expect(first.vtec).to eq '/O.NEW.KMTR.HT.Y.0002.141002T1900Z-141004T0400Z/'
|
49
47
|
|
50
48
|
second = alerts[1]
|
51
49
|
expect(second.polygon).to be_nil
|
50
|
+
|
51
|
+
expect(second.geocode.fips6).to eq '006001 006013 006041 006053 006055 ' \
|
52
|
+
'006069 006075 006081 006085 006087 006097'
|
53
|
+
expect(second.geocode.ugc).to eq 'CAZ006 CAZ505 CAZ506 CAZ507 CAZ508 ' \
|
54
|
+
'CAZ509 CAZ510 CAZ511 CAZ512 CAZ513 CAZ516 CAZ517 CAZ518 CAZ528 ' \
|
55
|
+
'CAZ529 CAZ530'
|
56
|
+
|
52
57
|
expect(second.vtec).to be_nil
|
53
58
|
|
54
59
|
third = alerts[2]
|
data/spec/fixtures/alerts.xml
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
<?xml version = '1.0' encoding = 'UTF-8' standalone = 'yes'?>
|
2
2
|
|
3
3
|
<!--
|
4
|
-
This atom/xml feed is an index to active advisories, watches and warnings
|
5
|
-
issued by the National Weather Service. This index file is not the complete
|
6
|
-
Common Alerting Protocol (CAP) alert message. To obtain the complete CAP
|
7
|
-
alert, please follow the links for each entry in this index. Also note the
|
8
|
-
CAP message uses a style sheet to convey the information in a human readable
|
9
|
-
format. Please view the source of the CAP message to see the complete data
|
10
|
-
set. Not all information in the CAP message is contained in this index of
|
4
|
+
This atom/xml feed is an index to active advisories, watches and warnings
|
5
|
+
issued by the National Weather Service. This index file is not the complete
|
6
|
+
Common Alerting Protocol (CAP) alert message. To obtain the complete CAP
|
7
|
+
alert, please follow the links for each entry in this index. Also note the
|
8
|
+
CAP message uses a style sheet to convey the information in a human readable
|
9
|
+
format. Please view the source of the CAP message to see the complete data
|
10
|
+
set. Not all information in the CAP message is contained in this index of
|
11
11
|
active alerts.
|
12
12
|
-->
|
13
13
|
|
@@ -50,17 +50,13 @@ xmlns:ha = 'http://www.alerting.net/namespace/index_1.0'
|
|
50
50
|
<cap:areaDesc>Southern Salinas Valley, Arroyo Seco and Lake San Antonio</cap:areaDesc>
|
51
51
|
<cap:polygon>27.35,-81.79 27.14,-81.89 27.04,-81.97 27.04,-82.02 27.14,-81.97 27.35,-81.86 27.35,-81.79</cap:polygon>
|
52
52
|
<cap:geocode>
|
53
|
-
<valueName>FIPS6</valueName>
|
54
|
-
<value>006001 006013 006041 006053 006055 006069 006075 006081 006085 006087 006097</value>
|
55
|
-
<valueName>UGC</valueName>
|
56
|
-
<value>CAZ006 CAZ505 CAZ506 CAZ507 CAZ508 CAZ509 CAZ510 CAZ511 CAZ512</value>
|
57
53
|
</cap:geocode>
|
58
54
|
<cap:parameter>
|
59
55
|
<valueName>VTEC</valueName>
|
60
56
|
<value>/O.NEW.KMTR.HT.Y.0002.141002T1900Z-141004T0400Z/</value>
|
61
57
|
</cap:parameter>
|
62
58
|
</entry>
|
63
|
-
|
59
|
+
|
64
60
|
<entry>
|
65
61
|
<id>http://alerts.weather.gov/cap/wwacapget.php?x=CA125171381DD0.HeatAdvisory.125171642740CA.MTRNPWMTR.64d60221994d798a87b4862623e0d63c</id>
|
66
62
|
<updated>2014-10-01T08:40:00-07:00</updated>
|
@@ -119,4 +115,4 @@ xmlns:ha = 'http://www.alerting.net/namespace/index_1.0'
|
|
119
115
|
<value>CAZ006 CAZ505 CAZ506 CAZ507 CAZ508 CAZ509 CAZ510 CAZ511 CAZ512 CAZ513 CAZ516 CAZ517 CAZ518 CAZ528 CAZ529 CAZ530</value>
|
120
116
|
</cap:geocode>
|
121
117
|
</entry>
|
122
|
-
</feed>
|
118
|
+
</feed>
|
data/spec/spec_helper.rb
CHANGED
@@ -3,10 +3,10 @@ require 'coveralls'
|
|
3
3
|
require 'simplecov'
|
4
4
|
require 'webmock/rspec'
|
5
5
|
|
6
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
6
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
7
7
|
SimpleCov::Formatter::HTMLFormatter,
|
8
8
|
Coveralls::SimpleCov::Formatter
|
9
|
-
]
|
9
|
+
])
|
10
10
|
SimpleCov.start
|
11
11
|
|
12
12
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
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.
|
4
|
+
version: 0.3.4
|
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-
|
11
|
+
date: 2015-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '3.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '3.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: webmock
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,9 +105,11 @@ files:
|
|
105
105
|
- ".hound.yml"
|
106
106
|
- ".rspec"
|
107
107
|
- ".rubocop.yml"
|
108
|
+
- ".ruby-version"
|
108
109
|
- ".travis.yml"
|
109
110
|
- CHANGELOG.md
|
110
111
|
- Gemfile
|
112
|
+
- Guardfile
|
111
113
|
- LICENSE.txt
|
112
114
|
- README.md
|
113
115
|
- Rakefile
|
@@ -148,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
150
|
version: '0'
|
149
151
|
requirements: []
|
150
152
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.4.5
|
153
|
+
rubygems_version: 2.4.5.1
|
152
154
|
signing_key:
|
153
155
|
specification_version: 4
|
154
156
|
summary: Client for parsing NOAA/NWS alerts, warnings, and watches.
|