rcap 2.5.0 → 2.7.4
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 +5 -5
- data/.ruby-version +1 -0
- data/CHANGELOG.md +18 -0
- data/README.md +1 -0
- data/lib/rcap.rb +3 -1
- data/lib/rcap/alert.rb +4 -2
- data/lib/rcap/base/alert.rb +70 -73
- data/lib/rcap/base/area.rb +19 -13
- data/lib/rcap/base/circle.rb +15 -4
- data/lib/rcap/base/event_code.rb +2 -0
- data/lib/rcap/base/geocode.rb +2 -0
- data/lib/rcap/base/info.rb +81 -75
- data/lib/rcap/base/parameter.rb +8 -6
- data/lib/rcap/base/point.rb +4 -2
- data/lib/rcap/base/polygon.rb +16 -8
- data/lib/rcap/base/resource.rb +13 -13
- data/lib/rcap/cap_1_0/alert.rb +36 -39
- data/lib/rcap/cap_1_0/area.rb +2 -0
- data/lib/rcap/cap_1_0/circle.rb +2 -0
- data/lib/rcap/cap_1_0/event_code.rb +3 -1
- data/lib/rcap/cap_1_0/geocode.rb +3 -1
- data/lib/rcap/cap_1_0/info.rb +3 -1
- data/lib/rcap/cap_1_0/parameter.rb +3 -2
- data/lib/rcap/cap_1_0/point.rb +2 -0
- data/lib/rcap/cap_1_0/polygon.rb +3 -1
- data/lib/rcap/cap_1_0/resource.rb +2 -0
- data/lib/rcap/cap_1_1/alert.rb +4 -2
- data/lib/rcap/cap_1_1/area.rb +2 -0
- data/lib/rcap/cap_1_1/circle.rb +2 -0
- data/lib/rcap/cap_1_1/event_code.rb +3 -1
- data/lib/rcap/cap_1_1/geocode.rb +3 -1
- data/lib/rcap/cap_1_1/info.rb +48 -46
- data/lib/rcap/cap_1_1/parameter.rb +2 -1
- data/lib/rcap/cap_1_1/point.rb +2 -0
- data/lib/rcap/cap_1_1/polygon.rb +3 -1
- data/lib/rcap/cap_1_1/resource.rb +12 -11
- data/lib/rcap/cap_1_2/alert.rb +4 -2
- data/lib/rcap/cap_1_2/area.rb +2 -0
- data/lib/rcap/cap_1_2/circle.rb +2 -0
- data/lib/rcap/cap_1_2/event_code.rb +3 -1
- data/lib/rcap/cap_1_2/geocode.rb +3 -1
- data/lib/rcap/cap_1_2/info.rb +55 -51
- data/lib/rcap/cap_1_2/parameter.rb +2 -1
- data/lib/rcap/cap_1_2/point.rb +2 -0
- data/lib/rcap/cap_1_2/polygon.rb +4 -2
- data/lib/rcap/cap_1_2/resource.rb +14 -12
- data/lib/rcap/config.rb +2 -0
- data/lib/rcap/custom_validators.rb +30 -27
- data/lib/rcap/extensions/array.rb +2 -0
- data/lib/rcap/extensions/date.rb +3 -1
- data/lib/rcap/extensions/date_time.rb +4 -1
- data/lib/rcap/extensions/float.rb +2 -0
- data/lib/rcap/extensions/integer.rb +7 -0
- data/lib/rcap/extensions/nil_class.rb +2 -0
- data/lib/rcap/extensions/string.rb +3 -1
- data/lib/rcap/extensions/time.rb +3 -0
- data/lib/rcap/formatters/yaml.rb +5 -0
- data/lib/rcap/info.rb +2 -0
- data/lib/rcap/utilities.rb +8 -10
- data/lib/rcap/validation.rb +19 -14
- data/lib/rcap/version.rb +3 -1
- data/rcap.gemspec +5 -5
- data/spec/alert_spec.rb +8 -9
- data/spec/cap_1_0/alert_spec.rb +4 -5
- data/spec/cap_1_0/area_spec.rb +7 -10
- data/spec/cap_1_0/circle_spec.rb +9 -0
- data/spec/cap_1_0/event_code_spec.rb +1 -1
- data/spec/cap_1_0/geocode_spec.rb +1 -1
- data/spec/cap_1_0/info_spec.rb +38 -38
- data/spec/cap_1_0/polygon_spec.rb +7 -5
- data/spec/cap_1_0/resource_spec.rb +6 -7
- data/spec/cap_1_1/alert_spec.rb +6 -7
- data/spec/cap_1_1/area_spec.rb +6 -8
- data/spec/cap_1_1/circle_spec.rb +9 -0
- data/spec/cap_1_1/info_spec.rb +26 -26
- data/spec/cap_1_1/parameter_spec.rb +1 -2
- data/spec/cap_1_1/polygon_spec.rb +12 -10
- data/spec/cap_1_1/resource_spec.rb +13 -13
- data/spec/cap_1_2/alert_spec.rb +7 -8
- data/spec/cap_1_2/area_spec.rb +6 -6
- data/spec/cap_1_2/circle_spec.rb +9 -0
- data/spec/cap_1_2/info_spec.rb +25 -26
- data/spec/cap_1_2/polygon_spec.rb +8 -0
- data/spec/cap_1_2/resource_spec.rb +13 -13
- data/spec/extensions_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -2
- data/spec/validations_spec.rb +0 -1
- metadata +15 -15
- data/lib/rcap/extensions/fixnum.rb +0 -5
data/spec/cap_1_0/circle_spec.rb
CHANGED
@@ -99,6 +99,15 @@ describe(RCAP::CAP_1_0::Circle) do
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
+
context('to geojson') do
|
103
|
+
it('should be valid geojson') do
|
104
|
+
@circle.longitude = 5.6
|
105
|
+
expected = '{"type":"Feature","geometry":{"type":"Point",' \
|
106
|
+
'"coordinates":[5.6,30]},"properties":{"radius":10.5}}'
|
107
|
+
expect(@circle.to_geojson).to eq expected
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
102
111
|
context('to hash') do
|
103
112
|
it('should be correct') do
|
104
113
|
@circle.to_h.should == { 'radius' => 10.5, 'lattitude' => 30, 'longitude' => 60 }
|
@@ -9,7 +9,7 @@ describe(RCAP::CAP_1_0::EventCode) do
|
|
9
9
|
event_code.value = 'value'
|
10
10
|
end
|
11
11
|
@alert = RCAP::CAP_1_0::Alert.new
|
12
|
-
@alert.add_info.event_codes <<
|
12
|
+
@alert.add_info.event_codes << @original_event_code
|
13
13
|
@xml_string = @alert.to_xml
|
14
14
|
@xml_document = REXML::Document.new(@xml_string)
|
15
15
|
@info_xml_element = RCAP.xpath_first(@xml_document.root, RCAP::CAP_1_0::Info::XPATH, RCAP::CAP_1_0::Alert::XMLNS)
|
@@ -9,7 +9,7 @@ describe(RCAP::CAP_1_0::Geocode) do
|
|
9
9
|
geocode.value = 'value'
|
10
10
|
end
|
11
11
|
@alert = RCAP::CAP_1_0::Alert.new
|
12
|
-
@alert.add_info.add_area.geocodes <<
|
12
|
+
@alert.add_info.add_area.geocodes << @original_geocode
|
13
13
|
@xml_string = @alert.to_xml
|
14
14
|
@xml_document = REXML::Document.new(@xml_string)
|
15
15
|
@info_xml_element = RCAP.xpath_first(@xml_document.root, RCAP::CAP_1_0::Info::XPATH, RCAP::CAP_1_0::Alert::XMLNS)
|
data/spec/cap_1_0/info_spec.rb
CHANGED
@@ -26,21 +26,21 @@ describe(RCAP::CAP_1_0::Info) do
|
|
26
26
|
resource.uri = 'http://tempuri.org/resource'
|
27
27
|
end
|
28
28
|
|
29
|
-
[%w
|
29
|
+
[%w[name1 value1], %w[name2 value2]].each do |name, value|
|
30
30
|
info.add_event_code do |event_code|
|
31
31
|
event_code.name = name
|
32
32
|
event_code.value = value
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
[%w
|
36
|
+
[%w[name1 value1], %w[name2 value2]].each do |name, value|
|
37
37
|
info.add_parameter do |parameter|
|
38
38
|
parameter.name = name
|
39
39
|
parameter.value = value
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
%w
|
43
|
+
%w[Area1 Area2].each do |area_desc|
|
44
44
|
info.add_area do |area|
|
45
45
|
area.area_desc = area_desc
|
46
46
|
end
|
@@ -72,25 +72,25 @@ describe(RCAP::CAP_1_0::Info) do
|
|
72
72
|
it('should have no parameters') { @info.parameters.should(be_empty) }
|
73
73
|
|
74
74
|
shared_examples_for('it can parse into a CAP 1.0 Info object') do
|
75
|
-
it('should parse categories correctly') { @info.categories.should_not(be_nil); @info.categories.should
|
76
|
-
it('should parse event correctly') { @info.event.should_not(be_nil); @info.event.should
|
77
|
-
it('should parse urgency correctly') { @info.urgency.should_not(be_nil); @info.urgency.should
|
78
|
-
it('should parse severity correctly') { @info.severity.should_not(be_nil); @info.severity.should
|
79
|
-
it('should parse certainty correctly') { @info.certainty.should_not(be_nil); @info.certainty.should
|
80
|
-
it('should parse audience correctly') { @info.audience.should_not(be_nil); @info.audience.should
|
75
|
+
it('should parse categories correctly') { @info.categories.should_not(be_nil); @info.categories.should == @original_info.categories }
|
76
|
+
it('should parse event correctly') { @info.event.should_not(be_nil); @info.event.should == @original_info.event }
|
77
|
+
it('should parse urgency correctly') { @info.urgency.should_not(be_nil); @info.urgency.should == @original_info.urgency }
|
78
|
+
it('should parse severity correctly') { @info.severity.should_not(be_nil); @info.severity.should == @original_info.severity }
|
79
|
+
it('should parse certainty correctly') { @info.certainty.should_not(be_nil); @info.certainty.should == @original_info.certainty }
|
80
|
+
it('should parse audience correctly') { @info.audience.should_not(be_nil); @info.audience.should == @original_info.audience }
|
81
81
|
it('should parse effective correctly') { @info.effective.should_not(be_nil); @info.effective.should(be_within(Rational(1, 86_400)).of(@original_info.effective)) }
|
82
82
|
it('should parse onset correctly') { @info.onset.should_not(be_nil); @info.onset.should(be_within(Rational(1, 86_400)).of(@original_info.onset)) }
|
83
83
|
it('should parse expires correctly') { @info.expires.should_not(be_nil); @info.expires.should(be_within(Rational(1, 86_400)).of(@original_info.expires)) }
|
84
|
-
it('should parse sender_name correctly') { @info.sender_name.should_not(be_nil); @info.sender_name.should
|
85
|
-
it('should parse headline correctly') { @info.headline.should_not(be_nil); @info.headline.should
|
84
|
+
it('should parse sender_name correctly') { @info.sender_name.should_not(be_nil); @info.sender_name.should == @original_info.sender_name }
|
85
|
+
it('should parse headline correctly') { @info.headline.should_not(be_nil); @info.headline.should == @original_info.headline }
|
86
86
|
it('should parse description correctly') { @info.description.should_not(be_nil); @info.description.should == @original_info.description }
|
87
87
|
it('should parse instruction correctly') { @info.instruction.should_not(be_nil); @info.instruction.should == @original_info.instruction }
|
88
|
-
it('should parse web correctly') { @info.web.should_not(be_nil); @info.web.should
|
89
|
-
it('should parse contact correctly') { @info.contact.should_not(be_nil); @info.contact.should
|
90
|
-
it('should parse event_codes correctly') { @info.event_codes.should_not(be_nil); @info.event_codes.should
|
91
|
-
it('should parse parameters correctly') { @info.parameters.should_not(be_nil); @info.parameters.should
|
92
|
-
it('should parse resources correctly') { @info.resources.should_not(be_nil); @info.resources.map(&:to_s).should
|
93
|
-
it('should parse areas correctly') { @info.areas.should_not(be_nil); @info.areas.should
|
88
|
+
it('should parse web correctly') { @info.web.should_not(be_nil); @info.web.should == @original_info.web }
|
89
|
+
it('should parse contact correctly') { @info.contact.should_not(be_nil); @info.contact.should == @original_info.contact }
|
90
|
+
it('should parse event_codes correctly') { @info.event_codes.should_not(be_nil); @info.event_codes.should == @original_info.event_codes }
|
91
|
+
it('should parse parameters correctly') { @info.parameters.should_not(be_nil); @info.parameters.should == @original_info.parameters }
|
92
|
+
it('should parse resources correctly') { @info.resources.should_not(be_nil); @info.resources.map(&:to_s).should == @original_info.resources.map(&:to_s) }
|
93
|
+
it('should parse areas correctly') { @info.areas.should_not(be_nil); @info.areas.should == @original_info.areas }
|
94
94
|
end
|
95
95
|
|
96
96
|
context('from XML') do
|
@@ -119,7 +119,7 @@ describe(RCAP::CAP_1_0::Info) do
|
|
119
119
|
before(:each) do
|
120
120
|
@info = RCAP::CAP_1_0::Info.new do |info|
|
121
121
|
info.event = 'Info Event'
|
122
|
-
info.categories <<
|
122
|
+
info.categories << RCAP::CAP_1_0::Info::CATEGORY_GEO
|
123
123
|
info.urgency = RCAP::CAP_1_0::Info::URGENCY_IMMEDIATE
|
124
124
|
info.severity = RCAP::CAP_1_0::Info::SEVERITY_EXTREME
|
125
125
|
info.certainty = RCAP::CAP_1_0::Info::CERTAINTY_VERY_LIKELY
|
@@ -158,83 +158,83 @@ describe(RCAP::CAP_1_0::Info) do
|
|
158
158
|
end
|
159
159
|
|
160
160
|
it('should export the language correctly') do
|
161
|
-
@info_hash[
|
161
|
+
@info_hash[RCAP::CAP_1_0::Info::LANGUAGE_KEY].should == @info.language
|
162
162
|
end
|
163
163
|
|
164
164
|
it('should export the categories') do
|
165
|
-
@info_hash[
|
165
|
+
@info_hash[RCAP::CAP_1_0::Info::CATEGORIES_KEY].should == @info.categories
|
166
166
|
end
|
167
167
|
|
168
168
|
it('should export the event') do
|
169
|
-
@info_hash[
|
169
|
+
@info_hash[RCAP::CAP_1_0::Info::EVENT_KEY].should == @info.event
|
170
170
|
end
|
171
171
|
|
172
172
|
it('should export the urgency') do
|
173
|
-
@info_hash[
|
173
|
+
@info_hash[RCAP::CAP_1_0::Info:: URGENCY_KEY].should == @info.urgency
|
174
174
|
end
|
175
175
|
|
176
176
|
it('should export the severity') do
|
177
|
-
@info_hash[
|
177
|
+
@info_hash[RCAP::CAP_1_0::Info:: SEVERITY_KEY].should == @info.severity
|
178
178
|
end
|
179
179
|
|
180
180
|
it('should export the certainty') do
|
181
|
-
@info_hash[
|
181
|
+
@info_hash[RCAP::CAP_1_0::Info:: CERTAINTY_KEY].should == @info.certainty
|
182
182
|
end
|
183
183
|
|
184
184
|
it('should export the audience') do
|
185
|
-
@info_hash[
|
185
|
+
@info_hash[RCAP::CAP_1_0::Info:: AUDIENCE_KEY].should == @info.audience
|
186
186
|
end
|
187
187
|
|
188
188
|
it('should export the effective date') do
|
189
|
-
@info_hash[
|
189
|
+
@info_hash[RCAP::CAP_1_0::Info::EFFECTIVE_KEY].should == @info.effective.to_s_for_cap
|
190
190
|
end
|
191
191
|
|
192
192
|
it('should export the onset date') do
|
193
|
-
@info_hash[
|
193
|
+
@info_hash[RCAP::CAP_1_0::Info::ONSET_KEY].should == @info.onset.to_s_for_cap
|
194
194
|
end
|
195
195
|
|
196
196
|
it('should export the expires date') do
|
197
|
-
@info_hash[
|
197
|
+
@info_hash[RCAP::CAP_1_0::Info::EXPIRES_KEY].should == @info.expires.to_s_for_cap
|
198
198
|
end
|
199
199
|
|
200
200
|
it('should export the sender name') do
|
201
|
-
@info_hash[
|
201
|
+
@info_hash[RCAP::CAP_1_0::Info::SENDER_NAME_KEY].should == @info.sender_name
|
202
202
|
end
|
203
203
|
|
204
204
|
it('should export the headline') do
|
205
|
-
@info_hash[
|
205
|
+
@info_hash[RCAP::CAP_1_0::Info::HEADLINE_KEY].should == @info.headline
|
206
206
|
end
|
207
207
|
|
208
208
|
it('should export the description') do
|
209
|
-
@info_hash[
|
209
|
+
@info_hash[RCAP::CAP_1_0::Info::DESCRIPTION_KEY].should == @info.description
|
210
210
|
end
|
211
211
|
|
212
212
|
it('should export the instruction') do
|
213
|
-
@info_hash[
|
213
|
+
@info_hash[RCAP::CAP_1_0::Info::INSTRUCTION_KEY].should == @info.instruction
|
214
214
|
end
|
215
215
|
|
216
216
|
it('should export the web address ') do
|
217
|
-
@info_hash[
|
217
|
+
@info_hash[RCAP::CAP_1_0::Info::WEB_KEY].should == @info.web
|
218
218
|
end
|
219
219
|
|
220
220
|
it('should export the contact') do
|
221
|
-
@info_hash[
|
221
|
+
@info_hash[RCAP::CAP_1_0::Info::CONTACT_KEY].should == @info.contact
|
222
222
|
end
|
223
223
|
|
224
224
|
it('should export the event codes') do
|
225
|
-
@info_hash[
|
225
|
+
@info_hash[RCAP::CAP_1_0::Info::EVENT_CODES_KEY].should == @info.event_codes.map { |event_code| event_code.to_h }
|
226
226
|
end
|
227
227
|
|
228
228
|
it('should export the parameters ') do
|
229
|
-
@info_hash[
|
229
|
+
@info_hash[RCAP::CAP_1_0::Info::PARAMETERS_KEY].should == @info.parameters.map { |parameter| parameter.to_h }
|
230
230
|
end
|
231
231
|
|
232
232
|
it('should export the resources ') do
|
233
|
-
@info_hash[
|
233
|
+
@info_hash[RCAP::CAP_1_0::Info::RESOURCES_KEY].should == @info.resources.map { |resource| resource.to_h }
|
234
234
|
end
|
235
235
|
|
236
236
|
it('should export the areas') do
|
237
|
-
@info_hash[
|
237
|
+
@info_hash[RCAP::CAP_1_0::Info::AREAS_KEY].should == @info.areas.map { |area| area.to_h }
|
238
238
|
end
|
239
239
|
end
|
240
240
|
end
|
@@ -14,11 +14,6 @@ describe(RCAP::CAP_1_0::Polygon) do
|
|
14
14
|
@polygon.should(be_valid)
|
15
15
|
end
|
16
16
|
|
17
|
-
it('does not have any points') do
|
18
|
-
@polygon.points.clear
|
19
|
-
@polygon.should_not(be_valid)
|
20
|
-
end
|
21
|
-
|
22
17
|
it('does not have a valid collection of points') do
|
23
18
|
@polygon.points.first.lattitude = nil
|
24
19
|
@polygon.should_not(be_valid)
|
@@ -106,6 +101,13 @@ describe(RCAP::CAP_1_0::Polygon) do
|
|
106
101
|
end
|
107
102
|
end
|
108
103
|
|
104
|
+
context('to geojson') do
|
105
|
+
it('should be valid geojson') do
|
106
|
+
expected = '{"type":"Polygon","coordinates":[[[0,0],[1,1],[2,2]]]}'
|
107
|
+
expect(@polygon.to_geojson).to eq expected
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
109
111
|
context('to a hash') do
|
110
112
|
it('should export correctly') do
|
111
113
|
@polygon.to_h.should == { RCAP::CAP_1_0::Polygon::POINTS_KEY => @polygon.points.map { |point| point.to_a } }
|
@@ -86,7 +86,6 @@ describe(RCAP::CAP_1_0::Resource) do
|
|
86
86
|
@resource.digest.should == @original_resource.digest
|
87
87
|
end
|
88
88
|
end
|
89
|
-
|
90
89
|
end
|
91
90
|
|
92
91
|
context('when exported') do
|
@@ -106,29 +105,29 @@ describe(RCAP::CAP_1_0::Resource) do
|
|
106
105
|
end
|
107
106
|
|
108
107
|
it('should set the resource description') do
|
109
|
-
@resource_hash[
|
108
|
+
@resource_hash[RCAP::CAP_1_0::Resource::RESOURCE_DESC_KEY].should == @resource.resource_desc
|
110
109
|
end
|
111
110
|
|
112
111
|
it('should set the mime type') do
|
113
|
-
@resource_hash[
|
112
|
+
@resource_hash[RCAP::CAP_1_0::Resource::MIME_TYPE_KEY].should == @resource.mime_type
|
114
113
|
end
|
115
114
|
|
116
115
|
it('should set the size') do
|
117
|
-
@resource_hash[
|
116
|
+
@resource_hash[RCAP::CAP_1_0::Resource::SIZE_KEY].should == @resource.size
|
118
117
|
end
|
119
118
|
|
120
119
|
it('should set the URI') do
|
121
|
-
@resource_hash[
|
120
|
+
@resource_hash[RCAP::CAP_1_0::Resource::URI_KEY].should == @resource.uri
|
122
121
|
end
|
123
122
|
|
124
123
|
it('should set the digest') do
|
125
|
-
@resource_hash[
|
124
|
+
@resource_hash[RCAP::CAP_1_0::Resource::DIGEST_KEY].should == @resource.digest
|
126
125
|
end
|
127
126
|
end
|
128
127
|
|
129
128
|
context('to xml') do
|
130
129
|
it('should be successful') do
|
131
|
-
|
130
|
+
-> { @resource_xml = @resource.to_xml }.should_not(raise_exception)
|
132
131
|
end
|
133
132
|
end
|
134
133
|
end
|
data/spec/cap_1_1/alert_spec.rb
CHANGED
@@ -12,14 +12,14 @@ describe(RCAP::CAP_1_1::Alert) do
|
|
12
12
|
['Address 1', 'Address 2'].each do |address|
|
13
13
|
alert.addresses << address
|
14
14
|
end
|
15
|
-
%w
|
15
|
+
%w[Code1 Code2].each do |code|
|
16
16
|
alert.codes << code
|
17
17
|
end
|
18
|
-
alert.note
|
19
|
-
%w
|
18
|
+
alert.note = 'Note'
|
19
|
+
%w[Reference1 Reference2].each do |reference|
|
20
20
|
alert.references << reference
|
21
21
|
end
|
22
|
-
%w
|
22
|
+
%w[Incident1 Incident2].each do |_incident|
|
23
23
|
end
|
24
24
|
alert.add_info
|
25
25
|
alert.add_info
|
@@ -27,7 +27,7 @@ describe(RCAP::CAP_1_1::Alert) do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
context('on initialisation') do
|
30
|
-
before(:each)
|
30
|
+
before(:each) do
|
31
31
|
@alert = RCAP::CAP_1_1::Alert.new
|
32
32
|
end
|
33
33
|
|
@@ -75,7 +75,6 @@ describe(RCAP::CAP_1_1::Alert) do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
it_should_behave_like('a successfully parsed CAP 1.1 alert')
|
78
|
-
|
79
78
|
end
|
80
79
|
|
81
80
|
context('from YAML') do
|
@@ -168,7 +167,7 @@ describe(RCAP::CAP_1_1::Alert) do
|
|
168
167
|
context('has an info element and it') do
|
169
168
|
it('is not valid') do
|
170
169
|
@info = @alert.add_info do |info|
|
171
|
-
info.event
|
170
|
+
info.event = 'Info Event'
|
172
171
|
info.categories << RCAP::CAP_1_1::Info::CATEGORY_GEO
|
173
172
|
info.urgency = RCAP::CAP_1_1::Info::URGENCY_IMMEDIATE
|
174
173
|
info.severity = RCAP::CAP_1_1::Info::SEVERITY_EXTREME
|
data/spec/cap_1_1/area_spec.rb
CHANGED
@@ -23,7 +23,6 @@ describe(RCAP::CAP_1_1::Area) do
|
|
23
23
|
point.longitude = 2
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
27
26
|
end
|
28
27
|
|
29
28
|
context('on initialisation') do
|
@@ -71,7 +70,6 @@ describe(RCAP::CAP_1_1::Area) do
|
|
71
70
|
|
72
71
|
context('from XML') do
|
73
72
|
before(:each) do
|
74
|
-
|
75
73
|
@alert = RCAP::CAP_1_1::Alert.new
|
76
74
|
@alert.add_info.add_area(&@area_builder)
|
77
75
|
@xml_string = @alert.to_xml
|
@@ -112,27 +110,27 @@ describe(RCAP::CAP_1_1::Area) do
|
|
112
110
|
end
|
113
111
|
|
114
112
|
it('should export the area description correctly') do
|
115
|
-
@area_hash[
|
113
|
+
@area_hash[RCAP::CAP_1_1::Area::AREA_DESC_KEY].should == @area.area_desc
|
116
114
|
end
|
117
115
|
|
118
116
|
it('should export the altitude correctly') do
|
119
|
-
@area_hash[
|
117
|
+
@area_hash[RCAP::CAP_1_1::Area::ALTITUDE_KEY].should == @area.altitude
|
120
118
|
end
|
121
119
|
|
122
120
|
it('should set the ceiling correctly') do
|
123
|
-
@area_hash[
|
121
|
+
@area_hash[RCAP::CAP_1_1::Area::CEILING_KEY].should == @area.ceiling
|
124
122
|
end
|
125
123
|
|
126
124
|
it('should export the circles correctly') do
|
127
|
-
@area_hash[
|
125
|
+
@area_hash[RCAP::CAP_1_1::Area::CIRCLES_KEY].should == @area.circles.map { |circle| circle.to_a }
|
128
126
|
end
|
129
127
|
|
130
128
|
it('should export the geocodes correctly') do
|
131
|
-
@area_hash[
|
129
|
+
@area_hash[RCAP::CAP_1_1::Area::GEOCODES_KEY].should == @area.geocodes.map { |geocode| geocode.to_h }
|
132
130
|
end
|
133
131
|
|
134
132
|
it('should export the polygons correctly') do
|
135
|
-
@area_hash[
|
133
|
+
@area_hash[RCAP::CAP_1_1::Area::POLYGONS_KEY].should == @area.polygons.map { |polygon| polygon.to_h }
|
136
134
|
end
|
137
135
|
end
|
138
136
|
end
|
data/spec/cap_1_1/circle_spec.rb
CHANGED
@@ -102,6 +102,15 @@ describe(RCAP::CAP_1_1::Circle) do
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
+
context('to geojson') do
|
106
|
+
it('should be valid geojson') do
|
107
|
+
@circle.longitude = 5.6
|
108
|
+
expected = '{"type":"Feature","geometry":{"type":"Point",' \
|
109
|
+
'"coordinates":[5.6,30]},"properties":{"radius":10.5}}'
|
110
|
+
expect(@circle.to_geojson).to eq expected
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
105
114
|
context('to hash') do
|
106
115
|
it('should be correct') do
|
107
116
|
@circle.to_h.should == { 'radius' => 10.5, 'lattitude' => 30, 'longitude' => 60 }
|
data/spec/cap_1_1/info_spec.rb
CHANGED
@@ -34,19 +34,19 @@ describe(RCAP::CAP_1_1::Info) do
|
|
34
34
|
|
35
35
|
[{ name: 'name1', value: 'value1' }, { name: 'name2', value: 'value2' }].each do |event_code_hash|
|
36
36
|
info.add_event_code do |event_code|
|
37
|
-
event_code.name = event_code_hash[
|
38
|
-
event_code.value = event_code_hash[
|
37
|
+
event_code.name = event_code_hash[:name]
|
38
|
+
event_code.value = event_code_hash[:value]
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
[{ name: 'name1', value: 'value1' }, { name: 'name2', value: 'value2' }].each do |parameter_hash|
|
43
43
|
info.add_parameter do |parameter|
|
44
|
-
parameter.name = parameter_hash[
|
45
|
-
parameter.value = parameter_hash[
|
44
|
+
parameter.name = parameter_hash[:name]
|
45
|
+
parameter.value = parameter_hash[:value]
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
%w
|
49
|
+
%w[Area1 Area2].each do |area_desc|
|
50
50
|
info.add_area do |area|
|
51
51
|
area.area_desc = area_desc
|
52
52
|
end
|
@@ -315,87 +315,87 @@ describe(RCAP::CAP_1_1::Info) do
|
|
315
315
|
end
|
316
316
|
|
317
317
|
it('should export the language correctly') do
|
318
|
-
@info_hash[
|
318
|
+
@info_hash[RCAP::CAP_1_1::Info::LANGUAGE_KEY].should == @info.language
|
319
319
|
end
|
320
320
|
|
321
321
|
it('should export the categories') do
|
322
|
-
@info_hash[
|
322
|
+
@info_hash[RCAP::CAP_1_1::Info::CATEGORIES_KEY].should == @info.categories
|
323
323
|
end
|
324
324
|
|
325
325
|
it('should export the event') do
|
326
|
-
@info_hash[
|
326
|
+
@info_hash[RCAP::CAP_1_1::Info::EVENT_KEY].should == @info.event
|
327
327
|
end
|
328
328
|
|
329
329
|
it('should export the response types') do
|
330
|
-
@info_hash[
|
330
|
+
@info_hash[RCAP::CAP_1_1::Info::RESPONSE_TYPES_KEY].should == @info.response_types
|
331
331
|
end
|
332
332
|
|
333
333
|
it('should export the urgency') do
|
334
|
-
@info_hash[
|
334
|
+
@info_hash[RCAP::CAP_1_1::Info:: URGENCY_KEY].should == @info.urgency
|
335
335
|
end
|
336
336
|
|
337
337
|
it('should export the severity') do
|
338
|
-
@info_hash[
|
338
|
+
@info_hash[RCAP::CAP_1_1::Info:: SEVERITY_KEY].should == @info.severity
|
339
339
|
end
|
340
340
|
|
341
341
|
it('should export the certainty') do
|
342
|
-
@info_hash[
|
342
|
+
@info_hash[RCAP::CAP_1_1::Info:: CERTAINTY_KEY].should == @info.certainty
|
343
343
|
end
|
344
344
|
|
345
345
|
it('should export the audience') do
|
346
|
-
@info_hash[
|
346
|
+
@info_hash[RCAP::CAP_1_1::Info:: AUDIENCE_KEY].should == @info.audience
|
347
347
|
end
|
348
348
|
|
349
349
|
it('should export the effective date') do
|
350
|
-
@info_hash[
|
350
|
+
@info_hash[RCAP::CAP_1_1::Info::EFFECTIVE_KEY].should == @info.effective.to_s_for_cap
|
351
351
|
end
|
352
352
|
|
353
353
|
it('should export the onset date') do
|
354
|
-
@info_hash[
|
354
|
+
@info_hash[RCAP::CAP_1_1::Info::ONSET_KEY].should == @info.onset.to_s_for_cap
|
355
355
|
end
|
356
356
|
|
357
357
|
it('should export the expires date') do
|
358
|
-
@info_hash[
|
358
|
+
@info_hash[RCAP::CAP_1_1::Info::EXPIRES_KEY].should == @info.expires.to_s_for_cap
|
359
359
|
end
|
360
360
|
|
361
361
|
it('should export the sender name') do
|
362
|
-
@info_hash[
|
362
|
+
@info_hash[RCAP::CAP_1_1::Info::SENDER_NAME_KEY].should == @info.sender_name
|
363
363
|
end
|
364
364
|
|
365
365
|
it('should export the headline') do
|
366
|
-
@info_hash[
|
366
|
+
@info_hash[RCAP::CAP_1_1::Info::HEADLINE_KEY].should == @info.headline
|
367
367
|
end
|
368
368
|
|
369
369
|
it('should export the description') do
|
370
|
-
@info_hash[
|
370
|
+
@info_hash[RCAP::CAP_1_1::Info::DESCRIPTION_KEY].should == @info.description
|
371
371
|
end
|
372
372
|
|
373
373
|
it('should export the instruction') do
|
374
|
-
@info_hash[
|
374
|
+
@info_hash[RCAP::CAP_1_1::Info::INSTRUCTION_KEY].should == @info.instruction
|
375
375
|
end
|
376
376
|
|
377
377
|
it('should export the web address ') do
|
378
|
-
@info_hash[
|
378
|
+
@info_hash[RCAP::CAP_1_1::Info::WEB_KEY].should == @info.web
|
379
379
|
end
|
380
380
|
|
381
381
|
it('should export the contact') do
|
382
|
-
@info_hash[
|
382
|
+
@info_hash[RCAP::CAP_1_1::Info::CONTACT_KEY].should == @info.contact
|
383
383
|
end
|
384
384
|
|
385
385
|
it('should export the event codes') do
|
386
|
-
@info_hash[
|
386
|
+
@info_hash[RCAP::CAP_1_1::Info::EVENT_CODES_KEY].should == @info.event_codes.map { |event_code| event_code.to_h }
|
387
387
|
end
|
388
388
|
|
389
389
|
it('should export the parameters ') do
|
390
|
-
@info_hash[
|
390
|
+
@info_hash[RCAP::CAP_1_1::Info::PARAMETERS_KEY].should == @info.parameters.map { |parameter| parameter.to_h }
|
391
391
|
end
|
392
392
|
|
393
393
|
it('should export the resources ') do
|
394
|
-
@info_hash[
|
394
|
+
@info_hash[RCAP::CAP_1_1::Info::RESOURCES_KEY].should == @info.resources.map { |resource| resource.to_h }
|
395
395
|
end
|
396
396
|
|
397
397
|
it('should export the areas') do
|
398
|
-
@info_hash[
|
398
|
+
@info_hash[RCAP::CAP_1_1::Info::AREAS_KEY].should == @info.areas.map { |area| area.to_h }
|
399
399
|
end
|
400
400
|
end
|
401
401
|
end
|