rcap 2.4.1 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/rcap/alert.rb +28 -29
  4. data/lib/rcap/base/alert.rb +192 -192
  5. data/lib/rcap/base/area.rb +84 -86
  6. data/lib/rcap/base/circle.rb +32 -32
  7. data/lib/rcap/base/info.rb +248 -253
  8. data/lib/rcap/base/parameter.rb +23 -24
  9. data/lib/rcap/base/point.rb +23 -23
  10. data/lib/rcap/base/polygon.rb +32 -32
  11. data/lib/rcap/base/resource.rb +57 -57
  12. data/lib/rcap/cap_1_0/alert.rb +79 -83
  13. data/lib/rcap/cap_1_0/area.rb +0 -2
  14. data/lib/rcap/cap_1_0/circle.rb +0 -1
  15. data/lib/rcap/cap_1_0/info.rb +1 -3
  16. data/lib/rcap/cap_1_0/parameter.rb +11 -12
  17. data/lib/rcap/cap_1_0/point.rb +0 -1
  18. data/lib/rcap/cap_1_0/polygon.rb +0 -2
  19. data/lib/rcap/cap_1_0/resource.rb +0 -3
  20. data/lib/rcap/cap_1_1/alert.rb +4 -6
  21. data/lib/rcap/cap_1_1/area.rb +0 -2
  22. data/lib/rcap/cap_1_1/circle.rb +0 -1
  23. data/lib/rcap/cap_1_1/info.rb +120 -129
  24. data/lib/rcap/cap_1_1/parameter.rb +0 -2
  25. data/lib/rcap/cap_1_1/point.rb +0 -1
  26. data/lib/rcap/cap_1_1/polygon.rb +0 -2
  27. data/lib/rcap/cap_1_1/resource.rb +32 -34
  28. data/lib/rcap/cap_1_2/alert.rb +4 -6
  29. data/lib/rcap/cap_1_2/area.rb +0 -2
  30. data/lib/rcap/cap_1_2/circle.rb +0 -1
  31. data/lib/rcap/cap_1_2/info.rb +114 -121
  32. data/lib/rcap/cap_1_2/parameter.rb +0 -2
  33. data/lib/rcap/cap_1_2/point.rb +0 -1
  34. data/lib/rcap/cap_1_2/polygon.rb +1 -3
  35. data/lib/rcap/cap_1_2/resource.rb +32 -34
  36. data/lib/rcap/config.rb +3 -3
  37. data/lib/rcap/custom_validators.rb +72 -76
  38. data/lib/rcap/extensions/array.rb +1 -1
  39. data/lib/rcap/extensions/date.rb +2 -2
  40. data/lib/rcap/extensions/date_time.rb +3 -3
  41. data/lib/rcap/extensions/string.rb +3 -3
  42. data/lib/rcap/extensions/time.rb +2 -3
  43. data/lib/rcap/info.rb +4 -5
  44. data/lib/rcap/utilities.rb +24 -25
  45. data/lib/rcap/validation.rb +19 -20
  46. data/lib/rcap/version.rb +1 -1
  47. data/spec/alert_spec.rb +141 -141
  48. data/spec/cap_1_0/alert_spec.rb +92 -94
  49. data/spec/cap_1_0/area_spec.rb +86 -86
  50. data/spec/cap_1_0/circle_spec.rb +39 -39
  51. data/spec/cap_1_0/event_code_spec.rb +15 -15
  52. data/spec/cap_1_0/geocode_spec.rb +16 -16
  53. data/spec/cap_1_0/info_spec.rb +175 -177
  54. data/spec/cap_1_0/parameter_spec.rb +27 -27
  55. data/spec/cap_1_0/point_spec.rb +18 -18
  56. data/spec/cap_1_0/polygon_spec.rb +38 -38
  57. data/spec/cap_1_0/resource_spec.rb +63 -64
  58. data/spec/cap_1_1/alert_spec.rb +107 -109
  59. data/spec/cap_1_1/area_spec.rb +90 -90
  60. data/spec/cap_1_1/circle_spec.rb +34 -34
  61. data/spec/cap_1_1/event_code_spec.rb +15 -16
  62. data/spec/cap_1_1/geocode_spec.rb +16 -16
  63. data/spec/cap_1_1/info_spec.rb +194 -196
  64. data/spec/cap_1_1/parameter_spec.rb +17 -17
  65. data/spec/cap_1_1/point_spec.rb +18 -18
  66. data/spec/cap_1_1/polygon_spec.rb +36 -36
  67. data/spec/cap_1_1/resource_spec.rb +106 -107
  68. data/spec/cap_1_2/alert_spec.rb +98 -99
  69. data/spec/cap_1_2/area_spec.rb +90 -90
  70. data/spec/cap_1_2/circle_spec.rb +43 -43
  71. data/spec/cap_1_2/event_code_spec.rb +19 -20
  72. data/spec/cap_1_2/geocode_spec.rb +20 -20
  73. data/spec/cap_1_2/info_spec.rb +196 -198
  74. data/spec/cap_1_2/parameter_spec.rb +19 -19
  75. data/spec/cap_1_2/point_spec.rb +21 -21
  76. data/spec/cap_1_2/polygon_spec.rb +47 -47
  77. data/spec/cap_1_2/resource_spec.rb +96 -97
  78. data/spec/extensions_spec.rb +29 -29
  79. data/spec/info_spec.rb +15 -15
  80. data/spec/spec_helper.rb +3 -3
  81. data/spec/validations_spec.rb +73 -73
  82. metadata +2 -2
@@ -1,100 +1,100 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe( RCAP::CAP_1_2::Circle ) do
4
- before( :each ) do
3
+ describe(RCAP::CAP_1_2::Circle) do
4
+ before(:each) do
5
5
  @circle_builder = lambda do |circle|
6
6
  circle.lattitude = 0
7
7
  circle.longitude = 0
8
8
  circle.radius = 1
9
9
  end
10
10
  end
11
- describe( '#to_s' ) do
12
- it( 'should return a correct string' ) do
13
- @circle = RCAP::CAP_1_2::Circle.new( &@circle_builder )
11
+ describe('#to_s') do
12
+ it('should return a correct string') do
13
+ @circle = RCAP::CAP_1_2::Circle.new(&@circle_builder)
14
14
  @circle.to_s.should == '0,0 1'
15
15
  end
16
16
  end
17
17
 
18
- context( 'should not be valid if' ) do
19
- before( :each ) do
20
- @circle = RCAP::CAP_1_2::Circle.new( &@circle_builder )
21
- @circle.should( be_valid )
18
+ context('should not be valid if') do
19
+ before(:each) do
20
+ @circle = RCAP::CAP_1_2::Circle.new(&@circle_builder)
21
+ @circle.should(be_valid)
22
22
  end
23
23
 
24
- it( 'does not have a lattitude defined' ) do
24
+ it('does not have a lattitude defined') do
25
25
  @circle.lattitude = nil
26
- @circle.should_not( be_valid )
26
+ @circle.should_not(be_valid)
27
27
  end
28
28
 
29
- it( 'does not have a longitude defined' ) do
29
+ it('does not have a longitude defined') do
30
30
  @circle.longitude = nil
31
- @circle.should_not( be_valid )
31
+ @circle.should_not(be_valid)
32
32
  end
33
33
 
34
- it( 'does not have a radius defined' ) do
34
+ it('does not have a radius defined') do
35
35
  @circle.radius = nil
36
- @circle.should_not( be_valid )
36
+ @circle.should_not(be_valid)
37
37
  end
38
38
 
39
- it( 'does not have a numeric radius' ) do
40
- @circle.radius = "not a number"
41
- @circle.should_not( be_valid )
39
+ it('does not have a numeric radius') do
40
+ @circle.radius = 'not a number'
41
+ @circle.should_not(be_valid)
42
42
  end
43
43
 
44
- it( 'does not have a positive radius' ) do
44
+ it('does not have a positive radius') do
45
45
  @circle.radius = -1
46
- @circle.should_not( be_valid )
46
+ @circle.should_not(be_valid)
47
47
  end
48
48
  end
49
49
 
50
- context( 'on initialisation' ) do
51
- context( 'from XML' ) do
52
- before( :each ) do
53
- @original_circle = RCAP::CAP_1_2::Circle.new( &@circle_builder )
50
+ context('on initialisation') do
51
+ context('from XML') do
52
+ before(:each) do
53
+ @original_circle = RCAP::CAP_1_2::Circle.new(&@circle_builder)
54
54
  @alert = RCAP::CAP_1_2::Alert.new
55
- @alert.add_info.add_area.add_circle( &@circle_builder )
55
+ @alert.add_info.add_area.add_circle(&@circle_builder)
56
56
  @xml_string = @alert.to_xml
57
- @xml_document = REXML::Document.new( @xml_string )
58
- @info_element = RCAP.xpath_first( @xml_document.root, RCAP::CAP_1_2::Info::XPATH, RCAP::CAP_1_2::Alert::XMLNS )
59
- @area_element = RCAP.xpath_first( @info_element, RCAP::CAP_1_2::Area::XPATH, RCAP::CAP_1_2::Alert::XMLNS )
60
- @circle_element = RCAP.xpath_first( @area_element, RCAP::CAP_1_2::Circle::XPATH, RCAP::CAP_1_2::Alert::XMLNS )
61
- @circle = RCAP::CAP_1_2::Circle.from_xml_element( @circle_element )
57
+ @xml_document = REXML::Document.new(@xml_string)
58
+ @info_element = RCAP.xpath_first(@xml_document.root, RCAP::CAP_1_2::Info::XPATH, RCAP::CAP_1_2::Alert::XMLNS)
59
+ @area_element = RCAP.xpath_first(@info_element, RCAP::CAP_1_2::Area::XPATH, RCAP::CAP_1_2::Alert::XMLNS)
60
+ @circle_element = RCAP.xpath_first(@area_element, RCAP::CAP_1_2::Circle::XPATH, RCAP::CAP_1_2::Alert::XMLNS)
61
+ @circle = RCAP::CAP_1_2::Circle.from_xml_element(@circle_element)
62
62
  end
63
63
 
64
- it( 'should parse the radius correctly' ) do
64
+ it('should parse the radius correctly') do
65
65
  @circle.radius.should == @original_circle.radius
66
66
  end
67
67
 
68
- it( 'should parse the lattitude and longitude correctly' ) do
68
+ it('should parse the lattitude and longitude correctly') do
69
69
  @circle.lattitude.should == @original_circle.lattitude
70
70
  @circle.longitude.should == @original_circle.longitude
71
71
  end
72
72
  end
73
73
 
74
- context( 'from a hash' ) do
75
- before( :each ) do
76
- @original_circle = RCAP::CAP_1_2::Circle.new( &@circle_builder )
77
- @circle = RCAP::CAP_1_2::Circle.from_h( @original_circle.to_h )
74
+ context('from a hash') do
75
+ before(:each) do
76
+ @original_circle = RCAP::CAP_1_2::Circle.new(&@circle_builder)
77
+ @circle = RCAP::CAP_1_2::Circle.from_h(@original_circle.to_h)
78
78
  end
79
79
 
80
- it( 'should set the radius correctly' ) do
80
+ it('should set the radius correctly') do
81
81
  @circle.radius.should == @original_circle.radius
82
82
  end
83
83
 
84
- it( 'should parse the lattitude and longitude correctly' ) do
84
+ it('should parse the lattitude and longitude correctly') do
85
85
  @circle.lattitude.should == @original_circle.lattitude
86
86
  @circle.longitude.should == @original_circle.longitude
87
87
  end
88
88
  end
89
89
  end
90
90
 
91
- context( 'when exported' ) do
92
- before( :each ) do
93
- @circle = RCAP::CAP_1_2::Circle.new( &@circle_builder )
91
+ context('when exported') do
92
+ before(:each) do
93
+ @circle = RCAP::CAP_1_2::Circle.new(&@circle_builder)
94
94
  end
95
95
 
96
- context( 'to hash' ) do
97
- it( 'should be correct' ) do
96
+ context('to hash') do
97
+ it('should be correct') do
98
98
  @circle.to_h.should == { 'radius' => 1, 'lattitude' => 0, 'longitude' => 0 }
99
99
  end
100
100
  end
@@ -1,50 +1,49 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe( RCAP::CAP_1_2::EventCode ) do
4
- before( :each ) do
3
+ describe(RCAP::CAP_1_2::EventCode) do
4
+ before(:each) do
5
5
  @event_code_builder = lambda do |event_code|
6
6
  event_code.name = 'name'
7
7
  event_code.value = 'value'
8
8
  end
9
9
  end
10
10
 
11
- context( 'when initialised' ) do
12
- context( 'from XML' ) do
13
- before( :each ) do
14
- @original_event_code = RCAP::CAP_1_2::EventCode.new( &@event_code_builder )
11
+ context('when initialised') do
12
+ context('from XML') do
13
+ before(:each) do
14
+ @original_event_code = RCAP::CAP_1_2::EventCode.new(&@event_code_builder)
15
15
  @alert = RCAP::CAP_1_2::Alert.new
16
- @alert.add_info.add_event_code( &@event_code_builder )
16
+ @alert.add_info.add_event_code(&@event_code_builder)
17
17
  @xml_string = @alert.to_xml
18
- @xml_document = REXML::Document.new( @xml_string )
19
- @info_xml_element = RCAP.xpath_first( @xml_document.root, RCAP::CAP_1_2::Info::XPATH, RCAP::CAP_1_2::Alert::XMLNS )
20
- @event_code_xml_element = RCAP.xpath_first( @info_xml_element, RCAP::CAP_1_2::EventCode::XPATH, RCAP::CAP_1_2::Alert::XMLNS )
21
- @event_code = RCAP::CAP_1_2::EventCode.from_xml_element( @event_code_xml_element )
18
+ @xml_document = REXML::Document.new(@xml_string)
19
+ @info_xml_element = RCAP.xpath_first(@xml_document.root, RCAP::CAP_1_2::Info::XPATH, RCAP::CAP_1_2::Alert::XMLNS)
20
+ @event_code_xml_element = RCAP.xpath_first(@info_xml_element, RCAP::CAP_1_2::EventCode::XPATH, RCAP::CAP_1_2::Alert::XMLNS)
21
+ @event_code = RCAP::CAP_1_2::EventCode.from_xml_element(@event_code_xml_element)
22
22
  end
23
23
 
24
- it( 'should parse into the correct class' ) do
24
+ it('should parse into the correct class') do
25
25
  @event_code.class.should == RCAP::CAP_1_2::EventCode
26
26
  end
27
27
 
28
- it( 'should parse the name correctly' ) do
28
+ it('should parse the name correctly') do
29
29
  @event_code.name.should == @original_event_code.name
30
30
  end
31
31
 
32
- it( 'should parse the value correctly' ) do
32
+ it('should parse the value correctly') do
33
33
  @event_code.value.should == @original_event_code.value
34
34
  end
35
35
  end
36
36
  end
37
37
 
38
- context( 'when exported' ) do
39
- before( :each ) do
40
- @event_code = RCAP::CAP_1_2::EventCode.new( &@event_code_builder )
38
+ context('when exported') do
39
+ before(:each) do
40
+ @event_code = RCAP::CAP_1_2::EventCode.new(&@event_code_builder)
41
41
  end
42
42
 
43
- context( 'to a hash' ) do
44
- it( 'should export correctly' ) do
43
+ context('to a hash') do
44
+ it('should export correctly') do
45
45
  @event_code.to_h.should == { 'name' => 'value' }
46
46
  end
47
47
  end
48
48
  end
49
49
  end
50
-
@@ -1,48 +1,48 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe( RCAP::CAP_1_2::Geocode ) do
4
- before( :each ) do
3
+ describe(RCAP::CAP_1_2::Geocode) do
4
+ before(:each) do
5
5
  @geocode_builder = lambda do |geocode|
6
6
  geocode.name = 'name'
7
7
  geocode.value = 'value'
8
8
  end
9
9
  end
10
10
 
11
- context( 'when initialised' ) do
12
- context( 'from XML' ) do
13
- before( :each ) do
14
- @original_geocode = RCAP::CAP_1_2::Geocode.new( &@geocode_builder )
11
+ context('when initialised') do
12
+ context('from XML') do
13
+ before(:each) do
14
+ @original_geocode = RCAP::CAP_1_2::Geocode.new(&@geocode_builder)
15
15
  @alert = RCAP::CAP_1_2::Alert.new
16
- @alert.add_info.add_area.add_geocode( &@geocode_builder )
16
+ @alert.add_info.add_area.add_geocode(&@geocode_builder)
17
17
  @xml_string = @alert.to_xml
18
- @xml_document = REXML::Document.new( @xml_string )
19
- @info_xml_element = RCAP.xpath_first( @xml_document.root, RCAP::CAP_1_2::Info::XPATH, RCAP::CAP_1_2::Alert::XMLNS )
20
- @area_xml_element = RCAP.xpath_first( @info_xml_element, RCAP::CAP_1_2::Area::XPATH, RCAP::CAP_1_2::Alert::XMLNS )
21
- @geocode_xml_element = RCAP.xpath_first( @area_xml_element, RCAP::CAP_1_2::Geocode::XPATH, RCAP::CAP_1_2::Alert::XMLNS )
22
- @geocode = RCAP::CAP_1_2::Geocode.from_xml_element( @geocode_xml_element )
18
+ @xml_document = REXML::Document.new(@xml_string)
19
+ @info_xml_element = RCAP.xpath_first(@xml_document.root, RCAP::CAP_1_2::Info::XPATH, RCAP::CAP_1_2::Alert::XMLNS)
20
+ @area_xml_element = RCAP.xpath_first(@info_xml_element, RCAP::CAP_1_2::Area::XPATH, RCAP::CAP_1_2::Alert::XMLNS)
21
+ @geocode_xml_element = RCAP.xpath_first(@area_xml_element, RCAP::CAP_1_2::Geocode::XPATH, RCAP::CAP_1_2::Alert::XMLNS)
22
+ @geocode = RCAP::CAP_1_2::Geocode.from_xml_element(@geocode_xml_element)
23
23
  end
24
24
 
25
- it( 'should parse into the correct class' ) do
25
+ it('should parse into the correct class') do
26
26
  @geocode.class.should == RCAP::CAP_1_2::Geocode
27
27
  end
28
28
 
29
- it( 'should parse the name correctly' ) do
29
+ it('should parse the name correctly') do
30
30
  @geocode.name.should == @original_geocode.name
31
31
  end
32
32
 
33
- it( 'should parse the value correctly' ) do
33
+ it('should parse the value correctly') do
34
34
  @geocode.value.should == @original_geocode.value
35
35
  end
36
36
  end
37
37
  end
38
38
 
39
- context( 'when exported' ) do
40
- before( :each ) do
41
- @geocode = RCAP::CAP_1_2::Geocode.new( &@geocode_builder )
39
+ context('when exported') do
40
+ before(:each) do
41
+ @geocode = RCAP::CAP_1_2::Geocode.new(&@geocode_builder)
42
42
  end
43
43
 
44
- context( 'to a hash' ) do
45
- it( 'should export correctly' ) do
44
+ context('to a hash') do
45
+ it('should export correctly') do
46
46
  @geocode.to_h.should == { 'name' => 'value' }
47
47
  end
48
48
  end
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe( RCAP::CAP_1_2::Info ) do
4
- before( :each ) do
3
+ describe(RCAP::CAP_1_2::Info) do
4
+ before(:each) do
5
5
 
6
6
  @info_builder = lambda do |info|
7
7
  info.categories << RCAP::CAP_1_2::Info::CATEGORY_GEO
8
8
  info.categories << RCAP::CAP_1_2::Info::CATEGORY_FIRE
9
- info.event ='Event Description'
9
+ info.event = 'Event Description'
10
10
  info.response_types << RCAP::CAP_1_2::Info::RESPONSE_TYPE_MONITOR
11
11
  info.response_types << RCAP::CAP_1_2::Info::RESPONSE_TYPE_ASSESS
12
12
  info.urgency = RCAP::CAP_1_2::Info::URGENCY_IMMEDIATE
@@ -22,7 +22,7 @@ describe( RCAP::CAP_1_2::Info ) do
22
22
  info.instruction = 'Instruction'
23
23
  info.web = 'http://website'
24
24
  info.contact = 'contact@address'
25
- [[ 'name1', 'value1' ], [ 'name2', 'value2' ]].each do |name, value|
25
+ [%w(name1 value1), %w(name2 value2)].each do |name, value|
26
26
  info.add_event_code do |event_code|
27
27
  event_code.name = name
28
28
  event_code.value = value
@@ -30,18 +30,18 @@ describe( RCAP::CAP_1_2::Info ) do
30
30
  end
31
31
 
32
32
  info.add_resource do |resource|
33
- resource.resource_desc = "Resource"
34
- resource.mime_type = "mime/type"
33
+ resource.resource_desc = 'Resource'
34
+ resource.mime_type = 'mime/type'
35
35
  end
36
36
 
37
- [[ 'name1', 'value1' ], [ 'name2', 'value2' ]].each do |name, value|
37
+ [%w(name1 value1), %w(name2 value2)].each do |name, value|
38
38
  info.add_parameter do |parameter|
39
39
  parameter.name = name
40
40
  parameter.value = value
41
41
  end
42
42
  end
43
43
 
44
- [ 'Area1', 'Area2' ].each do |area_desc|
44
+ %w(Area1 Area2).each do |area_desc|
45
45
  info.add_area do |area|
46
46
  area.area_desc = area_desc
47
47
  end
@@ -49,181 +49,180 @@ describe( RCAP::CAP_1_2::Info ) do
49
49
  end
50
50
  end
51
51
 
52
- context( 'on initialisation' ) do
53
- before( :each ) do
52
+ context('on initialisation') do
53
+ before(:each) do
54
54
  @info = RCAP::CAP_1_2::Info.new
55
55
  end
56
56
 
57
- it( 'should have a default language of en-US' ) do
57
+ it('should have a default language of en-US') do
58
58
  @info.language.should == 'en-US'
59
59
  end
60
60
 
61
- it( 'should have no categories' ) do
62
- @info.categories.should( be_empty )
61
+ it('should have no categories') do
62
+ @info.categories.should(be_empty)
63
63
  end
64
64
 
65
- it( 'should have no event' ) do
66
- @info.event.should( be_nil )
65
+ it('should have no event') do
66
+ @info.event.should(be_nil)
67
67
  end
68
68
 
69
- it( 'should have no response types' ) do
70
- @info.response_types.should( be_empty )
69
+ it('should have no response types') do
70
+ @info.response_types.should(be_empty)
71
71
  end
72
72
 
73
- it( 'should have no urgency' ) do
74
- @info.urgency.should( be_nil )
73
+ it('should have no urgency') do
74
+ @info.urgency.should(be_nil)
75
75
  end
76
76
 
77
- it( 'should have no severity' ) do
78
- @info.severity.should( be_nil )
77
+ it('should have no severity') do
78
+ @info.severity.should(be_nil)
79
79
  end
80
80
 
81
- it( 'should have no certainty' ) do
82
- @info.certainty.should( be_nil )
81
+ it('should have no certainty') do
82
+ @info.certainty.should(be_nil)
83
83
  end
84
84
 
85
- it( 'should have no audience' ) do
86
- @info.audience.should( be_nil )
85
+ it('should have no audience') do
86
+ @info.audience.should(be_nil)
87
87
  end
88
88
 
89
- it( 'should have no event_codes' ) do
90
- @info.event_codes.should( be_empty )
89
+ it('should have no event_codes') do
90
+ @info.event_codes.should(be_empty)
91
91
  end
92
92
 
93
- it( 'should have no effective datetime' ) do
94
- @info.effective.should( be_nil )
93
+ it('should have no effective datetime') do
94
+ @info.effective.should(be_nil)
95
95
  end
96
96
 
97
- it( 'should have no onset datetime' ) do
98
- @info.onset.should( be_nil )
97
+ it('should have no onset datetime') do
98
+ @info.onset.should(be_nil)
99
99
  end
100
100
 
101
- it( 'should have no expires datetime' ) do
102
- @info.expires.should( be_nil )
101
+ it('should have no expires datetime') do
102
+ @info.expires.should(be_nil)
103
103
  end
104
104
 
105
- it( 'should have no sender name ' ) do
106
- @info.sender_name.should( be_nil )
105
+ it('should have no sender name ') do
106
+ @info.sender_name.should(be_nil)
107
107
  end
108
108
 
109
- it( 'should have no headline' ) do
110
- @info.headline.should( be_nil )
109
+ it('should have no headline') do
110
+ @info.headline.should(be_nil)
111
111
  end
112
112
 
113
- it( 'should have no description' ) do
114
- @info.description.should( be_nil )
113
+ it('should have no description') do
114
+ @info.description.should(be_nil)
115
115
  end
116
116
 
117
- it( 'should have no instruction' ) do
118
- @info.instruction.should( be_nil )
117
+ it('should have no instruction') do
118
+ @info.instruction.should(be_nil)
119
119
  end
120
120
 
121
- it( 'should have no web' ) do
122
- @info.web.should( be_nil )
121
+ it('should have no web') do
122
+ @info.web.should(be_nil)
123
123
  end
124
124
 
125
- it( 'should have no contact' ) do
126
- @info.contact.should( be_nil )
125
+ it('should have no contact') do
126
+ @info.contact.should(be_nil)
127
127
  end
128
128
 
129
- it( 'should have no parameters' ) do
130
- @info.parameters.should( be_empty )
129
+ it('should have no parameters') do
130
+ @info.parameters.should(be_empty)
131
131
  end
132
132
 
133
-
134
- shared_examples_for( 'it can parse into a CAP 1.2 Info object' ) do
135
- it( 'should parse categories correctly' ) do
136
- @info.categories.should_not( be_empty )
133
+ shared_examples_for('it can parse into a CAP 1.2 Info object') do
134
+ it('should parse categories correctly') do
135
+ @info.categories.should_not(be_empty)
137
136
  @info.categories.should == @original_info.categories
138
137
  end
139
138
 
140
- it( 'should parse event correctly' ) do
141
- @info.event.should_not( be_nil )
139
+ it('should parse event correctly') do
140
+ @info.event.should_not(be_nil)
142
141
  @info.event.should == @original_info.event
143
142
  end
144
143
 
145
- it( 'should parse response_types correctly' ) do
146
- @info.response_types.should_not( be_nil )
144
+ it('should parse response_types correctly') do
145
+ @info.response_types.should_not(be_nil)
147
146
  @info.response_types.should == @original_info.response_types
148
147
  end
149
148
 
150
- it( 'should parse urgency correctly' ) do
151
- @info.urgency.should_not( be_nil )
149
+ it('should parse urgency correctly') do
150
+ @info.urgency.should_not(be_nil)
152
151
  @info.urgency.should == @original_info.urgency
153
152
  end
154
153
 
155
- it( 'should parse severity correctly' ) do
156
- @info.severity.should_not( be_nil )
154
+ it('should parse severity correctly') do
155
+ @info.severity.should_not(be_nil)
157
156
  @info.severity.should == @original_info.severity
158
157
  end
159
158
 
160
- it( 'should parse certainty correctly' ) do
161
- @info.certainty.should_not( be_nil )
159
+ it('should parse certainty correctly') do
160
+ @info.certainty.should_not(be_nil)
162
161
  @info.certainty.should == @original_info.certainty
163
162
  end
164
163
 
165
- it( 'should parse audience correctly' ) do
166
- @info.audience.should_not( be_nil )
164
+ it('should parse audience correctly') do
165
+ @info.audience.should_not(be_nil)
167
166
  @info.audience.should == @original_info.audience
168
167
  end
169
168
 
170
- it( 'should parse effective correctly' ) do
171
- @info.effective.should_not( be_nil )
172
- @info.effective.should( be_within(Rational( 1, 86400 )).of( @original_info.effective ))
169
+ it('should parse effective correctly') do
170
+ @info.effective.should_not(be_nil)
171
+ @info.effective.should(be_within(Rational(1, 86_400)).of(@original_info.effective))
173
172
  end
174
173
 
175
- it( 'should parse onset correctly' ) do
176
- @info.onset.should_not( be_nil )
177
- @info.onset.should( be_within( Rational( 1, 86400 )).of( @original_info.onset ))
174
+ it('should parse onset correctly') do
175
+ @info.onset.should_not(be_nil)
176
+ @info.onset.should(be_within(Rational(1, 86_400)).of(@original_info.onset))
178
177
  end
179
178
 
180
- it( 'should parse expires correctly' ) do
181
- @info.expires.should_not( be_nil )
182
- @info.expires.should( be_within( Rational( 1, 86400 )).of( @original_info.expires ))
179
+ it('should parse expires correctly') do
180
+ @info.expires.should_not(be_nil)
181
+ @info.expires.should(be_within(Rational(1, 86_400)).of(@original_info.expires))
183
182
  end
184
183
 
185
- it( 'should parse sender_name correctly' ) do
186
- @info.sender_name.should_not( be_nil )
184
+ it('should parse sender_name correctly') do
185
+ @info.sender_name.should_not(be_nil)
187
186
  @info.sender_name.should == @original_info.sender_name
188
187
  end
189
188
 
190
- it( 'should parse headline correctly' ) do
191
- @info.headline.should_not( be_nil )
189
+ it('should parse headline correctly') do
190
+ @info.headline.should_not(be_nil)
192
191
  @info.headline.should == @original_info.headline
193
192
  end
194
193
 
195
- it( 'should parse description correctly' ) do
196
- @info.description.should_not( be_nil )
194
+ it('should parse description correctly') do
195
+ @info.description.should_not(be_nil)
197
196
  @info.description.should == @original_info.description
198
197
  end
199
198
 
200
- it( 'should parse instruction correctly' ) do
201
- @info.instruction.should_not( be_nil )
199
+ it('should parse instruction correctly') do
200
+ @info.instruction.should_not(be_nil)
202
201
  @info.instruction.should == @original_info.instruction
203
202
  end
204
203
 
205
- it( 'should parse web correctly' ) do
206
- @info.web.should_not( be_nil )
204
+ it('should parse web correctly') do
205
+ @info.web.should_not(be_nil)
207
206
  @info.web.should == @original_info.web
208
207
  end
209
208
 
210
- it( 'should parse contact correctly' ) do
211
- @info.contact.should_not( be_nil )
209
+ it('should parse contact correctly') do
210
+ @info.contact.should_not(be_nil)
212
211
  @info.contact.should == @original_info.contact
213
212
  end
214
213
 
215
- it( 'should parse event_codes correctly' ) do
216
- @info.event_codes.should_not( be_nil )
214
+ it('should parse event_codes correctly') do
215
+ @info.event_codes.should_not(be_nil)
217
216
  @info.event_codes.should == @original_info.event_codes
218
217
  end
219
218
 
220
- it( 'should parse parameters correctly' ) do
221
- @info.parameters.should_not( be_nil )
219
+ it('should parse parameters correctly') do
220
+ @info.parameters.should_not(be_nil)
222
221
  @info.parameters.should == @original_info.parameters
223
222
  end
224
223
 
225
- it( 'should parse resources correctly' ) do
226
- @info.resources.should_not( be_nil )
224
+ it('should parse resources correctly') do
225
+ @info.resources.should_not(be_nil)
227
226
  comparison_attributes = lambda do |resource|
228
227
  [
229
228
  resource.resource_desc,
@@ -231,48 +230,48 @@ describe( RCAP::CAP_1_2::Info ) do
231
230
  resource.uri
232
231
  ]
233
232
  end
234
- @info.resources.map( &comparison_attributes ).should == @original_info.resources.map( &comparison_attributes )
233
+ @info.resources.map(&comparison_attributes).should == @original_info.resources.map(&comparison_attributes)
235
234
  end
236
235
 
237
- it( 'should parse areas correctly' ) do
238
- @info.areas.should_not( be_nil )
236
+ it('should parse areas correctly') do
237
+ @info.areas.should_not(be_nil)
239
238
  @info.areas.should == @original_info.areas
240
239
  end
241
240
  end
242
241
 
243
- context( 'from XML' ) do
244
- before( :each ) do
245
- @original_info = RCAP::CAP_1_2::Info.new( &@info_builder )
242
+ context('from XML') do
243
+ before(:each) do
244
+ @original_info = RCAP::CAP_1_2::Info.new(&@info_builder)
246
245
  @alert = RCAP::CAP_1_2::Alert.new
247
- @alert.add_info( &@info_builder )
246
+ @alert.add_info(&@info_builder)
248
247
  @xml_string = @alert.to_xml
249
- @xml_document = REXML::Document.new( @xml_string )
250
- @info = RCAP::CAP_1_2::Info.from_xml_element( RCAP.xpath_first( @xml_document.root, RCAP::CAP_1_2::Info::XPATH, RCAP::CAP_1_2::Alert::XMLNS ))
248
+ @xml_document = REXML::Document.new(@xml_string)
249
+ @info = RCAP::CAP_1_2::Info.from_xml_element(RCAP.xpath_first(@xml_document.root, RCAP::CAP_1_2::Info::XPATH, RCAP::CAP_1_2::Alert::XMLNS))
251
250
  end
252
251
 
253
- it_should_behave_like( "it can parse into a CAP 1.2 Info object" )
252
+ it_should_behave_like('it can parse into a CAP 1.2 Info object')
254
253
  end
255
254
 
256
- context( 'from a hash' ) do
257
- before( :each ) do
258
- @original_info = RCAP::CAP_1_2::Info.new( &@info_builder )
259
- @info = RCAP::CAP_1_2::Info.from_h( @original_info.to_h )
255
+ context('from a hash') do
256
+ before(:each) do
257
+ @original_info = RCAP::CAP_1_2::Info.new(&@info_builder)
258
+ @info = RCAP::CAP_1_2::Info.from_h(@original_info.to_h)
260
259
  end
261
- it_should_behave_like( "it can parse into a CAP 1.2 Info object" )
260
+ it_should_behave_like('it can parse into a CAP 1.2 Info object')
262
261
  end
263
262
 
264
- context( 'from yaml_data' ) do
265
- before( :each ) do
266
- @original_info = RCAP::CAP_1_2::Info.new( &@info_builder )
267
- @info = RCAP::CAP_1_2::Info.from_yaml_data( YAML.load( @original_info.to_yaml ))
263
+ context('from yaml_data') do
264
+ before(:each) do
265
+ @original_info = RCAP::CAP_1_2::Info.new(&@info_builder)
266
+ @info = RCAP::CAP_1_2::Info.from_yaml_data(YAML.load(@original_info.to_yaml))
268
267
  end
269
268
 
270
- it_should_behave_like( "it can parse into a CAP 1.2 Info object" )
269
+ it_should_behave_like('it can parse into a CAP 1.2 Info object')
271
270
  end
272
271
  end
273
272
 
274
- context( 'is not valid if it' ) do
275
- before( :each ) do
273
+ context('is not valid if it') do
274
+ before(:each) do
276
275
  @info = RCAP::CAP_1_2::Info.new do |info|
277
276
  info.event = 'Info Event'
278
277
  info.categories << RCAP::CAP_1_2::Info::CATEGORY_GEO
@@ -282,202 +281,201 @@ describe( RCAP::CAP_1_2::Info ) do
282
281
  end
283
282
 
284
283
  @info.valid?
285
- @info.should( be_valid )
284
+ @info.should(be_valid)
286
285
  end
287
286
 
288
- it( 'does not have an event' ) do
287
+ it('does not have an event') do
289
288
  @info.event = nil
290
- @info.should_not( be_valid )
289
+ @info.should_not(be_valid)
291
290
  end
292
291
 
293
- it( 'does not have categories' ) do
292
+ it('does not have categories') do
294
293
  @info.categories.clear
295
- @info.should_not( be_valid )
294
+ @info.should_not(be_valid)
296
295
  end
297
296
 
298
- it( 'does not have an urgency' ) do
297
+ it('does not have an urgency') do
299
298
  @info.urgency = nil
300
- @info.should_not( be_valid )
299
+ @info.should_not(be_valid)
301
300
  end
302
301
 
303
- it( 'does not have an severity' ) do
302
+ it('does not have an severity') do
304
303
  @info.severity = nil
305
- @info.should_not( be_valid )
304
+ @info.should_not(be_valid)
306
305
  end
307
306
 
308
- it( 'does not have an certainty' ) do
307
+ it('does not have an certainty') do
309
308
  @info.certainty = nil
310
- @info.should_not( be_valid )
309
+ @info.should_not(be_valid)
311
310
  end
312
311
  end
313
312
 
314
-
315
- describe( 'when exported' ) do
316
- context( 'to hash' ) do
317
- before( :each ) do
318
- @info = RCAP::CAP_1_2::Info.new( &@info_builder )
313
+ describe('when exported') do
314
+ context('to hash') do
315
+ before(:each) do
316
+ @info = RCAP::CAP_1_2::Info.new(&@info_builder)
319
317
  @info_hash = @info.to_h
320
318
  end
321
319
 
322
- it( 'should export the language correctly' ) do
323
- @info_hash[ RCAP::CAP_1_2::Info::LANGUAGE_KEY ].should == @info.language
320
+ it('should export the language correctly') do
321
+ @info_hash[ RCAP::CAP_1_2::Info::LANGUAGE_KEY].should == @info.language
324
322
  end
325
323
 
326
- it( 'should export the categories' ) do
327
- @info_hash[ RCAP::CAP_1_2::Info::CATEGORIES_KEY ].should == @info.categories
324
+ it('should export the categories') do
325
+ @info_hash[ RCAP::CAP_1_2::Info::CATEGORIES_KEY].should == @info.categories
328
326
  end
329
327
 
330
- it( 'should export the event' ) do
331
- @info_hash[ RCAP::CAP_1_2::Info::EVENT_KEY ].should == @info.event
328
+ it('should export the event') do
329
+ @info_hash[ RCAP::CAP_1_2::Info::EVENT_KEY].should == @info.event
332
330
  end
333
331
 
334
- it( 'should export the response types' ) do
335
- @info_hash[ RCAP::CAP_1_2::Info::RESPONSE_TYPES_KEY ].should == @info.response_types
332
+ it('should export the response types') do
333
+ @info_hash[ RCAP::CAP_1_2::Info::RESPONSE_TYPES_KEY].should == @info.response_types
336
334
  end
337
335
 
338
- it( 'should export the urgency' ) do
339
- @info_hash[ RCAP::CAP_1_2::Info:: URGENCY_KEY ].should == @info.urgency
336
+ it('should export the urgency') do
337
+ @info_hash[ RCAP::CAP_1_2::Info:: URGENCY_KEY].should == @info.urgency
340
338
  end
341
339
 
342
- it( 'should export the severity' ) do
343
- @info_hash[ RCAP::CAP_1_2::Info:: SEVERITY_KEY ].should == @info.severity
340
+ it('should export the severity') do
341
+ @info_hash[ RCAP::CAP_1_2::Info:: SEVERITY_KEY].should == @info.severity
344
342
  end
345
343
 
346
- it( 'should export the certainty' ) do
347
- @info_hash[ RCAP::CAP_1_2::Info:: CERTAINTY_KEY ].should == @info.certainty
344
+ it('should export the certainty') do
345
+ @info_hash[ RCAP::CAP_1_2::Info:: CERTAINTY_KEY].should == @info.certainty
348
346
  end
349
347
 
350
- it( 'should export the audience' ) do
351
- @info_hash[ RCAP::CAP_1_2::Info:: AUDIENCE_KEY ].should == @info.audience
348
+ it('should export the audience') do
349
+ @info_hash[ RCAP::CAP_1_2::Info:: AUDIENCE_KEY].should == @info.audience
352
350
  end
353
351
 
354
- it( 'should export the effective date' ) do
355
- @info_hash[ RCAP::CAP_1_2::Info::EFFECTIVE_KEY ].should == @info.effective.to_s_for_cap
352
+ it('should export the effective date') do
353
+ @info_hash[ RCAP::CAP_1_2::Info::EFFECTIVE_KEY].should == @info.effective.to_s_for_cap
356
354
  end
357
355
 
358
- it( 'should export the onset date' ) do
359
- @info_hash[ RCAP::CAP_1_2::Info::ONSET_KEY ].should == @info.onset.to_s_for_cap
356
+ it('should export the onset date') do
357
+ @info_hash[ RCAP::CAP_1_2::Info::ONSET_KEY].should == @info.onset.to_s_for_cap
360
358
  end
361
359
 
362
- it( 'should export the expires date' ) do
363
- @info_hash[ RCAP::CAP_1_2::Info::EXPIRES_KEY ].should == @info.expires.to_s_for_cap
360
+ it('should export the expires date') do
361
+ @info_hash[ RCAP::CAP_1_2::Info::EXPIRES_KEY].should == @info.expires.to_s_for_cap
364
362
  end
365
363
 
366
- it( 'should export the sender name' ) do
367
- @info_hash[ RCAP::CAP_1_2::Info::SENDER_NAME_KEY ].should == @info.sender_name
368
- end
364
+ it('should export the sender name') do
365
+ @info_hash[ RCAP::CAP_1_2::Info::SENDER_NAME_KEY].should == @info.sender_name
366
+ end
369
367
 
370
- it( 'should export the headline' ) do
371
- @info_hash[ RCAP::CAP_1_2::Info::HEADLINE_KEY ].should == @info.headline
372
- end
368
+ it('should export the headline') do
369
+ @info_hash[ RCAP::CAP_1_2::Info::HEADLINE_KEY].should == @info.headline
370
+ end
373
371
 
374
- it( 'should export the description' ) do
375
- @info_hash[ RCAP::CAP_1_2::Info::DESCRIPTION_KEY ].should == @info.description
376
- end
372
+ it('should export the description') do
373
+ @info_hash[ RCAP::CAP_1_2::Info::DESCRIPTION_KEY].should == @info.description
374
+ end
377
375
 
378
- it( 'should export the instruction' ) do
379
- @info_hash[ RCAP::CAP_1_2::Info::INSTRUCTION_KEY ].should == @info.instruction
380
- end
376
+ it('should export the instruction') do
377
+ @info_hash[ RCAP::CAP_1_2::Info::INSTRUCTION_KEY].should == @info.instruction
378
+ end
381
379
 
382
- it( 'should export the web address ' ) do
383
- @info_hash[ RCAP::CAP_1_2::Info::WEB_KEY ].should == @info.web
384
- end
380
+ it('should export the web address ') do
381
+ @info_hash[ RCAP::CAP_1_2::Info::WEB_KEY].should == @info.web
382
+ end
385
383
 
386
- it( 'should export the contact' ) do
387
- @info_hash[ RCAP::CAP_1_2::Info::CONTACT_KEY ].should == @info.contact
388
- end
384
+ it('should export the contact') do
385
+ @info_hash[ RCAP::CAP_1_2::Info::CONTACT_KEY].should == @info.contact
386
+ end
389
387
 
390
- it( 'should export the event codes' ) do
391
- @info_hash[ RCAP::CAP_1_2::Info::EVENT_CODES_KEY ].should == @info.event_codes.map{ |event_code| event_code.to_h }
392
- end
388
+ it('should export the event codes') do
389
+ @info_hash[ RCAP::CAP_1_2::Info::EVENT_CODES_KEY].should == @info.event_codes.map { |event_code| event_code.to_h }
390
+ end
393
391
 
394
- it( 'should export the parameters ' ) do
395
- @info_hash[ RCAP::CAP_1_2::Info::PARAMETERS_KEY ].should == @info.parameters.map{ |parameter| parameter.to_h }
396
- end
392
+ it('should export the parameters ') do
393
+ @info_hash[ RCAP::CAP_1_2::Info::PARAMETERS_KEY].should == @info.parameters.map { |parameter| parameter.to_h }
394
+ end
397
395
 
398
- it( 'should export the resources ' ) do
399
- @info_hash[ RCAP::CAP_1_2::Info::RESOURCES_KEY ].should == @info.resources.map{ |resource| resource.to_h }
400
- end
396
+ it('should export the resources ') do
397
+ @info_hash[ RCAP::CAP_1_2::Info::RESOURCES_KEY].should == @info.resources.map { |resource| resource.to_h }
398
+ end
401
399
 
402
- it( 'should export the areas' ) do
403
- @info_hash[ RCAP::CAP_1_2::Info::AREAS_KEY ].should == @info.areas.map{ |area| area.to_h }
404
- end
400
+ it('should export the areas') do
401
+ @info_hash[ RCAP::CAP_1_2::Info::AREAS_KEY].should == @info.areas.map { |area| area.to_h }
402
+ end
405
403
  end
406
404
  end
407
405
 
408
- describe( 'instance methods' ) do
409
- before( :each ) do
406
+ describe('instance methods') do
407
+ before(:each) do
410
408
  @info = RCAP::CAP_1_2::Info.new
411
409
  end
412
410
 
413
- describe( '#add_event_code' ) do
414
- before( :each ) do
411
+ describe('#add_event_code') do
412
+ before(:each) do
415
413
  @event_code = @info.add_event_code do |event_code|
416
414
  event_code.name = 'Event Code'
417
415
  event_code.value = '1234'
418
416
  end
419
417
  end
420
418
 
421
- it( 'should return a 1.2 EventCode' ) do
419
+ it('should return a 1.2 EventCode') do
422
420
  @event_code.class.should == RCAP::CAP_1_2::EventCode
423
421
  @event_code.name.should == 'Event Code'
424
422
  @event_code.value.should == '1234'
425
423
  end
426
424
 
427
- it( 'should add an EventCode to the event_codes attribute' ) do
425
+ it('should add an EventCode to the event_codes attribute') do
428
426
  @info.event_codes.size.should == 1
429
427
  end
430
428
  end
431
429
 
432
- describe( '#add_parameter' ) do
433
- before( :each ) do
430
+ describe('#add_parameter') do
431
+ before(:each) do
434
432
  @parameter = @info.add_parameter do |parameter|
435
433
  parameter.name = 'Parameter'
436
434
  parameter.value = '1234'
437
435
  end
438
436
  end
439
437
 
440
- it( 'should return a 1.2 Parameter' ) do
438
+ it('should return a 1.2 Parameter') do
441
439
  @parameter.class.should == RCAP::CAP_1_2::Parameter
442
440
  @parameter.name.should == 'Parameter'
443
441
  @parameter.value.should == '1234'
444
442
  end
445
443
 
446
- it( 'should add a Parameter to the parameters attribute' ) do
444
+ it('should add a Parameter to the parameters attribute') do
447
445
  @info.parameters.size.should == 1
448
446
  end
449
447
  end
450
448
 
451
- describe( '#add_resource' ) do
452
- before( :each ) do
449
+ describe('#add_resource') do
450
+ before(:each) do
453
451
  @resource = @info.add_resource do |resource|
454
452
  resource.resource_desc = 'Resource'
455
453
  end
456
454
  end
457
455
 
458
- it( 'should return a 1.2 Resource' ) do
456
+ it('should return a 1.2 Resource') do
459
457
  @resource.class.should == RCAP::CAP_1_2::Resource
460
458
  @resource.resource_desc.should == 'Resource'
461
459
  end
462
460
 
463
- it( 'should add a Resource to the resources attribute' ) do
461
+ it('should add a Resource to the resources attribute') do
464
462
  @info.resources.size.should == 1
465
463
  end
466
464
  end
467
465
 
468
- describe( '#add_area' ) do
469
- before( :each ) do
466
+ describe('#add_area') do
467
+ before(:each) do
470
468
  @area = @info.add_area do |area|
471
469
  area.area_desc = 'Area'
472
470
  end
473
471
  end
474
472
 
475
- it( 'should return a 1.2 area' ) do
473
+ it('should return a 1.2 area') do
476
474
  @area.class.should == RCAP::CAP_1_2::Area
477
475
  @area.area_desc.should == 'Area'
478
476
  end
479
477
 
480
- it( 'should add a Area to the areas attribute' ) do
478
+ it('should add a Area to the areas attribute') do
481
479
  @info.areas.size.should == 1
482
480
  end
483
481
  end