gull 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12876cf3ef029b6b63d54b99fbc1011339ca47e0
4
- data.tar.gz: 6cc92aa4a7ad4b3585b68b197728d0267b8d6eb0
3
+ metadata.gz: 6866c03cf869ea252749ada87f38b4c2763b5ee0
4
+ data.tar.gz: daf6fca66ec3829783b66037383ffcbb6b97a042
5
5
  SHA512:
6
- metadata.gz: 81ed17d4195d3068ad76acf66d6cb015c3752c0ee517ab862a9e5779540933fb7eec532a7b0f29a54290471a5cab54c63021e8bcc5a7d8f0596d16d7bdcdedf2
7
- data.tar.gz: 4d7846a56a9893f3a2306363b142f83febc04e49aab94cd53ec55461fd34b2ef418b46ceb698eed3290ca08c2e14a32181fa39281dce2bef75de45a941b6230d
6
+ metadata.gz: 6ab8bd8205650ed746e2da93f8eba5ac037732e2c7dd4f9bd58ef9bad2d3e269270508116e4292844b747c6ded882925505be2ec275772023ed1695b7e98ab88
7
+ data.tar.gz: 1209ae73e604144d862b13363b69998b90914ab18a24e835e0e3c5669b4bde3122de8cd58ff806655a0036d389d7d522efdc74b563c60c91c280cd30c4ef73a2
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ [![Gem Version](https://badge.fury.io/rb/gull.svg)](http://badge.fury.io/rb/gull)
1
2
  [![Build Status](https://travis-ci.org/sethdeckard/gull.svg?branch=master)](https://travis-ci.org/sethdeckard/gull)
2
3
  # Gull
3
4
 
@@ -23,24 +24,36 @@ Or install it yourself as:
23
24
 
24
25
  alerts = Gull::Alert.fetch
25
26
  alert = alert.first
27
+
28
+ #access details of alert
29
+ alert.id
30
+ alert.alert_type
31
+ alert.title
32
+ alert.summary
33
+ alert.effective_at
34
+ alert.expires_at
35
+ alert.area
36
+ alert.geocode.fips6
37
+ alert.geocode.ugc
38
+ alert.urgency
39
+ alert.severity
40
+ alert.certainty
41
+ #etc...
26
42
 
27
- #Generate map of polygon (if alert has one)
28
- #requires Google Static Maps API Key
43
+ #You can also generate a map of the polygon if alert has one (requires Google Static Maps API Key)
29
44
  alert.polygon.image_url "your_api_key"
30
45
 
31
46
  => "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"
32
47
 
33
48
  #options can be passed for map to override defaults
34
49
  options = { :width => 600, :height => 300, :color => "0xfbf000", :weight => 4, :fillcolor => "0xfbf00070", :maptype => "hybrid" }
35
-
36
50
  alert.polygon.image_url "your_api_key", options
37
51
 
38
- #returns the centroid of the polygon
52
+ #get the centroid of the polygon (to display a map pin, etc.)
39
53
  alert.polygon.centroid
40
54
 
41
55
  => [34.835, -91.205]
42
56
 
43
-
44
57
 
45
58
  ### Urgency
46
59
 
data/gull.gemspec CHANGED
@@ -18,11 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_runtime_dependency "httpclient"
22
+ spec.add_runtime_dependency "nokogiri"
23
+
21
24
  spec.add_development_dependency "bundler", ">= 1.6"
22
25
  spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "rspec", ">= 2.11"
24
27
  spec.add_development_dependency "webmock"
25
-
26
- spec.add_runtime_dependency "httpclient"
27
- spec.add_runtime_dependency "nokogiri"
28
- end
28
+ end
data/lib/gull.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'gull/version'
2
2
  require 'gull/alert'
3
3
  require 'gull/polygon'
4
+ require 'gull/geocode'
4
5
 
5
6
  module Gull
6
7
  end
data/lib/gull/alert.rb CHANGED
@@ -4,7 +4,11 @@ require 'nokogiri'
4
4
  module Gull
5
5
  class Alert
6
6
  attr_accessor :id, :title, :summary, :alert_type, :polygon, :area, :effective_at, :expires_at,
7
- :urgency, :severity, :certainty
7
+ :urgency, :severity, :certainty, :geocode
8
+
9
+ def initialize
10
+ self.geocode = Geocode.new
11
+ end
8
12
 
9
13
  def self.fetch
10
14
  client = HTTPClient.new
@@ -35,6 +39,11 @@ module Gull
35
39
  alert.urgency = code_to_symbol entry.xpath('cap:urgency').inner_text
36
40
  alert.severity = code_to_symbol entry.xpath('cap:severity').inner_text
37
41
  alert.certainty = code_to_symbol entry.xpath('cap:certainty').inner_text
42
+
43
+ geocode = entry.xpath('cap:geocode')
44
+ alert.geocode.fips6 = geocode.children.css('value').first.inner_text
45
+ alert.geocode.ugc = geocode.children.css('value').last.inner_text
46
+
38
47
  alerts.push alert
39
48
  end
40
49
 
@@ -0,0 +1,5 @@
1
+ module Gull
2
+ class Geocode
3
+ attr_accessor :fips6, :ugc
4
+ end
5
+ end
data/lib/gull/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gull
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
data/spec/alert_spec.rb CHANGED
@@ -28,6 +28,9 @@ describe Gull::Alert do
28
28
  expect(first.severity).to eq :minor
29
29
  expect(first.certainty).to eq :very_likely
30
30
 
31
+ expect(first.geocode.fips6).to eq "006001 006013 006041 006053 006055 006069 006075 006081 006085 006087 006097"
32
+ expect(first.geocode.ugc).to eq "CAZ006 CAZ505 CAZ506 CAZ507 CAZ508 CAZ509 CAZ510 CAZ511 CAZ512"
33
+
31
34
  second = alerts[1]
32
35
  expect(second.polygon).to be_nil
33
36
  end
data/spec/alerts.xml CHANGED
@@ -53,7 +53,7 @@ xmlns:ha = 'http://www.alerting.net/namespace/index_1.0'
53
53
  <valueName>FIPS6</valueName>
54
54
  <value>006001 006013 006041 006053 006055 006069 006075 006081 006085 006087 006097</value>
55
55
  <valueName>UGC</valueName>
56
- <value>CAZ006 CAZ505 CAZ506 CAZ507 CAZ508 CAZ509 CAZ510 CAZ511 CAZ512 CAZ513 CAZ516 CAZ517 CAZ518 CAZ528 CAZ529 CAZ530</value>
56
+ <value>CAZ006 CAZ505 CAZ506 CAZ507 CAZ508 CAZ509 CAZ510 CAZ511 CAZ512</value>
57
57
  </cap:geocode>
58
58
  <cap:parameter>
59
59
  <valueName>VTEC</valueName>
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'gull/alert'
2
2
  require 'gull/polygon'
3
+ require 'gull/geocode'
3
4
  require 'webmock/rspec'
4
5
 
5
6
  # This file was generated by the `rspec --init` command. Conventionally, all
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gull
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Deckard
@@ -11,27 +11,27 @@ cert_chain: []
11
11
  date: 2014-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: httpclient
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
20
- type: :development
19
+ version: '0'
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: '1.6'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
- type: :development
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
@@ -39,21 +39,21 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '>='
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.6'
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: '0'
54
+ version: '1.6'
55
55
  - !ruby/object:Gem::Dependency
56
- name: webmock
56
+ name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '>='
@@ -67,27 +67,27 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: httpclient
70
+ name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '>='
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :runtime
75
+ version: '2.11'
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: '0'
82
+ version: '2.11'
83
83
  - !ruby/object:Gem::Dependency
84
- name: nokogiri
84
+ name: webmock
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
- type: :runtime
90
+ type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
@@ -111,6 +111,7 @@ files:
111
111
  - gull.gemspec
112
112
  - lib/gull.rb
113
113
  - lib/gull/alert.rb
114
+ - lib/gull/geocode.rb
114
115
  - lib/gull/polygon.rb
115
116
  - lib/gull/version.rb
116
117
  - spec/alert_spec.rb