gull 0.3.4 → 0.4.0

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: 8e31bf5dcc237447beaebab3385d8d87b2615d88
4
- data.tar.gz: c123ff556c38b50041abd35bf2211406a4da70cc
3
+ metadata.gz: 499056dd7d0dfaf61fd26893aac65a8f8b2f802f
4
+ data.tar.gz: 989cda9df71c6d5fc5d31c3ae9c4ff6a26e7ff7b
5
5
  SHA512:
6
- metadata.gz: 014efe76f247bbdcb3a2159617ce700c5b291b141071f6cb74a546ee93a8126264128f0858ba15d882f2bbdd05a1a7ddb976d6a7a4131367aabdf9138006901b
7
- data.tar.gz: 21a3d3fe3471ff03773a6958ed6af9908f198d284259b809e77f89a6219f1d21c14216304eb36f3b96d96b182162acccd1a8ad208f1c58aab321b98068ce09e9
6
+ metadata.gz: 7b86f770036bbae32dd13ad68d793fc62043bbf199d3e980cdb92455e26c0498a952d1212a5af69ec26403377da32edce66ee2efdfa68d4e5249a6dc23a5ed35
7
+ data.tar.gz: ffe0a676c31958d1c51c25a50a1be6d13046ba88689f734ec4a82112062c4d87e4c5cc6ef6abb52751689e3879a14e15d5d0f4d7fdd532e125eade99e47ff140
@@ -1 +1 @@
1
- 2.2.3
1
+ 2.3.1
@@ -1,8 +1,7 @@
1
1
  language: ruby
2
- sudo: false
2
+ sudo: true
3
3
  rvm:
4
- - 2.2.3
5
- - 2.1.7
6
- - 2.0.0
4
+ - 2.3.1
5
+ - 2.2.5
7
6
 
8
7
  script: rspec spec
@@ -1,38 +1,53 @@
1
- #### 0.3.4 (12/16/2015)
2
- Fixed parser to handle empty geocode.
1
+ 0.4.0 (07/26/2016) - Merged pull request #2 from [schrockwell](https://github.com/schrockwell), which adds `to_wkt` to `Polygon` which formats the polygon points as Well-Known Text (WKT). Removed `centroid` method, use new `to_wkt` method with an external geospatial library instead.
3
2
 
4
- #### 0.3.3 (11/25/2015)
5
- Handle additional service failure scenarios.
6
3
  ***
7
- #### 0.3.2 (11/10/2015)
8
- Added BadResponseError to client error handling.
4
+
5
+ 0.3.4 (12/16/2015) - Fixed parser to handle empty geocode.
6
+
9
7
  ***
10
- #### 0.3.1 (6/25/2015)
11
- Added nested error handling for other HTTPClient errors. HttpError has original attribute exposing the root error.
8
+
9
+ 0.3.3 (11/25/2015) - Handle additional service failure scenarios.
10
+
12
11
  ***
13
- #### 0.3.0 (6/23/2015)
14
- Added Client class for error handling (bad entries accessed via errors array). Exposed option to turn on strict XML parsing for debugging. Alert.fetch uses new Client but is backwards compatible, however it doesn't give you access to errors array.
12
+
13
+ 0.3.2 (11/10/2015) - Added BadResponseError to client error handling.
14
+
15
15
  ***
16
- #### 0.2.13 (6/20/2015)
17
- Handle missing cap section
16
+
17
+ 0.3.1 (6/25/2015) - Added nested error handling for other HTTPClient errors. HttpError has original attribute exposing the root error.
18
+
19
+ ***
20
+
21
+ 0.3.0 (6/23/2015) - Added Client class for error handling (bad entries accessed via errors array). Exposed option to turn on strict XML parsing for debugging. Alert.fetch uses new Client but is backwards compatible, however it doesn't give you access to errors array.
22
+
23
+ ***
24
+
25
+ 0.2.13 (6/20/2015) - Handle missing cap section
26
+
18
27
  ***
19
- #### 0.2.12 (6/12/2015)
20
- Fix issue with missing link elements
28
+
29
+ 0.2.12 (6/12/2015) - Fix issue with missing link elements
30
+
21
31
  ***
22
- #### 0.2.11 (5/29/2015)
23
- Added method to get original polygon string
32
+
33
+ 0.2.11 (5/29/2015) -Added method to get original polygon string
34
+
24
35
  ***
25
- #### 0.2.10 (3/23/2015)
26
- Added option to override default alert service URI.
36
+
37
+ 0.2.10 (3/23/2015) - Added option to override default alert service URI.
38
+
27
39
  ***
28
- #### 0.2.1 (10/02/2014)
29
- Added static map image to polygons.
40
+
41
+ 0.2.1 (10/02/2014) - Added static map image to polygons.
42
+
30
43
  ***
31
- #### 0.2.0 (10/02/2014)
32
- Introduced Polygon type.
44
+
45
+ 0.2.0 (10/02/2014) - Introduced Polygon type.
46
+
33
47
  ***
34
- #### 0.1.1 (10/01/2014)
35
- Refactored and simplified alert processing.
48
+
49
+ 0.1.1 (10/01/2014) - Refactored and simplified alert processing.
50
+
36
51
  ***
37
- #### 0.1.0 (10/01/2014)
38
- Initial release, basic functionality of fetching and parsing alerts.
52
+
53
+ 0.1.0 (10/01/2014) - Initial release, basic functionality of fetching and parsing alerts.
data/Gemfile CHANGED
@@ -2,8 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in gull.gemspec
4
4
  gemspec
5
-
6
- gem 'coveralls', require: false
7
- gem 'guard'
8
- gem 'guard-rspec', require: false
9
- gem 'simplecov', require: false
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/gull.svg)](http://badge.fury.io/rb/gull)
2
2
  [![Build Status](https://travis-ci.org/sethdeckard/gull.svg?branch=master)](https://travis-ci.org/sethdeckard/gull)
3
- [![Coverage Status](https://coveralls.io/repos/sethdeckard/gull/badge.png)](https://coveralls.io/r/sethdeckard/gull)
3
+ [![Coverage Status](https://coveralls.io/repos/sethdeckard/gull/badge.svg?branch=master)](https://coveralls.io/r/sethdeckard/gull)
4
4
  [![Code Climate](https://codeclimate.com/github/sethdeckard/gull/badges/gpa.svg)](https://codeclimate.com/github/sethdeckard/gull)
5
5
  [![Dependency Status](https://gemnasium.com/sethdeckard/gull.svg)](https://gemnasium.com/sethdeckard/gull)
6
6
  [![security](https://hakiri.io/github/sethdeckard/gull/master.svg)](https://hakiri.io/github/sethdeckard/gull/master)
7
7
  # Gull
8
8
 
9
- Ruby client for parsing NOAA/NWS alerts, warnings, and watches. The name comes from the type of bird featured on the NOAA logo.
9
+ Ruby client for parsing NOAA/NWS alerts, warnings, and watches. The name comes from the type of bird featured on the NOAA logo. Please read the Notes/Caveats section for limitations.
10
10
 
11
11
  ## Installation
12
12
 
@@ -68,24 +68,16 @@ Options can be passed for map to override defaults
68
68
 
69
69
  ```ruby
70
70
  options = { width: 600, height: 300, color: '0xfbf000', weight: 4,
71
- fillcolor: '0xfbf00070', maptype: 'hybrid' }
72
- alert.polygon.image_url 'YOUR_GOOGLE_API_KEY', options
71
+ fillcolor: '0xfbf00070', maptype: 'hybrid' }
72
+ alert.polygon.image_url 'YOUR_GOOGLE_API_KEY', options
73
73
  ```
74
74
 
75
- Get the centroid of the polygon (to display a map pin, etc.)
76
-
77
- ```ruby
78
- alert.polygon.centroid
79
-
80
- => [34.835, -91.205]
81
- ```
82
-
83
75
  ##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).
76
+ 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 Atom feeds](http://alerts.weather.gov/). If you need a complete CAP parser I suggest looking at [RCAP](https://github.com/farrel/RCAP).
85
77
 
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.
78
+ The NWS will often cancel or update alerts before their expiration time. The public Atom feeds only provide current active alerts and do not include these separate update and cancellation CAP messages.
87
79
 
88
- The public RSS feeds are not always reliable, if you are using this for critical purposes then you should explore other options.
80
+ The public Atom feeds have not always been reliable in terms of uptime and are often delayed by 2-3 minutes. If you are considering using this (or another gem/library that accesses the public Atom feeds) for mission critical purposes then you should explore other options.
89
81
 
90
82
  ### Urgency
91
83
 
@@ -19,10 +19,12 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_runtime_dependency 'httpclient'
22
- spec.add_runtime_dependency 'nokogiri', '>= 1.6.2'
22
+ spec.add_runtime_dependency 'nokogiri', '>= 1.6.8'
23
23
 
24
- spec.add_development_dependency 'bundler', '>= 1.6'
24
+ spec.add_development_dependency 'bundler'
25
25
  spec.add_development_dependency 'rake'
26
- spec.add_development_dependency 'rspec', '>= 3.0'
26
+ spec.add_development_dependency 'rspec', '>=3.0'
27
+ spec.add_development_dependency 'coveralls'
28
+ spec.add_development_dependency 'guard'
27
29
  spec.add_development_dependency 'webmock'
28
30
  end
@@ -3,31 +3,8 @@ module Gull
3
3
  attr_accessor :coordinates
4
4
 
5
5
  def initialize(polygon)
6
- self.coordinates = polygon.split(' ').collect do |coords|
7
- coords.split(',').collect(&:to_f)
8
- end
9
- end
10
-
11
- def centroid
12
- low_x = 0
13
- low_y = 0
14
- high_x = 0
15
- high_y = 0
16
-
17
- coordinates.each do |pair|
18
- x_bounds = bounds pair.first, low_x, high_x
19
- low_x = x_bounds.first
20
- high_x = x_bounds.last
21
-
22
- y_bounds = bounds pair.last, low_y, high_y
23
- low_y = y_bounds.first
24
- high_y = y_bounds.last
25
- end
26
-
27
- center_x = low_x + ((high_x - low_x) / 2)
28
- center_y = low_y + ((high_y - low_y) / 2)
29
-
30
- [center_x, center_y]
6
+ self.coordinates = polygon.split(' ')
7
+ .map { |point| point.split(',').map(&:to_f) }
31
8
  end
32
9
 
33
10
  def image_url(api_key, options = {})
@@ -51,20 +28,17 @@ module Gull
51
28
  coordinates.map { |pair| pair.join(',') }.join(' ')
52
29
  end
53
30
 
54
- private
55
-
56
- def bounds(point, low, high)
57
- if point < low || low == 0
58
- low = point
59
- elsif point > high || high == 0
60
- high = point
61
- end
62
-
63
- [low, high]
31
+ # Returns well-known text (WKT) formatted polygon
32
+ def to_wkt
33
+ pairs = coordinates.map { |pair| "#{pair.last} #{pair.first}" }
34
+ .join(', ')
35
+ "POLYGON((#{pairs}))"
64
36
  end
65
37
 
38
+ private
39
+
66
40
  def coordinates_piped
67
- coordinates.collect { |pair| pair.join ',' }.join '|'
41
+ coordinates.map { |pair| pair.join ',' }.join '|'
68
42
  end
69
43
  end
70
44
  end
@@ -1,3 +1,3 @@
1
1
  module Gull
2
- VERSION = '0.3.4'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -1,25 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Gull::Polygon do
4
- it 'should return centroid of polygon' do
5
- polygon = Gull::Polygon.new '34.57,-97.56 34.77,-97.38 34.75,-97.17 ' \
6
- '34.64,-97.11 34.64,-97.14 34.62,-97.14 34.62,-97.2 34.6,-97.19 34.59,' \
7
- '-97.17 34.57,-97.17 34.5,-97.3 34.51,-97.56 34.57,-97.56'
8
- expect(polygon.centroid).to eq [34.635000000000005, -97.33500000000001]
9
-
10
- polygon = Gull::Polygon.new '30.71,-86.4 30.78,-86.04 30.27,-86.01 30.35,' \
11
- '-86.28 30.37,-86.4 30.39,-86.4 30.4,-86.4 30.4,-86.34 30.43,-86.32' \
12
- ' 30.4,-86.29 30.43,-86.25 30.39,-86.16 30.39,-86.13 30.47,-86.21 ' \
13
- '30.48,-86.26 30.46,-86.4 30.71,-86.4'
14
- expect(polygon.centroid).to eq [30.525, -86.20500000000001]
15
-
16
- polygon = Gull::Polygon.new '30.39,-86.59 30.38,-86.8 30.79,-86.72 30.78,' \
17
- '-86.38 30.45,-86.39 30.44,-86.42 30.48,-86.46 30.45,-86.49 30.42,' \
18
- '-86.59 30.4,-86.58 30.4,-86.53 30.42,-86.49 30.42,-86.44 30.41,-86.4 ' \
19
- '30.38,-86.39 30.37,-86.4 30.39,-86.59'
20
- expect(polygon.centroid).to eq [30.58, -86.59]
21
- end
22
-
23
4
  it 'should return static map image url' do
24
5
  polygon = Gull::Polygon.new '34.57,-97.56 34.77,-97.38 34.75,-97.17'
25
6
 
@@ -48,4 +29,17 @@ describe Gull::Polygon do
48
29
  polygon = Gull::Polygon.new text
49
30
  expect(polygon.to_s).to eq text
50
31
  end
32
+
33
+ it 'should output polygons in WKT format' do
34
+ text = '34.57,-97.56 34.77,-97.38 34.75,-97.17 ' \
35
+ '34.64,-97.11 34.64,-97.14 34.62,-97.14 34.62,-97.2 34.6,-97.19 34.59,' \
36
+ '-97.17 34.57,-97.17 34.5,-97.3 34.51,-97.56 34.57,-97.56'
37
+
38
+ wkt_text = 'POLYGON((-97.56 34.57, -97.38 34.77, -97.17 34.75,' \
39
+ ' -97.11 34.64, -97.14 34.64, -97.14 34.62, -97.2 34.62, -97.19 34.6,' \
40
+ ' -97.17 34.59, -97.17 34.57, -97.3 34.5, -97.56 34.51, -97.56 34.57))'
41
+
42
+ polygon = Gull::Polygon.new text
43
+ expect(polygon.to_wkt).to eq wkt_text
44
+ end
51
45
  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.3.4
4
+ version: 0.4.0
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-12-16 00:00:00.000000000 Z
11
+ date: 2016-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.6.2
33
+ version: 1.6.8
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 1.6.2
40
+ version: 1.6.8
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.6'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.6'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,34 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: webmock
85
113
  requirement: !ruby/object:Gem::Requirement
@@ -150,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
178
  version: '0'
151
179
  requirements: []
152
180
  rubyforge_project:
153
- rubygems_version: 2.4.5.1
181
+ rubygems_version: 2.6.4
154
182
  signing_key:
155
183
  specification_version: 4
156
184
  summary: Client for parsing NOAA/NWS alerts, warnings, and watches.