gull 0.2.10 → 0.2.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +52 -34
- data/lib/gull/alert.rb +3 -4
- data/lib/gull/polygon.rb +4 -0
- data/lib/gull/version.rb +1 -1
- data/spec/polygon_spec.rb +8 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abbfea59f3e20194da7602da330d7d17304add4b
|
4
|
+
data.tar.gz: 4469f2c218b7483b039b8404bf90a03a47a99e9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1157f36b6ba261f2f91077b6e016b65eb3b782038af7da83e7af7464b1612d846b860fab672e2328bb816cf8b59aff02b8671363771a547954568c1137e0d89c
|
7
|
+
data.tar.gz: 5cbfa92c6fbd6de9806f73f5791097506969ee72f5eff576def3dfd58a361a1985a65d383800f7e08025f6a76df15e739481d80c3ed5c42d2035823e56b7a527
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
***
|
2
|
+
### 0.2.10 (3/23/2015) - Added option to override default alert service URI.
|
3
|
+
***
|
4
|
+
### 0.2.1 (10/02/2014) - Added static map image to polygons.
|
5
|
+
***
|
6
|
+
#### 0.2.0 (10/02/2014) - Introduced Polygon type.
|
7
|
+
***
|
8
|
+
#### 0.1.1 (10/01/2014) - Refectored and simplfied alert processing.
|
9
|
+
***
|
10
|
+
#### 0.1.0 (10/01/2014) - Initial release, basic functionality of fetching and parsing alerts.
|
data/README.md
CHANGED
@@ -12,7 +12,9 @@ Ruby client for parsing NOAA/NWS alerts, warnings, and watches. The name comes f
|
|
12
12
|
|
13
13
|
Add this line to your application's Gemfile:
|
14
14
|
|
15
|
-
|
15
|
+
```ruby
|
16
|
+
gem 'gull'
|
17
|
+
```
|
16
18
|
|
17
19
|
And then execute:
|
18
20
|
|
@@ -24,39 +26,55 @@ Or install it yourself as:
|
|
24
26
|
|
25
27
|
## Usage
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
29
|
+
```ruby
|
30
|
+
require 'gull'
|
31
|
+
|
32
|
+
alerts = Gull::Alert.fetch
|
33
|
+
alert = alerts.first
|
34
|
+
|
35
|
+
alert.id
|
36
|
+
alert.alert_type
|
37
|
+
alert.title
|
38
|
+
alert.summary
|
39
|
+
alert.effective_at
|
40
|
+
alert.expires_at
|
41
|
+
alert.published_at
|
42
|
+
alert.area
|
43
|
+
alert.polygon
|
44
|
+
alert.geocode.fips6
|
45
|
+
alert.geocode.ugc
|
46
|
+
alert.urgency
|
47
|
+
alert.severity
|
48
|
+
alert.certainty
|
49
|
+
alert.vtec
|
50
|
+
```
|
51
|
+
|
52
|
+
To get alerts for a single state, territory, or marine zone just pass an optional URL
|
53
|
+
```ruby
|
54
|
+
oklahoma_url = 'http://alerts.weather.gov/cap/ok.php?x=1'
|
55
|
+
alerts = Gull::Alert.fetch(url: oklahoma_url)
|
56
|
+
```
|
57
|
+
|
58
|
+
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)
|
59
|
+
```ruby
|
60
|
+
alert.polygon.image_url 'YOUR_GOOGLE_API_KEY'
|
61
|
+
|
62
|
+
=> "http://maps.googleapis.com/maps/api/staticmap?size=640x640&maptype=roadmap&path=color:0xff0000|weight:3|fillcolor:0xff000060|38.73,-94.22|38.75,-94.16|38.57,-93.94|38.4,-93.84|38.4,-93.91|38.73,-94.22&key=YOUR_GOOGLE_API_KEY"
|
63
|
+
```
|
64
|
+
|
65
|
+
Options can be passed for map to override defaults
|
66
|
+
```ruby
|
67
|
+
options = { width: 600, height: 300, color: '0xfbf000', weight: 4,
|
68
|
+
fillcolor: '0xfbf00070', maptype: 'hybrid' }
|
69
|
+
alert.polygon.image_url 'YOUR_GOOGLE_API_KEY', options
|
70
|
+
```
|
71
|
+
|
72
|
+
Get the centroid of the polygon (to display a map pin, etc.)
|
73
|
+
```ruby
|
74
|
+
alert.polygon.centroid
|
75
|
+
|
76
|
+
=> [34.835, -91.205]
|
77
|
+
```
|
60
78
|
|
61
79
|
##Notes
|
62
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.
|
data/lib/gull/alert.rb
CHANGED
@@ -67,11 +67,10 @@ module Gull
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def parse_times(element)
|
70
|
-
self.updated_at = Time.parse(element.css('updated').inner_text)
|
71
|
-
self.published_at = Time.parse(element.css('published').inner_text)
|
70
|
+
self.updated_at = Time.parse(element.css('updated').inner_text)
|
71
|
+
self.published_at = Time.parse(element.css('published').inner_text)
|
72
72
|
self.effective_at = Time.parse(element.xpath('cap:effective').inner_text)
|
73
|
-
|
74
|
-
self.expires_at = Time.parse(element.xpath('cap:expires').inner_text).utc
|
73
|
+
self.expires_at = Time.parse(element.xpath('cap:expires').inner_text)
|
75
74
|
end
|
76
75
|
|
77
76
|
def parse_categories(element)
|
data/lib/gull/polygon.rb
CHANGED
data/lib/gull/version.rb
CHANGED
data/spec/polygon_spec.rb
CHANGED
@@ -40,4 +40,12 @@ describe Gull::Polygon do
|
|
40
40
|
'&key=testkey'
|
41
41
|
expect(url).to eq expected_url
|
42
42
|
end
|
43
|
+
|
44
|
+
it 'should return original string representation' do
|
45
|
+
text = '34.57,-97.56 34.77,-97.38 34.75,-97.17 ' \
|
46
|
+
'34.64,-97.11 34.64,-97.14 34.62,-97.14 34.62,-97.2 34.6,-97.19 34.59,' \
|
47
|
+
'-97.17 34.57,-97.17 34.5,-97.3 34.51,-97.56 34.57,-97.56'
|
48
|
+
polygon = Gull::Polygon.new text
|
49
|
+
expect(polygon.to_s).to eq text
|
50
|
+
end
|
43
51
|
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.2.
|
4
|
+
version: 0.2.11
|
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-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- ".rspec"
|
107
107
|
- ".rubocop.yml"
|
108
108
|
- ".travis.yml"
|
109
|
+
- CHANGELOG.md
|
109
110
|
- Gemfile
|
110
111
|
- LICENSE.txt
|
111
112
|
- README.md
|
@@ -143,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
144
|
version: '0'
|
144
145
|
requirements: []
|
145
146
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.4.
|
147
|
+
rubygems_version: 2.4.5
|
147
148
|
signing_key:
|
148
149
|
specification_version: 4
|
149
150
|
summary: Client for parsing NOAA/NWS alerts, warnings, and watches.
|