rcap 2.4.1 → 2.7.3

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