gull 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +39 -2
- data/lib/gull/alert.rb +9 -7
- data/lib/gull/version.rb +1 -1
- data/spec/alert_spec.rb +3 -3
- data/spec/alerts.xml +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc65a6c9ee8613f29a9e8e5d0417fec80900b73f
|
4
|
+
data.tar.gz: e306c334a7890b5ba7008faef82ec29ce95627a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff9664befc1f5cada0ff816a64a3ba0c4de73470b3d80fc1986e73b78e7a086715d10b325f178fc8bdf5416d69c3b151bd1e1b7cb2de1b0a81bebf27bfe48f62
|
7
|
+
data.tar.gz: 0d8ae32459002821f3cdd83c3687884fafb8ad6afe7689b73470660ef6b3ab22332f792b03d078f30724941410f5d19c808fda8d5fcdf73cefbd008e0460b453
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Gull
|
2
2
|
|
3
|
-
|
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
|
-
|
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
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
|
27
|
-
expect(first.severity).to eq
|
28
|
-
expect(first.certainty).to eq
|
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>
|