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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da54d6cfb08b76036d97ad90f22c636afadd4854
4
- data.tar.gz: 96967ecefbb71ce965a1dd4cda9a32ccedb97d81
3
+ metadata.gz: 8e31bf5dcc237447beaebab3385d8d87b2615d88
4
+ data.tar.gz: c123ff556c38b50041abd35bf2211406a4da70cc
5
5
  SHA512:
6
- metadata.gz: 0b6474304998d1f817affbf50900c192c2ef2de8276ba51f9d5329ce0642bf4daa5c8a81ac0a9af74fc138c7db740dcbcd817de6ec99d27348ded7fe0beed952
7
- data.tar.gz: eee354c3c0477622cf3c44463b5d17959adb81d525bad64f8e604be0dcefe7a2b21c67c8c09c3daf26359dcd598bfd2439a2c5c0c709e8fc0acf9025a1823f00
6
+ metadata.gz: 014efe76f247bbdcb3a2159617ce700c5b291b141071f6cb74a546ee93a8126264128f0858ba15d882f2bbdd05a1a7ddb976d6a7a4131367aabdf9138006901b
7
+ data.tar.gz: 21a3d3fe3471ff03773a6958ed6af9908f198d284259b809e77f89a6219f1d21c14216304eb36f3b96d96b182162acccd1a8ad208f1c58aab321b98068ce09e9
@@ -0,0 +1 @@
1
+ 2.2.3
@@ -1,3 +1,6 @@
1
+ #### 0.3.4 (12/16/2015)
2
+ Fixed parser to handle empty geocode.
3
+
1
4
  #### 0.3.3 (11/25/2015)
2
5
  Handle additional service failure scenarios.
3
6
  ***
data/Gemfile CHANGED
@@ -4,4 +4,6 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'coveralls', require: false
7
+ gem 'guard'
8
+ gem 'guard-rspec', require: false
7
9
  gem 'simplecov', require: false
@@ -0,0 +1,5 @@
1
+ guard :rspec, cmd: 'bundle exec rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { 'spec' }
5
+ end
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
- The NWS will sometimes expire warnings before their expiration date/time, for example if they are reissuing a tornado warning by redefining the polygon area. This new warning will have it's own unique ID and the warning that it replaced will no longer exist in the results. So it's important when fetching new warnings to compare the active warnings from your previous call to fetch and if any active warnings are missing in the new results you should consider them expired. Otherwise you could end up with extra active warnings where perhaps just the warning text or polygon varies a little.
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
@@ -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', '>= 2.11'
26
+ spec.add_development_dependency 'rspec', '>= 3.0'
27
27
  spec.add_development_dependency 'webmock'
28
28
  end
@@ -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.gsub(' ', '_').downcase.to_sym
78
+ code.tr(' ', '_').downcase.to_sym
77
79
  end
78
80
  end
79
81
  end
@@ -1,3 +1,3 @@
1
1
  module Gull
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.4'
3
3
  end
@@ -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 eq '006001 006013 006041 006053 006055 ' \
44
- '006069 006075 006081 006085 006087 006097'
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]
@@ -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>
@@ -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.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-25 00:00:00.000000000 Z
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: '2.11'
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: '2.11'
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.