rcap 2.4.1 → 2.7.3

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.
Files changed (99) hide show
  1. checksums.yaml +5 -5
  2. data/.ruby-version +1 -0
  3. data/CHANGELOG.md +18 -0
  4. data/README.md +1 -0
  5. data/lib/rcap.rb +3 -1
  6. data/lib/rcap/alert.rb +30 -29
  7. data/lib/rcap/base/alert.rb +208 -205
  8. data/lib/rcap/base/area.rb +95 -91
  9. data/lib/rcap/base/circle.rb +45 -34
  10. data/lib/rcap/base/event_code.rb +2 -0
  11. data/lib/rcap/base/geocode.rb +2 -0
  12. data/lib/rcap/base/info.rb +273 -272
  13. data/lib/rcap/base/parameter.rb +29 -28
  14. data/lib/rcap/base/point.rb +26 -24
  15. data/lib/rcap/base/polygon.rb +43 -35
  16. data/lib/rcap/base/resource.rb +65 -65
  17. data/lib/rcap/cap_1_0/alert.rb +85 -86
  18. data/lib/rcap/cap_1_0/area.rb +2 -2
  19. data/lib/rcap/cap_1_0/circle.rb +2 -1
  20. data/lib/rcap/cap_1_0/event_code.rb +3 -1
  21. data/lib/rcap/cap_1_0/geocode.rb +3 -1
  22. data/lib/rcap/cap_1_0/info.rb +3 -3
  23. data/lib/rcap/cap_1_0/parameter.rb +13 -13
  24. data/lib/rcap/cap_1_0/point.rb +2 -1
  25. data/lib/rcap/cap_1_0/polygon.rb +3 -3
  26. data/lib/rcap/cap_1_0/resource.rb +2 -3
  27. data/lib/rcap/cap_1_1/alert.rb +6 -6
  28. data/lib/rcap/cap_1_1/area.rb +2 -2
  29. data/lib/rcap/cap_1_1/circle.rb +2 -1
  30. data/lib/rcap/cap_1_1/event_code.rb +3 -1
  31. data/lib/rcap/cap_1_1/geocode.rb +3 -1
  32. data/lib/rcap/cap_1_1/info.rb +125 -132
  33. data/lib/rcap/cap_1_1/parameter.rb +2 -3
  34. data/lib/rcap/cap_1_1/point.rb +2 -1
  35. data/lib/rcap/cap_1_1/polygon.rb +3 -3
  36. data/lib/rcap/cap_1_1/resource.rb +37 -38
  37. data/lib/rcap/cap_1_2/alert.rb +6 -6
  38. data/lib/rcap/cap_1_2/area.rb +2 -2
  39. data/lib/rcap/cap_1_2/circle.rb +2 -1
  40. data/lib/rcap/cap_1_2/event_code.rb +3 -1
  41. data/lib/rcap/cap_1_2/geocode.rb +3 -1
  42. data/lib/rcap/cap_1_2/info.rb +120 -123
  43. data/lib/rcap/cap_1_2/parameter.rb +2 -3
  44. data/lib/rcap/cap_1_2/point.rb +2 -1
  45. data/lib/rcap/cap_1_2/polygon.rb +4 -4
  46. data/lib/rcap/cap_1_2/resource.rb +38 -38
  47. data/lib/rcap/config.rb +5 -3
  48. data/lib/rcap/custom_validators.rb +75 -78
  49. data/lib/rcap/extensions/array.rb +3 -1
  50. data/lib/rcap/extensions/date.rb +3 -1
  51. data/lib/rcap/extensions/date_time.rb +5 -2
  52. data/lib/rcap/extensions/float.rb +2 -0
  53. data/lib/rcap/extensions/integer.rb +7 -0
  54. data/lib/rcap/extensions/nil_class.rb +2 -0
  55. data/lib/rcap/extensions/string.rb +6 -4
  56. data/lib/rcap/extensions/time.rb +5 -3
  57. data/lib/rcap/formatters/yaml.rb +5 -0
  58. data/lib/rcap/info.rb +6 -5
  59. data/lib/rcap/utilities.rb +27 -30
  60. data/lib/rcap/validation.rb +22 -21
  61. data/lib/rcap/version.rb +3 -1
  62. data/rcap.gemspec +5 -5
  63. data/spec/alert_spec.rb +141 -141
  64. data/spec/cap_1_0/alert_spec.rb +92 -94
  65. data/spec/cap_1_0/area_spec.rb +86 -86
  66. data/spec/cap_1_0/circle_spec.rb +48 -39
  67. data/spec/cap_1_0/event_code_spec.rb +15 -15
  68. data/spec/cap_1_0/geocode_spec.rb +16 -16
  69. data/spec/cap_1_0/info_spec.rb +175 -177
  70. data/spec/cap_1_0/parameter_spec.rb +27 -27
  71. data/spec/cap_1_0/point_spec.rb +18 -18
  72. data/spec/cap_1_0/polygon_spec.rb +43 -41
  73. data/spec/cap_1_0/resource_spec.rb +63 -64
  74. data/spec/cap_1_1/alert_spec.rb +107 -109
  75. data/spec/cap_1_1/area_spec.rb +90 -90
  76. data/spec/cap_1_1/circle_spec.rb +43 -34
  77. data/spec/cap_1_1/event_code_spec.rb +15 -16
  78. data/spec/cap_1_1/geocode_spec.rb +16 -16
  79. data/spec/cap_1_1/info_spec.rb +194 -196
  80. data/spec/cap_1_1/parameter_spec.rb +17 -17
  81. data/spec/cap_1_1/point_spec.rb +18 -18
  82. data/spec/cap_1_1/polygon_spec.rb +43 -41
  83. data/spec/cap_1_1/resource_spec.rb +106 -107
  84. data/spec/cap_1_2/alert_spec.rb +98 -99
  85. data/spec/cap_1_2/area_spec.rb +90 -90
  86. data/spec/cap_1_2/circle_spec.rb +52 -43
  87. data/spec/cap_1_2/event_code_spec.rb +19 -20
  88. data/spec/cap_1_2/geocode_spec.rb +20 -20
  89. data/spec/cap_1_2/info_spec.rb +196 -198
  90. data/spec/cap_1_2/parameter_spec.rb +19 -19
  91. data/spec/cap_1_2/point_spec.rb +21 -21
  92. data/spec/cap_1_2/polygon_spec.rb +55 -47
  93. data/spec/cap_1_2/resource_spec.rb +96 -97
  94. data/spec/extensions_spec.rb +29 -29
  95. data/spec/info_spec.rb +15 -15
  96. data/spec/spec_helper.rb +3 -3
  97. data/spec/validations_spec.rb +73 -73
  98. metadata +12 -11
  99. data/lib/rcap/extensions/fixnum.rb +0 -5
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe( RCAP::CAP_1_0::Alert ) do
4
- context( 'on initialisation' ) do
5
- before( :each ) do
3
+ describe(RCAP::CAP_1_0::Alert) do
4
+ context('on initialisation') do
5
+ before(:each) do
6
6
  @alert = RCAP::CAP_1_0::Alert.new
7
7
 
8
8
  @original_alert = RCAP::CAP_1_0::Alert.new do |alert|
@@ -12,160 +12,158 @@ describe( RCAP::CAP_1_0::Alert ) do
12
12
  alert.scope = RCAP::CAP_1_0::Alert::SCOPE_PUBLIC
13
13
  alert.source = 'Source'
14
14
  alert.restriction = 'No Restriction'
15
- [ 'Address 1', 'Address 2'].each do |address|
15
+ ['Address 1', 'Address 2'].each do |address|
16
16
  alert.addresses << address
17
17
  end
18
- [ 'Code1', 'Code2' ].each do |code|
18
+ %w(Code1 Code2).each do |code|
19
19
  alert.codes << code
20
20
  end
21
21
  alert.note = 'Note'
22
- [ 'Sender1','Sender2' ].each do |sender|
22
+ %w(Sender1 Sender2).each do |sender|
23
23
  a = RCAP::CAP_1_0::Alert.new do |a|
24
24
  a.sender = sender
25
25
  end
26
26
  alert.references << a.to_reference
27
27
  end
28
- [ 'Incident1', 'Incident2' ].each do |incident|
28
+ %w(Incident1 Incident2).each do |incident|
29
29
  alert.incidents << incident
30
30
  end
31
- 2.times{ alert.add_info }
31
+ 2.times { alert.add_info }
32
32
  end
33
33
  end
34
34
 
35
- it( 'should have a identifier' ){ @alert.identifier.should_not( be_nil )}
36
- it( 'should not have a sender' ){ @alert.sender.should( be_nil )}
37
- it( 'should not have a sent time' ){ @alert.sent.should( be_nil )}
38
- it( 'should not have a status' ){ @alert.status.should( be_nil )}
39
- it( 'should not have a scope' ){ @alert.scope.should( be_nil )}
40
- it( 'should not have a source'){ @alert.source.should( be_nil )}
41
- it( 'should not have a restriction'){ @alert.restriction.should( be_nil )}
42
- it( 'should not have any addresses' ){ @alert.addresses.should( be_empty )}
43
- it( 'should not have any codes' ){ @alert.codes.should( be_empty )}
44
- it( 'should not have a note' ){ @alert.note.should( be_nil )}
45
- it( 'should not have any references' ){ @alert.references.should( be_empty )}
46
- it( 'should not have any incidents' ){ @alert.incidents.should( be_empty )}
47
- it( 'should not have any infos' ){ @alert.infos.should( be_empty )}
48
-
49
- shared_examples_for( "a successfully parsed CAP 1.0 alert" ) do
50
- it( 'should parse identifier correctly' ) { @alert.identifier.should == @original_alert.identifier }
51
- it( 'should parse sender correctly' ) { @alert.sender.should == @original_alert.sender }
52
- it( 'should parse sent correctly' ) { @alert.sent.should( be_within( 1 ).of( @original_alert.sent ))}
53
- it( 'should parse status correctly' ) { @alert.status.should == @original_alert.status }
54
- it( 'should parse msg_type correctly' ) { @alert.msg_type.should == @original_alert.msg_type }
55
- it( 'should parse source correctly' ) { @alert.source.should == @original_alert.source }
56
- it( 'should parse scope correctly' ) { @alert.scope.should == @original_alert.scope }
57
- it( 'should parse restriction correctly' ){ @alert.restriction.should == @original_alert.restriction }
58
- it( 'should parse addresses correctly' ) { @alert.addresses.should == @original_alert.addresses }
59
- it( 'should parse code correctly' ) { @alert.codes.should == @original_alert.codes }
60
- it( 'should parse note correctly' ) { @alert.note.should == @original_alert.note }
61
- it( 'should parse references correctly' ) { @alert.references.should == @original_alert.references }
62
- it( 'should parse incidents correctly' ) { @alert.incidents.should == @original_alert.incidents }
63
- it( 'should parse infos correctly' ) do
35
+ it('should have a identifier') { @alert.identifier.should_not(be_nil) }
36
+ it('should not have a sender') { @alert.sender.should(be_nil) }
37
+ it('should not have a sent time') { @alert.sent.should(be_nil) }
38
+ it('should not have a status') { @alert.status.should(be_nil) }
39
+ it('should not have a scope') { @alert.scope.should(be_nil) }
40
+ it('should not have a source') { @alert.source.should(be_nil) }
41
+ it('should not have a restriction') { @alert.restriction.should(be_nil) }
42
+ it('should not have any addresses') { @alert.addresses.should(be_empty) }
43
+ it('should not have any codes') { @alert.codes.should(be_empty) }
44
+ it('should not have a note') { @alert.note.should(be_nil) }
45
+ it('should not have any references') { @alert.references.should(be_empty) }
46
+ it('should not have any incidents') { @alert.incidents.should(be_empty) }
47
+ it('should not have any infos') { @alert.infos.should(be_empty) }
48
+
49
+ shared_examples_for('a successfully parsed CAP 1.0 alert') do
50
+ it('should parse identifier correctly') { @alert.identifier.should == @original_alert.identifier }
51
+ it('should parse sender correctly') { @alert.sender.should == @original_alert.sender }
52
+ it('should parse sent correctly') { @alert.sent.should(be_within(1).of(@original_alert.sent)) }
53
+ it('should parse status correctly') { @alert.status.should == @original_alert.status }
54
+ it('should parse msg_type correctly') { @alert.msg_type.should == @original_alert.msg_type }
55
+ it('should parse source correctly') { @alert.source.should == @original_alert.source }
56
+ it('should parse scope correctly') { @alert.scope.should == @original_alert.scope }
57
+ it('should parse restriction correctly') { @alert.restriction.should == @original_alert.restriction }
58
+ it('should parse addresses correctly') { @alert.addresses.should == @original_alert.addresses }
59
+ it('should parse code correctly') { @alert.codes.should == @original_alert.codes }
60
+ it('should parse note correctly') { @alert.note.should == @original_alert.note }
61
+ it('should parse references correctly') { @alert.references.should == @original_alert.references }
62
+ it('should parse incidents correctly') { @alert.incidents.should == @original_alert.incidents }
63
+ it('should parse infos correctly') do
64
64
  @alert.infos.size.should == @original_alert.infos.size
65
- @alert.infos.each{ |info| info.class.should == RCAP::CAP_1_0::Info }
65
+ @alert.infos.each { |info| info.class.should == RCAP::CAP_1_0::Info }
66
66
  end
67
67
  end
68
68
 
69
- context( 'from XML' ) do
70
- before( :each ) do
69
+ context('from XML') do
70
+ before(:each) do
71
71
  @xml_string = @original_alert.to_xml
72
- @xml_document = REXML::Document.new( @xml_string )
72
+ @xml_document = REXML::Document.new(@xml_string)
73
73
  @alert_element = @xml_document.root
74
- @alert = RCAP::CAP_1_0::Alert.from_xml_element( @alert_element )
74
+ @alert = RCAP::CAP_1_0::Alert.from_xml_element(@alert_element)
75
75
  end
76
76
 
77
- it_should_behave_like( "a successfully parsed CAP 1.0 alert" )
77
+ it_should_behave_like('a successfully parsed CAP 1.0 alert')
78
78
 
79
79
  end
80
80
 
81
- context( 'from YAML' ) do
82
- before( :each ) do
81
+ context('from YAML') do
82
+ before(:each) do
83
83
  @yaml_string = @original_alert.to_yaml
84
- @alert = RCAP::CAP_1_0::Alert.from_yaml( @yaml_string )
84
+ @alert = RCAP::CAP_1_0::Alert.from_yaml(@yaml_string)
85
85
  end
86
86
 
87
- it_should_behave_like( "a successfully parsed CAP 1.0 alert" )
87
+ it_should_behave_like('a successfully parsed CAP 1.0 alert')
88
88
  end
89
89
 
90
- context( 'from a hash' ) do
91
- before( :each ) do
92
- @alert = RCAP::CAP_1_0::Alert.from_h( @original_alert.to_h )
90
+ context('from a hash') do
91
+ before(:each) do
92
+ @alert = RCAP::CAP_1_0::Alert.from_h(@original_alert.to_h)
93
93
  end
94
94
 
95
- it_should_behave_like( "a successfully parsed CAP 1.0 alert" )
95
+ it_should_behave_like('a successfully parsed CAP 1.0 alert')
96
96
  end
97
97
 
98
- context( 'from JSON' ) do
99
- before( :each ) do
100
- @alert = RCAP::CAP_1_0::Alert.from_json( @original_alert.to_json )
98
+ context('from JSON') do
99
+ before(:each) do
100
+ @alert = RCAP::CAP_1_0::Alert.from_json(@original_alert.to_json)
101
101
  end
102
102
 
103
- it_should_behave_like( "a successfully parsed CAP 1.0 alert" )
103
+ it_should_behave_like('a successfully parsed CAP 1.0 alert')
104
104
  end
105
105
  end
106
106
 
107
- describe( 'is not valid if it' ) do
108
- before( :each ) do
107
+ describe('is not valid if it') do
108
+ before(:each) do
109
109
  @alert = RCAP::CAP_1_0::Alert.new do |alert|
110
- alert.identifier = 'Identifier'
111
- alert.sender = "cap@tempuri.org"
112
- alert.sent = DateTime.now
113
- alert.status = RCAP::CAP_1_0::Alert::STATUS_TEST
114
- alert.msg_type = RCAP::CAP_1_0::Alert::MSG_TYPE_ALERT
115
- alert.scope = RCAP::CAP_1_0::Alert::SCOPE_PUBLIC
110
+ alert.identifier = 'Identifier'
111
+ alert.sender = 'cap@tempuri.org'
112
+ alert.sent = DateTime.now
113
+ alert.status = RCAP::CAP_1_0::Alert::STATUS_TEST
114
+ alert.msg_type = RCAP::CAP_1_0::Alert::MSG_TYPE_ALERT
115
+ alert.scope = RCAP::CAP_1_0::Alert::SCOPE_PUBLIC
116
116
  end
117
- @alert.should( be_valid )
117
+ @alert.should(be_valid)
118
118
  end
119
119
 
120
- it( 'does not have a identifier' ) do
120
+ it('does not have a identifier') do
121
121
  @alert.identifier = nil
122
- @alert.should_not( be_valid )
122
+ @alert.should_not(be_valid)
123
123
  end
124
124
 
125
- it( 'does not have a sender' ) do
125
+ it('does not have a sender') do
126
126
  @alert.sender = nil
127
- @alert.should_not( be_valid )
127
+ @alert.should_not(be_valid)
128
128
  end
129
129
 
130
- it( 'does not have a sent time (sent)' ) do
130
+ it('does not have a sent time (sent)') do
131
131
  @alert.sent = nil
132
- @alert.should_not( be_valid )
132
+ @alert.should_not(be_valid)
133
133
  end
134
134
 
135
- it( 'does not have a status' ) do
135
+ it('does not have a status') do
136
136
  @alert.status = nil
137
- @alert.should_not( be_valid )
137
+ @alert.should_not(be_valid)
138
138
  end
139
139
 
140
- it( 'does not have a message type (msg_type)' ) do
140
+ it('does not have a message type (msg_type)') do
141
141
  @alert.msg_type = nil
142
- @alert.should_not( be_valid )
142
+ @alert.should_not(be_valid)
143
143
  end
144
144
 
145
- it( 'does not have a scope' ) do
145
+ it('does not have a scope') do
146
146
  @alert.scope = nil
147
- @alert.should_not( be_valid )
147
+ @alert.should_not(be_valid)
148
148
  end
149
149
 
150
-
151
- it( 'does not have a valid status' ) do
150
+ it('does not have a valid status') do
152
151
  @alert.status = 'incorrect value'
153
- @alert.should_not( be_valid )
152
+ @alert.should_not(be_valid)
154
153
  end
155
154
 
156
- it( 'does not have a valid message type msg_type' ) do
155
+ it('does not have a valid message type msg_type') do
157
156
  @alert.msg_type = 'incorrect value'
158
- @alert.should_not( be_valid )
157
+ @alert.should_not(be_valid)
159
158
  end
160
159
 
161
- it( 'does not have a valid scope' ) do
160
+ it('does not have a valid scope') do
162
161
  @alert.scope = 'incorrect value'
163
- @alert.should_not( be_valid )
162
+ @alert.should_not(be_valid)
164
163
  end
165
164
 
166
-
167
- context( 'has an info element and it' ) do
168
- it( 'is not valid' ) do
165
+ context('has an info element and it') do
166
+ it('is not valid') do
169
167
  @info = @alert.add_info do |info|
170
168
  info.event = 'Info Event'
171
169
  info.urgency = RCAP::CAP_1_0::Info::URGENCY_IMMEDIATE
@@ -175,19 +173,19 @@ describe( RCAP::CAP_1_0::Alert ) do
175
173
  @info.categories << RCAP::CAP_1_0::Info::CATEGORY_GEO
176
174
  @info.event = nil
177
175
 
178
- @info.should_not( be_valid )
179
- @alert.should_not( be_valid )
176
+ @info.should_not(be_valid)
177
+ @alert.should_not(be_valid)
180
178
  end
181
179
  end
182
180
  end
183
181
 
184
- describe( 'instance methods' ) do
185
- before( :each ) do
182
+ describe('instance methods') do
183
+ before(:each) do
186
184
  @alert = RCAP::CAP_1_0::Alert.new
187
185
  end
188
186
 
189
- describe( '#add_info' ) do
190
- before( :each ) do
187
+ describe('#add_info') do
188
+ before(:each) do
191
189
  @info = @alert.add_info do |info|
192
190
  info.urgency = 'urgent'
193
191
  end
@@ -195,11 +193,11 @@ describe( RCAP::CAP_1_0::Alert ) do
195
193
  @info.urgency.should == 'urgent'
196
194
  end
197
195
 
198
- it( 'should return a CAP 1.0 Info object' ) do
196
+ it('should return a CAP 1.0 Info object') do
199
197
  @info.class.should == RCAP::CAP_1_0::Info
200
198
  end
201
199
 
202
- it( 'should add an Info object to the infos array' ) do
200
+ it('should add an Info object to the infos array') do
203
201
  @alert.infos.size.should == 1
204
202
  end
205
203
  end
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe( RCAP::CAP_1_0::Area ) do
4
- context( 'on initialisation' ) do
5
- before( :each ) do
3
+ describe(RCAP::CAP_1_0::Area) do
4
+ context('on initialisation') do
5
+ before(:each) do
6
6
  @area = RCAP::CAP_1_0::Area.new
7
7
 
8
8
  @original_area = RCAP::CAP_1_0::Area.new do |area|
@@ -29,77 +29,77 @@ describe( RCAP::CAP_1_0::Area ) do
29
29
  end
30
30
 
31
31
  # Atomic
32
- it( 'should not have a area_desc' ){ @area.area_desc.should( be_nil )}
33
- it( 'should not have a altitude' ){ @area.altitude.should( be_nil )}
34
- it( 'should not have a ceiling' ){ @area.ceiling.should( be_nil )}
32
+ it('should not have a area_desc') { @area.area_desc.should(be_nil) }
33
+ it('should not have a altitude') { @area.altitude.should(be_nil) }
34
+ it('should not have a ceiling') { @area.ceiling.should(be_nil) }
35
35
 
36
36
  # Group
37
- it( 'should have an empty polygons' ){ @area.polygons.should( be_empty )}
38
- it( 'should have an empty circles' ){ @area.circles.should( be_empty )}
39
- it( 'should have an empty geocodes' ){ @area.geocodes.should( be_empty )}
37
+ it('should have an empty polygons') { @area.polygons.should(be_empty) }
38
+ it('should have an empty circles') { @area.circles.should(be_empty) }
39
+ it('should have an empty geocodes') { @area.geocodes.should(be_empty) }
40
40
 
41
- shared_examples_for( "it can parse into a CAP 1.0 Area object" ) do
42
- it( 'should parse the area_desc correctly' ) do
41
+ shared_examples_for('it can parse into a CAP 1.0 Area object') do
42
+ it('should parse the area_desc correctly') do
43
43
  @area.area_desc.should == @original_area.area_desc
44
44
  end
45
45
 
46
- it( 'should parse the altitude correctly' ) do
46
+ it('should parse the altitude correctly') do
47
47
  @area.altitude.should == @original_area.altitude
48
48
  end
49
49
 
50
- it( 'should parse the ceiling correctly' ) do
50
+ it('should parse the ceiling correctly') do
51
51
  @area.ceiling.should == @original_area.ceiling
52
52
  end
53
53
 
54
- it( 'should parse the circles correctly' ) do
54
+ it('should parse the circles correctly') do
55
55
  @area.circles.should == @original_area.circles
56
56
  end
57
57
 
58
- it( 'should parse the geocodes correctly' ) do
58
+ it('should parse the geocodes correctly') do
59
59
  @area.geocodes.should == @original_area.geocodes
60
60
  end
61
61
 
62
- it( 'should parse the polygons correctly' ) do
62
+ it('should parse the polygons correctly') do
63
63
  @area.polygons.should == @original_area.polygons
64
64
  end
65
65
  end
66
66
 
67
- context( 'from XML' ) do
68
- before( :each ) do
67
+ context('from XML') do
68
+ before(:each) do
69
69
 
70
70
  @alert = RCAP::CAP_1_0::Alert.new
71
71
  @alert.add_info.areas << @original_area
72
72
  @xml_string = @alert.to_xml
73
- @xml_document = REXML::Document.new( @xml_string )
74
- @info_xml_element = RCAP.xpath_first( @xml_document.root, RCAP::CAP_1_0::Info::XPATH, RCAP::CAP_1_0::Alert::XMLNS )
75
- @area_xml_element = RCAP.xpath_first( @info_xml_element, RCAP::CAP_1_0::Area::XPATH, RCAP::CAP_1_0::Alert::XMLNS )
76
- @area = RCAP::CAP_1_0::Area.from_xml_element( @area_xml_element )
73
+ @xml_document = REXML::Document.new(@xml_string)
74
+ @info_xml_element = RCAP.xpath_first(@xml_document.root, RCAP::CAP_1_0::Info::XPATH, RCAP::CAP_1_0::Alert::XMLNS)
75
+ @area_xml_element = RCAP.xpath_first(@info_xml_element, RCAP::CAP_1_0::Area::XPATH, RCAP::CAP_1_0::Alert::XMLNS)
76
+ @area = RCAP::CAP_1_0::Area.from_xml_element(@area_xml_element)
77
77
  end
78
78
 
79
- it_should_behave_like( "it can parse into a CAP 1.0 Area object" )
79
+ it_should_behave_like('it can parse into a CAP 1.0 Area object')
80
80
  end
81
81
 
82
- context( 'from YAML Data' ) do
83
- before( :each ) do
82
+ context('from YAML Data') do
83
+ before(:each) do
84
84
 
85
- @area = RCAP::CAP_1_0::Area.from_yaml_data( YAML.load( @original_area.to_yaml ))
85
+ @area = RCAP::CAP_1_0::Area.from_yaml_data(YAML.load(@original_area.to_yaml))
86
86
  end
87
87
 
88
- it_should_behave_like( "it can parse into a CAP 1.0 Area object" )
88
+ it_should_behave_like('it can parse into a CAP 1.0 Area object')
89
89
  end
90
90
 
91
- context( 'from a hash' ) do
92
- before( :each ) do
91
+ context('from a hash') do
92
+ before(:each) do
93
93
 
94
- @area = RCAP::CAP_1_0::Area.from_h( @original_area.to_h )
94
+ @area = RCAP::CAP_1_0::Area.from_h(@original_area.to_h)
95
95
  end
96
96
 
97
- it_should_behave_like( "it can parse into a CAP 1.0 Area object" )
97
+ it_should_behave_like('it can parse into a CAP 1.0 Area object')
98
98
  end
99
99
  end
100
100
 
101
- context( 'when exported' ) do
102
- before( :each ) do
101
+ context('when exported') do
102
+ before(:each) do
103
103
  @area = RCAP::CAP_1_0::Area.new do |area|
104
104
  area.area_desc = 'Area Description'
105
105
  area.altitude = 100
@@ -123,76 +123,76 @@ describe( RCAP::CAP_1_0::Area ) do
123
123
  end
124
124
  end
125
125
 
126
- context( 'to a hash' ) do
127
- before( :each ) do
126
+ context('to a hash') do
127
+ before(:each) do
128
128
  @area_hash = @area.to_h
129
129
  end
130
130
 
131
- it( 'should export the area description correctly' ) do
132
- @area_hash[ RCAP::CAP_1_0::Area::AREA_DESC_KEY ].should == @area.area_desc
131
+ it('should export the area description correctly') do
132
+ @area_hash[ RCAP::CAP_1_0::Area::AREA_DESC_KEY].should == @area.area_desc
133
133
  end
134
134
 
135
- it( 'should export the altitude correctly' ) do
136
- @area_hash[ RCAP::CAP_1_0::Area::ALTITUDE_KEY ].should == @area.altitude
135
+ it('should export the altitude correctly') do
136
+ @area_hash[ RCAP::CAP_1_0::Area::ALTITUDE_KEY].should == @area.altitude
137
137
  end
138
138
 
139
- it( 'should set the ceiling correctly' ) do
140
- @area_hash[ RCAP::CAP_1_0::Area::CEILING_KEY ].should == @area.ceiling
139
+ it('should set the ceiling correctly') do
140
+ @area_hash[ RCAP::CAP_1_0::Area::CEILING_KEY].should == @area.ceiling
141
141
  end
142
142
 
143
- it( 'should export the circles correctly' ) do
144
- @area_hash[ RCAP::CAP_1_0::Area::CIRCLES_KEY ].should == @area.circles.map{ |circle| circle.to_a }
143
+ it('should export the circles correctly') do
144
+ @area_hash[ RCAP::CAP_1_0::Area::CIRCLES_KEY].should == @area.circles.map { |circle| circle.to_a }
145
145
  end
146
146
 
147
- it( 'should export the geocodes correctly' ) do
148
- @area_hash[ RCAP::CAP_1_0::Area::GEOCODES_KEY ].should == @area.geocodes.map{ |geocode| geocode.to_h }
147
+ it('should export the geocodes correctly') do
148
+ @area_hash[ RCAP::CAP_1_0::Area::GEOCODES_KEY].should == @area.geocodes.map { |geocode| geocode.to_h }
149
149
  end
150
150
 
151
- it( 'should export the polygons correctly' ) do
152
- @area_hash[ RCAP::CAP_1_0::Area::POLYGONS_KEY ].should == @area.polygons.map{ |polygon| polygon.to_h }
151
+ it('should export the polygons correctly') do
152
+ @area_hash[ RCAP::CAP_1_0::Area::POLYGONS_KEY].should == @area.polygons.map { |polygon| polygon.to_h }
153
153
  end
154
154
  end
155
155
  end
156
156
 
157
- context( 'is not valid if' ) do
158
- before( :each ) do
157
+ context('is not valid if') do
158
+ before(:each) do
159
159
  @area = RCAP::CAP_1_0::Area.new do |area|
160
- area.area_desc = "Cape Town Metropole"
160
+ area.area_desc = 'Cape Town Metropole'
161
161
  end
162
- @area.should( be_valid )
162
+ @area.should(be_valid)
163
163
  end
164
164
 
165
- it( 'does not have an area descrtiption (area_desc)') do
165
+ it('does not have an area descrtiption (area_desc)') do
166
166
  @area.area_desc = nil
167
- @area.should_not( be_valid )
167
+ @area.should_not(be_valid)
168
168
  end
169
169
 
170
- it( 'has a ceiling defined but no altitude' ) do
170
+ it('has a ceiling defined but no altitude') do
171
171
  @area.ceiling = 1
172
172
  @area.altitude = nil
173
- @area.should_not( be_valid )
173
+ @area.should_not(be_valid)
174
174
  end
175
175
 
176
- context( 'it contains circles and it' ) do
177
- before( :each ) do
176
+ context('it contains circles and it') do
177
+ before(:each) do
178
178
  @area.add_circle do |circle|
179
179
  circle.lattitude = 0
180
180
  circle.longitude = 0
181
181
  circle.radius = 1
182
182
  end
183
- @area.should( be_valid )
183
+ @area.should(be_valid)
184
184
  end
185
185
 
186
- it( 'has an invalid circle' ) do
186
+ it('has an invalid circle') do
187
187
  @area.circles.first.lattitude = nil
188
- @area.should_not( be_valid )
188
+ @area.should_not(be_valid)
189
189
  end
190
190
  end
191
191
 
192
- context( 'it contains polygons and it' ) do
193
- before( :each ) do
192
+ context('it contains polygons and it') do
193
+ before(:each) do
194
194
  @polygon = RCAP::CAP_1_0::Polygon.new
195
- [[ 0, 0], [ 0, 1 ], [ 0, 0 ]].each do |lattitude, longitude|
195
+ [[0, 0], [0, 1], [0, 0]].each do |lattitude, longitude|
196
196
  @polygon.add_point do |point|
197
197
  point.lattitude = lattitude
198
198
  point.longitude = longitude
@@ -200,52 +200,52 @@ describe( RCAP::CAP_1_0::Area ) do
200
200
  end
201
201
 
202
202
  @area.polygons << @polygon
203
- @area.should( be_valid )
203
+ @area.should(be_valid)
204
204
  end
205
205
 
206
- it( 'has an invalid polygon' ) do
206
+ it('has an invalid polygon') do
207
207
  @polygon.points.first.lattitude = nil
208
- @area.should_not( be_valid )
208
+ @area.should_not(be_valid)
209
209
  end
210
210
  end
211
211
 
212
- context( 'it contains geocodes and it' ) do
213
- before( :each ) do
212
+ context('it contains geocodes and it') do
213
+ before(:each) do
214
214
  @area.add_geocode do |geocode|
215
215
  geocode.name = 'foo'
216
216
  geocode.value = 'bar'
217
217
  end
218
- @area.should( be_valid )
218
+ @area.should(be_valid)
219
219
  end
220
220
 
221
- it( 'has an invalid geocode' ) do
222
- @area.geocodes.first.value = nil
223
- @area.should_not( be_valid )
221
+ it('has an invalid geocode') do
222
+ @area.geocodes.first.name = nil
223
+ @area.should_not(be_valid)
224
224
  end
225
225
  end
226
226
  end
227
227
 
228
- describe( 'instance methods' ) do
229
- before( :each ) do
228
+ describe('instance methods') do
229
+ before(:each) do
230
230
  @area = RCAP::CAP_1_0::Area.new
231
231
  end
232
232
 
233
- describe( '#add_polygon' ) do
234
- before( :each ) do
233
+ describe('#add_polygon') do
234
+ before(:each) do
235
235
  @polygon = @area.add_polygon
236
236
  end
237
237
 
238
- it( 'should return a CAP 1.0 Polygon' ) do
238
+ it('should return a CAP 1.0 Polygon') do
239
239
  @polygon.class.should == RCAP::CAP_1_0::Polygon
240
240
  end
241
241
 
242
- it( 'should add a Polygon to the polygons attribute' ) do
242
+ it('should add a Polygon to the polygons attribute') do
243
243
  @area.polygons.size.should == 1
244
244
  end
245
245
  end
246
246
 
247
- describe( '#add_circle' ) do
248
- before( :each ) do
247
+ describe('#add_circle') do
248
+ before(:each) do
249
249
  @circle = @area.add_circle do |circle|
250
250
  circle.lattitude = 1
251
251
  circle.longitude = 1
@@ -253,33 +253,33 @@ describe( RCAP::CAP_1_0::Area ) do
253
253
  end
254
254
  end
255
255
 
256
- it( 'should return a CAP 1.0 Circle' ) do
256
+ it('should return a CAP 1.0 Circle') do
257
257
  @circle.class.should == RCAP::CAP_1_0::Circle
258
258
  @circle.lattitude.should == 1
259
259
  @circle.longitude.should == 1
260
260
  @circle.radius.should == 1
261
261
  end
262
262
 
263
- it( 'should add a circle to the circles attribute' ) do
263
+ it('should add a circle to the circles attribute') do
264
264
  @area.circles.size.should == 1
265
265
  end
266
266
  end
267
267
 
268
- describe( '#add_geocode' ) do
269
- before( :each ) do
268
+ describe('#add_geocode') do
269
+ before(:each) do
270
270
  @geocode = @area.add_geocode do |geocode|
271
271
  geocode.name = 'Geocode'
272
272
  geocode.value = '123'
273
273
  end
274
274
  end
275
275
 
276
- it( 'should return a CAP 1.0 Geocode' ) do
276
+ it('should return a CAP 1.0 Geocode') do
277
277
  @geocode.class.should == RCAP::CAP_1_0::Geocode
278
278
  @geocode.name.should == 'Geocode'
279
279
  @geocode.value.should == '123'
280
280
  end
281
281
 
282
- it( 'should add a geocode to the geocodes attribute' ) do
282
+ it('should add a geocode to the geocodes attribute') do
283
283
  @area.geocodes.size.should == 1
284
284
  end
285
285
  end