gull 0.2.9 → 0.2.10

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: efe23d6de3946c51a67a4fc953d6d1815eea92a9
4
- data.tar.gz: 4101a32bf1a6ce2111e0771bd2d22b9f1d7c9d23
3
+ metadata.gz: 4e86081d360eca93b4a9d0dbe5185bc6a248a6a1
4
+ data.tar.gz: 336895cd8f897425e987779c2168c5ed1a065f4f
5
5
  SHA512:
6
- metadata.gz: b47fef1e1492a2f6f46b796922f8870fa2c308aaf5803ab550f31d3d6cd853e3821009a3892c59be9237376200e77c70407eacf30c25035c8440586f885403cc
7
- data.tar.gz: 4e9dd491033578832999b28fa7c0d56a8a6a867e36ea4a2ebe035e97be511a58f6b739f060a36f16f8dd80f17c3ced550ac5b8c52c383fc3284187470c04d197
6
+ metadata.gz: 8da6e8b46feb22d5b611d4e17387830fbcab34bb8195e4101d3162cbee41c23b5bf800ab662eaf24745928bee7a43164935c055d7bd82dc198868607e833ae23
7
+ data.tar.gz: 3a985d7754a0d7229fec1cac7ba50ac71315a8c48a76eebfeb468543ba37ec2c835eddc8947634bd066f3b177d30a98b4c7aa8b389f34f1e476e02ba6e4ede4d
data/.hound.yml ADDED
@@ -0,0 +1,3 @@
1
+ ruby:
2
+ enabled: true
3
+ config_file: .rubocop.yml
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'spec/spec_helper.rb'
4
+ Style/StringLiterals:
5
+ EnforcedStyle: single_quotes
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in gull.gemspec
4
4
  gemspec
5
5
 
6
- gem 'coveralls', require: false
6
+ gem 'coveralls', require: false
data/README.md CHANGED
@@ -57,6 +57,9 @@ Or install it yourself as:
57
57
  alert.polygon.centroid
58
58
 
59
59
  => [34.835, -91.205]
60
+
61
+ ##Notes
62
+ 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.
60
63
 
61
64
 
62
65
  ### Urgency
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new
5
5
 
6
- task :default => :spec
7
- task :test => :spec
6
+ task default: :spec
7
+ task test: :spec
data/gull.gemspec CHANGED
@@ -4,25 +4,25 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'gull/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "gull"
7
+ spec.name = 'gull'
8
8
  spec.version = Gull::VERSION
9
- spec.authors = ["Seth Deckard"]
10
- spec.email = ["seth@deckard.me"]
11
- spec.summary = %q{Client for parsing NOAA/NWS alerts, warnings, and watches.}
12
- spec.description = %q{Client for parsing NOAA/NWS alerts, warnings, and watches.}
13
- spec.homepage = "https://github.com/sethdeckard/gull"
14
- spec.license = "MIT"
9
+ spec.authors = ['Seth Deckard']
10
+ spec.email = ['seth@deckard.me']
11
+ spec.summary = 'Client for parsing NOAA/NWS alerts, warnings, and watches.'
12
+ spec.description = 'Client for parsing NOAA/NWS alerts, warnings, and watches.'
13
+ spec.homepage = 'https://github.com/sethdeckard/gull'
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_runtime_dependency "httpclient"
22
- spec.add_runtime_dependency "nokogiri", ">= 1.6.2"
21
+ spec.add_runtime_dependency 'httpclient'
22
+ spec.add_runtime_dependency 'nokogiri', '>= 1.6.2'
23
23
 
24
- spec.add_development_dependency "bundler", ">= 1.6"
25
- spec.add_development_dependency "rake"
26
- spec.add_development_dependency "rspec", ">= 2.11"
27
- spec.add_development_dependency "webmock"
28
- end
24
+ spec.add_development_dependency 'bundler', '>= 1.6'
25
+ spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'rspec', '>= 2.11'
27
+ spec.add_development_dependency 'webmock'
28
+ end
data/lib/gull.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'gull/version'
2
+ require 'gull/error'
2
3
  require 'gull/alert'
3
4
  require 'gull/polygon'
4
5
  require 'gull/geocode'
data/lib/gull/alert.rb CHANGED
@@ -3,28 +3,26 @@ require 'nokogiri'
3
3
 
4
4
  module Gull
5
5
  class Alert
6
- attr_accessor :id, :title, :summary, :link, :alert_type, :polygon, :area, :effective_at,
7
- :expires_at, :updated_at, :published_at, :urgency, :severity, :certainty, :geocode, :vtec
6
+ attr_accessor :id, :title, :summary, :link, :alert_type, :polygon, :area,
7
+ :effective_at, :expires_at, :updated_at, :published_at,
8
+ :urgency, :severity, :certainty, :geocode, :vtec
8
9
 
9
10
  def initialize
10
11
  self.geocode = Geocode.new
11
12
  end
12
13
 
13
- def self.fetch
14
- client = HTTPClient.new
15
- response = client.get_content "http://alerts.weather.gov/cap/us.php?x=0"
16
- document = Nokogiri::XML response
17
- self.process document.css('feed/entry')
18
- end
14
+ def self.fetch(options = {})
15
+ options = {
16
+ url: 'http://alerts.weather.gov/cap/us.php?x=1'
17
+ }.merge options
19
18
 
20
- def parse element
21
- self.id = element.css('id').inner_text
22
- self.title = element.css('title').inner_text
23
- self.summary = element.css('summary').inner_text
24
- self.link = element.css('link').first.attributes["href"].value
25
- self.alert_type = element.xpath('cap:event').inner_text
26
- self.area = element.xpath('cap:areaDesc').inner_text
19
+ content = response options
20
+ document = Nokogiri::XML content
21
+ process document.css('feed/entry')
22
+ end
27
23
 
24
+ def parse(element)
25
+ parse_core_attributes element
28
26
  parse_times element
29
27
  parse_categories element
30
28
 
@@ -35,7 +33,16 @@ module Gull
35
33
 
36
34
  private
37
35
 
38
- def self.process entries
36
+ def self.response(options)
37
+ client = HTTPClient.new
38
+ begin
39
+ return client.get_content options[:url]
40
+ rescue HTTPClient::TimeoutError
41
+ raise TimeoutError, 'Timeout while connecting to NWS web service'
42
+ end
43
+ end
44
+
45
+ def self.process(entries)
39
46
  alerts = []
40
47
  entries.each do |entry|
41
48
  alerts.push create_instance entry
@@ -44,44 +51,52 @@ module Gull
44
51
  alerts
45
52
  end
46
53
 
47
- def self.create_instance entry
54
+ def self.create_instance(entry)
48
55
  alert = Alert.new
49
56
  alert.parse entry
50
57
  alert
51
58
  end
52
59
 
53
- def parse_times element
60
+ def parse_core_attributes(element)
61
+ self.id = element.css('id').inner_text
62
+ self.title = element.css('title').inner_text
63
+ self.summary = element.css('summary').inner_text
64
+ self.link = element.css('link').first.attributes['href'].value
65
+ self.alert_type = element.xpath('cap:event').inner_text
66
+ self.area = element.xpath('cap:areaDesc').inner_text
67
+ end
68
+
69
+ def parse_times(element)
54
70
  self.updated_at = Time.parse(element.css('updated').inner_text).utc
55
71
  self.published_at = Time.parse(element.css('published').inner_text).utc
56
- self.effective_at = Time.parse(element.xpath('cap:effective').inner_text).utc
72
+ self.effective_at = Time.parse(element.xpath('cap:effective').inner_text)
73
+ .utc
57
74
  self.expires_at = Time.parse(element.xpath('cap:expires').inner_text).utc
58
75
  end
59
76
 
60
- def parse_categories element
77
+ def parse_categories(element)
61
78
  self.urgency = code_to_symbol element.xpath('cap:urgency').inner_text
62
79
  self.severity = code_to_symbol element.xpath('cap:severity').inner_text
63
80
  self.certainty = code_to_symbol element.xpath('cap:certainty').inner_text
64
81
  end
65
82
 
66
- def parse_polygon text
67
- unless text.empty?
68
- self.polygon = Polygon.new text
69
- end
83
+ def parse_polygon(text)
84
+ return if text.empty?
85
+ self.polygon = Polygon.new text
70
86
  end
71
87
 
72
- def parse_geocode element
73
- self.geocode.fips6 = element.children.css('value').first.inner_text
74
- self.geocode.ugc = element.children.css('value').last.inner_text
88
+ def parse_geocode(element)
89
+ geocode.fips6 = element.children.css('value').first.inner_text
90
+ geocode.ugc = element.children.css('value').last.inner_text
75
91
  end
76
92
 
77
- def parse_vtec element
93
+ def parse_vtec(element)
78
94
  value = element.children.css('value').inner_text
79
95
  self.vtec = value.empty? ? nil : value
80
96
  end
81
97
 
82
- def code_to_symbol code
83
- code.gsub(' ','_').downcase.to_sym
98
+ def code_to_symbol(code)
99
+ code.gsub(' ', '_').downcase.to_sym
84
100
  end
85
-
86
101
  end
87
- end
102
+ end
data/lib/gull/error.rb ADDED
@@ -0,0 +1,4 @@
1
+ module Gull
2
+ class TimeoutError < StandardError
3
+ end
4
+ end
data/lib/gull/geocode.rb CHANGED
@@ -2,4 +2,4 @@ module Gull
2
2
  class Geocode
3
3
  attr_accessor :fips6, :ugc
4
4
  end
5
- end
5
+ end
data/lib/gull/polygon.rb CHANGED
@@ -2,14 +2,16 @@ module Gull
2
2
  class Polygon
3
3
  attr_accessor :coordinates
4
4
 
5
- def initialize polygon
6
- self.coordinates = polygon.split(" ").collect {|coords| coords.split(",").collect {|coord| coord.to_f} }
5
+ def initialize(polygon)
6
+ self.coordinates = polygon.split(' ').collect do |coords|
7
+ coords.split(',').collect(&:to_f)
8
+ end
7
9
  end
8
10
 
9
11
  def centroid
10
- low_x = 0
12
+ low_x = 0
11
13
  low_y = 0
12
- high_x = 0
14
+ high_x = 0
13
15
  high_y = 0
14
16
 
15
17
  coordinates.each do |pair|
@@ -28,27 +30,29 @@ module Gull
28
30
  [center_x, center_y]
29
31
  end
30
32
 
31
- def image_url api_key, options={}
32
- opts = {
33
- :width => 640,
34
- :height => 640,
35
- :color => "0xff0000",
36
- :weight => 3,
37
- :fillcolor => "0xff000060",
38
- :maptype => "roadmap"
33
+ def image_url(api_key, options = {})
34
+ options = {
35
+ width: 640,
36
+ height: 640,
37
+ color: '0xff0000',
38
+ weight: 3,
39
+ fillcolor: '0xff000060',
40
+ maptype: 'roadmap'
39
41
  }.merge(options)
40
42
 
41
- url_base = "http://maps.googleapis.com/maps/api/staticmap"
42
- "#{url_base}?size=#{opts[:width]}x#{opts[:height]}&maptype=#{opts[:maptype]}&path=color:#{opts[:color]}" +
43
- "|weight:#{opts[:weight]}|fillcolor:#{opts[:fillcolor]}|#{coordinates_piped}&key=#{api_key}"
43
+ url_base = 'http://maps.googleapis.com/maps/api/staticmap'
44
+ "#{url_base}?size=#{options[:width]}x#{options[:height]}" \
45
+ "&maptype=#{options[:maptype]}&path=color:#{options[:color]}" \
46
+ "|weight:#{options[:weight]}|fillcolor:#{options[:fillcolor]}" \
47
+ "|#{coordinates_piped}&key=#{api_key}"
44
48
  end
45
49
 
46
- private
50
+ private
47
51
 
48
- def bounds point, low, high
49
- if point < low or low == 0
52
+ def bounds(point, low, high)
53
+ if point < low || low == 0
50
54
  low = point
51
- elsif point > high or high == 0
55
+ elsif point > high || high == 0
52
56
  high = point
53
57
  end
54
58
 
@@ -56,8 +60,7 @@ module Gull
56
60
  end
57
61
 
58
62
  def coordinates_piped
59
- coordinates.collect {|pair| pair.join "," }.join "|"
63
+ coordinates.collect { |pair| pair.join ',' }.join '|'
60
64
  end
61
-
62
65
  end
63
- end
66
+ end
data/lib/gull/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gull
2
- VERSION = "0.2.9"
2
+ VERSION = '0.2.10'
3
3
  end
data/spec/alert_spec.rb CHANGED
@@ -1,46 +1,51 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Gull::Alert do
4
- it "should initialize with geocode" do
4
+ it 'should initialize with geocode' do
5
5
  alert = Gull::Alert.new
6
6
  expect(alert.geocode).not_to be_nil
7
7
  end
8
8
 
9
- it "should fetch parsed alerts" do
10
- xml = File.read "spec/fixtures/alerts.xml"
9
+ it 'should fetch parsed alerts' do
10
+ xml = File.read 'spec/fixtures/alerts.xml'
11
11
 
12
- stub_request(:get, "http://alerts.weather.gov/cap/us.php?x=0").
13
- with(:headers => {'Accept'=>'*/*'}).
14
- to_return(:status => 200, :body => xml, :headers => {})
12
+ stub_request(:get, 'http://alerts.weather.gov/cap/us.php?x=1')
13
+ .with(headers: { 'Accept' => '*/*' })
14
+ .to_return(status: 200, body: xml, headers: {})
15
15
 
16
16
  alerts = Gull::Alert.fetch
17
17
  expect(alerts.size).to eq(3)
18
18
 
19
19
  first = alerts.first
20
- expect(first.id).to eq "http://alerts.weather.gov/cap/wwacapget.php?x=CA125171381DD0.HeatAdvisory"
21
- expect(first.link).to eq "http://alerts.weather.gov/cap/wwacapget.php?x=CA125171381DD0.HeatAdvisory"
22
- expect(first.alert_type).to eq "Heat Advisory"
23
- expect(first.title).to eq "Heat Advisory issued October 01 at 8:40AM PDT until October 03 at 9:00PM PDT by NWS"
24
- expect(first.summary).to eq "SUMMARY TEXT"
25
-
26
- coordinates = [[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
- [27.35,-81.79]]
20
+ expect(first.id).to eq 'http://alerts.weather.gov/cap/wwacapget.php?x=CA125171381DD0.HeatAdvisory'
21
+ expect(first.link).to eq 'http://alerts.weather.gov/cap/wwacapget.php?x=CA125171381DD0.HeatAdvisory'
22
+ expect(first.alert_type).to eq 'Heat Advisory'
23
+ expect(first.title).to eq 'Heat Advisory issued October 01 at 8:40AM PDT' \
24
+ ' until October 03 at 9:00PM PDT by NWS'
25
+ expect(first.summary).to eq 'SUMMARY TEXT'
26
+
27
+ coordinates = [[27.35, -81.79], [27.14, -81.89], [27.04, -81.97],
28
+ [27.04, -82.02], [27.14, -81.97], [27.35, -81.86],
29
+ [27.35, -81.79]]
28
30
  expect(first.polygon.coordinates).to eq coordinates
29
-
30
- expect(first.effective_at).to eq Time.parse("2014-10-01T08:40:00-07:00")
31
- expect(first.expires_at).to eq Time.parse("2014-10-03T21:00:00-07:00")
32
- expect(first.updated_at).to eq Time.parse("2014-10-01T08:40:00-07:05")
33
- expect(first.published_at).to eq Time.parse("2014-10-01T08:40:00-07:06")
34
31
 
35
- expect(first.area).to eq "Southern Salinas Valley, Arroyo Seco and Lake San Antonio"
32
+ expect(first.effective_at).to eq Time.parse('2014-10-01T08:40:00-07:00')
33
+ expect(first.expires_at).to eq Time.parse('2014-10-03T21:00:00-07:00')
34
+ expect(first.updated_at).to eq Time.parse('2014-10-01T08:40:00-07:05')
35
+ expect(first.published_at).to eq Time.parse('2014-10-01T08:40:00-07:06')
36
+
37
+ expect(first.area).to eq 'Southern Salinas Valley, Arroyo Seco and Lake ' \
38
+ 'San Antonio'
36
39
  expect(first.urgency).to eq :expected
37
40
  expect(first.severity).to eq :minor
38
41
  expect(first.certainty).to eq :very_likely
39
42
 
40
- expect(first.geocode.fips6).to eq "006001 006013 006041 006053 006055 006069 006075 006081 006085 006087 006097"
41
- expect(first.geocode.ugc).to eq "CAZ006 CAZ505 CAZ506 CAZ507 CAZ508 CAZ509 CAZ510 CAZ511 CAZ512"
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'
42
47
 
43
- expect(first.vtec).to eq "/O.NEW.KMTR.HT.Y.0002.141002T1900Z-141004T0400Z/"
48
+ expect(first.vtec).to eq '/O.NEW.KMTR.HT.Y.0002.141002T1900Z-141004T0400Z/'
44
49
 
45
50
  second = alerts[1]
46
51
  expect(second.polygon).to be_nil
@@ -50,25 +55,45 @@ describe Gull::Alert do
50
55
  expect(third.vtec).to be_nil
51
56
  end
52
57
 
53
- it "should handle empty alerts" do
54
- xml = File.read "spec/fixtures/empty.xml"
58
+ it 'should fetch from url in options' do
59
+ xml = File.read 'spec/fixtures/alerts.xml'
60
+
61
+ stub_request(:get, 'http://alerts.weather.gov/cap/ok.php?x=1')
62
+ .with(headers: { 'Accept' => '*/*' })
63
+ .to_return(status: 200, body: xml, headers: {})
64
+
65
+ alerts = Gull::Alert.fetch(url: 'http://alerts.weather.gov/cap/ok.php?x=1')
66
+ expect(alerts.size).to eq(3)
67
+ end
68
+
69
+ it 'should handle empty alerts' do
70
+ xml = File.read 'spec/fixtures/empty.xml'
55
71
 
56
- stub_request(:get, "http://alerts.weather.gov/cap/us.php?x=0").
57
- with(:headers => {'Accept'=>'*/*'}).
58
- to_return(:status => 200, :body => xml, :headers => {})
72
+ stub_request(:get, 'http://alerts.weather.gov/cap/us.php?x=1')
73
+ .with(headers: { 'Accept' => '*/*' })
74
+ .to_return(status: 200, body: xml, headers: {})
59
75
 
60
76
  alerts = Gull::Alert.fetch
61
77
  expect(alerts.size).to eq(0)
62
78
  end
63
79
 
64
- it "should handle bad response" do
65
- xml = File.read "spec/fixtures/bad.xml"
80
+ it 'should handle bad response' do
81
+ xml = File.read 'spec/fixtures/bad.xml'
66
82
 
67
- stub_request(:get, "http://alerts.weather.gov/cap/us.php?x=0").
68
- with(:headers => {'Accept'=>'*/*'}).
69
- to_return(:status => 200, :body => xml, :headers => {})
83
+ stub_request(:get, 'http://alerts.weather.gov/cap/us.php?x=1')
84
+ .with(headers: { 'Accept' => '*/*' })
85
+ .to_return(status: 200, body: xml, headers: {})
70
86
 
71
87
  alerts = Gull::Alert.fetch
72
- expect(alerts.size).to eq(0)
88
+ expect(alerts.size).to eq(0)
89
+ end
90
+
91
+ it 'should raise own error if timeout occurs' do
92
+ stub_request(:get, 'http://alerts.weather.gov/cap/us.php?x=1')
93
+ .with(headers: { 'Accept' => '*/*' }).to_timeout
94
+
95
+ message = 'Timeout while connecting to NWS web service'
96
+ expect { Gull::Alert.fetch }
97
+ .to raise_error(Gull::TimeoutError, message)
73
98
  end
74
- end
99
+ end
data/spec/polygon_spec.rb CHANGED
@@ -1,34 +1,43 @@
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 34.64,-97.11 34.64,-97.14 " +
6
- "34.62,-97.14 34.62,-97.2 34.6,-97.19 34.59,-97.17 34.57,-97.17 34.5,-97.3 34.51,-97.56 34.57,-97.56"
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'
7
8
  expect(polygon.centroid).to eq [34.635000000000005, -97.33500000000001]
8
9
 
9
- polygon = Gull::Polygon.new "30.71,-86.4 30.78,-86.04 30.27,-86.01 30.35,-86.28 30.37,-86.4 30.39,-86.4 30.4,-86.4 30.4,-86.34 30.43,-86.32 30.4,-86.29 30.43,-86.25 30.39,-86.16 30.39,-86.13 30.47,-86.21 30.48,-86.26 30.46,-86.4 30.71,-86.4"
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'
10
14
  expect(polygon.centroid).to eq [30.525, -86.20500000000001]
11
15
 
12
- polygon = Gull::Polygon.new "30.39,-86.59 30.38,-86.8 30.79,-86.72 30.78,-86.38 30.45,-86.39 30.44,-86.42 30.48,-86.46 30.45,-86.49 30.42,-86.59 30.4,-86.58 30.4,-86.53 30.42,-86.49 30.42,-86.44 30.41,-86.4 30.38,-86.39 30.37,-86.4 30.39,-86.59"
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'
13
20
  expect(polygon.centroid).to eq [30.58, -86.59]
14
21
  end
15
22
 
16
- it "should return static map image url" do
17
- polygon = Gull::Polygon.new "34.57,-97.56 34.77,-97.38 34.75,-97.17"
23
+ it 'should return static map image url' do
24
+ polygon = Gull::Polygon.new '34.57,-97.56 34.77,-97.38 34.75,-97.17'
18
25
 
19
- api_key = "testkey"
20
- options = { :width => 600, :height => 300, :color => "0xfbf000", :weight => 4, :fillcolor => "0xfbf00070",
21
- :maptype => "hybrid" }
26
+ api_key = 'testkey'
27
+ options = { width: 600, height: 300, color: '0xfbf000', weight: 4,
28
+ fillcolor: '0xfbf00070', maptype: 'hybrid' }
22
29
  url = polygon.image_url api_key, options
23
- expected_url = "http://maps.googleapis.com/maps/api/staticmap?" +
24
- "size=600x300&maptype=hybrid&path=color:0xfbf000" +
25
- "|weight:4|fillcolor:0xfbf00070|34.57,-97.56|34.77,-97.38|34.75,-97.17&key=testkey"
30
+ expected_url = 'http://maps.googleapis.com/maps/api/staticmap?' \
31
+ 'size=600x300&maptype=hybrid&path=color:0xfbf000' \
32
+ '|weight:4|fillcolor:0xfbf00070|34.57,-97.56|34.77,-97.38|34.75,-97.17' \
33
+ '&key=testkey'
26
34
  expect(url).to eq expected_url
27
35
 
28
36
  url = polygon.image_url api_key
29
- expected_url = "http://maps.googleapis.com/maps/api/staticmap?" +
30
- "size=640x640&maptype=roadmap&path=color:0xff0000" +
31
- "|weight:3|fillcolor:0xff000060|34.57,-97.56|34.77,-97.38|34.75,-97.17&key=testkey"
37
+ expected_url = 'http://maps.googleapis.com/maps/api/staticmap?' \
38
+ 'size=640x640&maptype=roadmap&path=color:0xff0000' \
39
+ '|weight:3|fillcolor:0xff000060|34.57,-97.56|34.77,-97.38|34.75,-97.17' \
40
+ '&key=testkey'
32
41
  expect(url).to eq expected_url
33
42
  end
34
- end
43
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,4 @@
1
- require 'gull/alert'
2
- require 'gull/polygon'
3
- require 'gull/geocode'
1
+ require 'gull'
4
2
  require 'webmock/rspec'
5
3
 
6
4
  require 'coveralls'
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.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Deckard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-11 00:00:00.000000000 Z
11
+ date: 2015-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -102,7 +102,9 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - ".gitignore"
105
+ - ".hound.yml"
105
106
  - ".rspec"
107
+ - ".rubocop.yml"
106
108
  - ".travis.yml"
107
109
  - Gemfile
108
110
  - LICENSE.txt
@@ -111,6 +113,7 @@ files:
111
113
  - gull.gemspec
112
114
  - lib/gull.rb
113
115
  - lib/gull/alert.rb
116
+ - lib/gull/error.rb
114
117
  - lib/gull/geocode.rb
115
118
  - lib/gull/polygon.rb
116
119
  - lib/gull/version.rb
@@ -140,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
143
  version: '0'
141
144
  requirements: []
142
145
  rubyforge_project:
143
- rubygems_version: 2.2.2
146
+ rubygems_version: 2.4.4
144
147
  signing_key:
145
148
  specification_version: 4
146
149
  summary: Client for parsing NOAA/NWS alerts, warnings, and watches.