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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e86081d360eca93b4a9d0dbe5185bc6a248a6a1
4
- data.tar.gz: 336895cd8f897425e987779c2168c5ed1a065f4f
3
+ metadata.gz: abbfea59f3e20194da7602da330d7d17304add4b
4
+ data.tar.gz: 4469f2c218b7483b039b8404bf90a03a47a99e9e
5
5
  SHA512:
6
- metadata.gz: 8da6e8b46feb22d5b611d4e17387830fbcab34bb8195e4101d3162cbee41c23b5bf800ab662eaf24745928bee7a43164935c055d7bd82dc198868607e833ae23
7
- data.tar.gz: 3a985d7754a0d7229fec1cac7ba50ac71315a8c48a76eebfeb468543ba37ec2c835eddc8947634bd066f3b177d30a98b4c7aa8b389f34f1e476e02ba6e4ede4d
6
+ metadata.gz: 1157f36b6ba261f2f91077b6e016b65eb3b782038af7da83e7af7464b1612d846b860fab672e2328bb816cf8b59aff02b8671363771a547954568c1137e0d89c
7
+ data.tar.gz: 5cbfa92c6fbd6de9806f73f5791097506969ee72f5eff576def3dfd58a361a1985a65d383800f7e08025f6a76df15e739481d80c3ed5c42d2035823e56b7a527
@@ -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
- gem 'gull'
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
- require 'gull'
28
-
29
- alerts = Gull::Alert.fetch
30
- alert = alert.first
31
-
32
- #access details of alert
33
- alert.id
34
- alert.alert_type
35
- alert.title
36
- alert.summary
37
- alert.effective_at
38
- alert.expires_at
39
- alert.area
40
- alert.geocode.fips6
41
- alert.geocode.ugc
42
- alert.urgency
43
- alert.severity
44
- alert.certainty
45
- #etc...
46
-
47
- #You can also generate a map of the polygon if alert has one (requires Google Static Maps API Key)
48
- alert.polygon.image_url "your_api_key"
49
-
50
- => "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_api_key"
51
-
52
- #options can be passed for map to override defaults
53
- options = { :width => 600, :height => 300, :color => "0xfbf000", :weight => 4, :fillcolor => "0xfbf00070", :maptype => "hybrid" }
54
- alert.polygon.image_url "your_api_key", options
55
-
56
- #get the centroid of the polygon (to display a map pin, etc.)
57
- alert.polygon.centroid
58
-
59
- => [34.835, -91.205]
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.
@@ -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).utc
71
- self.published_at = Time.parse(element.css('published').inner_text).utc
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
- .utc
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)
@@ -47,6 +47,10 @@ module Gull
47
47
  "|#{coordinates_piped}&key=#{api_key}"
48
48
  end
49
49
 
50
+ def to_s
51
+ coordinates.map { |pair| pair.join(',') }.join(' ')
52
+ end
53
+
50
54
  private
51
55
 
52
56
  def bounds(point, low, high)
@@ -1,3 +1,3 @@
1
1
  module Gull
2
- VERSION = '0.2.10'
2
+ VERSION = '0.2.11'
3
3
  end
@@ -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.10
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-03-23 00:00:00.000000000 Z
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.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.