gull 0.1.0 → 0.1.1

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: d5a3b5083957caf81e25c35ecc48c924b7a5205b
4
- data.tar.gz: eff8557f99a7de3fdbf566360f3496e77ebf21e1
3
+ metadata.gz: cc65a6c9ee8613f29a9e8e5d0417fec80900b73f
4
+ data.tar.gz: e306c334a7890b5ba7008faef82ec29ce95627a5
5
5
  SHA512:
6
- metadata.gz: ec1b9e5d0bbad689d5a7ad2ee2159b33709c37fa206c66489a3d9d810ee7b4332f5b43e683c9fda625ae02cb8299fd0d32056484f70890598df19c045d6745d0
7
- data.tar.gz: d0482148cfbd4fe0ff5fc480cda34dcba5839e643caf62420704a037ea45990cb7b60773a27dc3fa92e28c5595485e689c2b724f13c7cd8f081810f0ee41f12d
6
+ metadata.gz: ff9664befc1f5cada0ff816a64a3ba0c4de73470b3d80fc1986e73b78e7a086715d10b325f178fc8bdf5416d69c3b151bd1e1b7cb2de1b0a81bebf27bfe48f62
7
+ data.tar.gz: 0d8ae32459002821f3cdd83c3687884fafb8ad6afe7689b73470660ef6b3ab22332f792b03d078f30724941410f5d19c808fda8d5fcdf73cefbd008e0460b453
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Gull
2
2
 
3
- Client for parsing NOAA/NWS alerts, warnings, and watches. The name comes from the type of bird featured on the NOAA logo.
3
+ Ruby client for parsing NOAA/NWS alerts, warnings, and watches. The name comes from the type of bird featured on the NOAA logo.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,40 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- Gull::Alert.fetch
21
+ require 'gull/alert'
22
+
23
+ Gull::Alert.fetch
24
+
25
+ ### Urgency
26
+
27
+ | Symbol | Definition
28
+ | :------------- |:-------------
29
+ | :immediate | Responsive action should betaken immediately
30
+ | :expected | Responsive action should be taken soon (within next hour)
31
+ | :future | Responsive action should be taken in the near future
32
+ | :past | Responsive action is no longer required
33
+ | :unknown | Urgency not known
34
+
35
+ ### Severity
36
+
37
+ | Symbol | Definition
38
+ | :------------- |:-------------
39
+ | :extreme | Extraordinary threat to life or property
40
+ | :severe | Significant threat to life or property
41
+ | :moderate | Possible threat to life or property
42
+ | :minor | Minimal threat to life or property
43
+ | :unknown | Severity unknown
44
+
45
+ ### Certainty
46
+
47
+ | Symbol | Definition
48
+ | :------------- |:-------------
49
+ | :very_likely | Highly likely (p > ~ 85%) or certain
50
+ | :likely | Likely (p > ~50%)
51
+ | :possible | Possible but not likely (p <= ~50%)
52
+ | :unlikely | Not expected to occur (p ~ 0)
53
+ | :unknown | Certainty unknown
54
+
22
55
 
23
56
  ## Contributing
24
57
 
@@ -27,3 +60,7 @@ Gull::Alert.fetch
27
60
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
61
  4. Push to the branch (`git push origin my-new-feature`)
29
62
  5. Create a new Pull Request
63
+
64
+ ## License
65
+
66
+ Gull is released under the [MIT License](http://www.opensource.org/licenses/MIT).
data/lib/gull/alert.rb CHANGED
@@ -6,9 +6,6 @@ module Gull
6
6
  attr_accessor :id, :title, :summary, :alert_type, :polygon, :area, :effective_at, :expires_at,
7
7
  :urgency, :severity, :certainty
8
8
 
9
- def initialize(attributes = {})
10
- end
11
-
12
9
  def self.fetch
13
10
  client = HTTPClient.new
14
11
  response = client.get_content "http://alerts.weather.gov/cap/us.php?x=0"
@@ -17,6 +14,8 @@ module Gull
17
14
  self.process entries
18
15
  end
19
16
 
17
+ private
18
+
20
19
  def self.process entries
21
20
  alerts = []
22
21
  entries.each do |entry|
@@ -29,14 +28,17 @@ module Gull
29
28
  alert.area = entry.xpath('cap:areaDesc').inner_text
30
29
  alert.effective_at = Time.parse(entry.xpath('cap:effective').inner_text).utc
31
30
  alert.expires_at = Time.parse(entry.xpath('cap:expires').inner_text).utc
32
- alert.urgency = entry.xpath('cap:urgency').inner_text
33
- alert.severity = entry.xpath('cap:severity').inner_text
34
- alert.certainty = entry.xpath('cap:certainty').inner_text
31
+ alert.urgency = code_to_symbol entry.xpath('cap:urgency').inner_text
32
+ alert.severity = code_to_symbol entry.xpath('cap:severity').inner_text
33
+ alert.certainty = code_to_symbol entry.xpath('cap:certainty').inner_text
35
34
  alerts.push alert
36
35
  end
37
36
 
38
37
  alerts
39
38
  end
40
-
39
+
40
+ def self.code_to_symbol code
41
+ code.gsub(' ','_').downcase.to_sym
42
+ end
41
43
  end
42
44
  end
data/lib/gull/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gull
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/spec/alert_spec.rb CHANGED
@@ -23,8 +23,8 @@ describe Gull::Alert do
23
23
  expect(first.effective_at).to eq Time.parse("2014-10-01T08:40:00-07:00")
24
24
  expect(first.expires_at).to eq Time.parse("2014-10-03T21:00:00-07:00")
25
25
  expect(first.area).to eq "Southern Salinas Valley, Arroyo Seco and Lake San Antonio"
26
- expect(first.urgency).to eq "Expected"
27
- expect(first.severity).to eq "Minor"
28
- expect(first.certainty).to eq "Likely"
26
+ expect(first.urgency).to eq :expected
27
+ expect(first.severity).to eq :minor
28
+ expect(first.certainty).to eq :very_likely
29
29
  end
30
30
  end
data/spec/alerts.xml CHANGED
@@ -46,7 +46,7 @@ xmlns:ha = 'http://www.alerting.net/namespace/index_1.0'
46
46
  <cap:category>Met</cap:category>
47
47
  <cap:urgency>Expected</cap:urgency>
48
48
  <cap:severity>Minor</cap:severity>
49
- <cap:certainty>Likely</cap:certainty>
49
+ <cap:certainty>Very Likely</cap:certainty>
50
50
  <cap:areaDesc>Southern Salinas Valley, Arroyo Seco and Lake San Antonio</cap:areaDesc>
51
51
  <cap:polygon>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.35,-81.79</cap:polygon>
52
52
  <cap:geocode>
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.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Deckard