noaa-alerts 0.1.1 → 0.1.2
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.
- data/lib/alert.rb +15 -13
- data/lib/client.rb +1 -1
- data/lib/noaa-alerts/version.rb +1 -1
- data/spec/noaa_alerts_spec.rb +1 -0
- metadata +2 -3
data/lib/alert.rb
CHANGED
@@ -2,9 +2,10 @@ require "noaa-alerts/version"
|
|
2
2
|
|
3
3
|
module Noaa
|
4
4
|
class Alert
|
5
|
-
attr_reader :description, :locations, :identifier, :effective_at, :expires_at, :event, :urgency, :severity, :headline, :sent_at
|
5
|
+
attr_reader :url, :description, :locations, :identifier, :effective_at, :expires_at, :event, :urgency, :severity, :headline, :sent_at
|
6
6
|
|
7
|
-
def initialize(entry)
|
7
|
+
def initialize(url, entry)
|
8
|
+
@url = url || ""
|
8
9
|
@description = ""
|
9
10
|
@event = ""
|
10
11
|
@urgency = ""
|
@@ -15,22 +16,23 @@ module Noaa
|
|
15
16
|
@effective_at = nil
|
16
17
|
@expires_at = nil
|
17
18
|
@sent_at = nil
|
18
|
-
handle_entry(entry)
|
19
|
+
handle_entry(entry) if entry
|
19
20
|
end
|
20
21
|
|
21
22
|
private
|
22
23
|
|
23
24
|
def handle_entry(entry)
|
24
|
-
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
25
|
+
info = entry.fetch('info')
|
26
|
+
@description = info.fetch('description')
|
27
|
+
@event = info.fetch('event')
|
28
|
+
@urgency= info.fetch('urgency')
|
29
|
+
@severity = info.fetch('severity')
|
30
|
+
@headline = info.fetch('headline')
|
31
|
+
@locations = info.fetch('area').fetch('areaDesc').split('; ')
|
32
|
+
@identifier = entry.fetch('identifier')
|
33
|
+
@sent_at = Time.parse(entry.fetch('sent'))
|
34
|
+
@effective_at = Time.parse(info.fetch('effective'))
|
35
|
+
@expires_at = Time.parse(info.fetch('expires'))
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|
data/lib/client.rb
CHANGED
data/lib/noaa-alerts/version.rb
CHANGED
data/spec/noaa_alerts_spec.rb
CHANGED
@@ -20,6 +20,7 @@ describe Noaa, :vcr do
|
|
20
20
|
describe Noaa::Alert do
|
21
21
|
subject { Noaa::Client.new("ny").alerts.first }
|
22
22
|
|
23
|
+
its(:url) { should_not be_empty }
|
23
24
|
its(:event) { should_not be_empty }
|
24
25
|
its(:urgency) { should_not be_empty }
|
25
26
|
its(:severity) { should_not be_empty }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: noaa-alerts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -137,4 +137,3 @@ specification_version: 3
|
|
137
137
|
summary: Fetch and format feeds from the NOAA.
|
138
138
|
test_files:
|
139
139
|
- spec/noaa_alerts_spec.rb
|
140
|
-
has_rdoc:
|