rcap 2.4.1 → 2.5.0

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 (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,67 +1,67 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe( Array ) do
4
- describe( 'to_s_for_cap' ) do
5
- context( 'with an element containing white space' ) do
6
- before( :all ) do
7
- @list = [ 'one', 'white space', 'three' ]
3
+ describe(Array) do
4
+ describe('to_s_for_cap') do
5
+ context('with an element containing white space') do
6
+ before(:all) do
7
+ @list = ['one', 'white space', 'three']
8
8
  end
9
9
 
10
- it( 'should format the list correctly' ) do
10
+ it('should format the list correctly') do
11
11
  @list.to_s_for_cap.should == 'one "white space" three'
12
12
  end
13
13
  end
14
14
 
15
- context( 'without an element containing white space' ) do
16
- before( :all ) do
17
- @list = [ 'one', 'two', 'three' ]
15
+ context('without an element containing white space') do
16
+ before(:all) do
17
+ @list = %w(one two three)
18
18
  end
19
- it( 'should format the list correctly' ) do
19
+ it('should format the list correctly') do
20
20
  @list.to_s_for_cap.should == 'one two three'
21
21
  end
22
22
  end
23
23
  end
24
24
  end
25
25
 
26
- describe( String ) do
27
- describe( 'for_cap_list' ) do
28
- context( 'with white space' ) do
29
- before( :all ) do
26
+ describe(String) do
27
+ describe('for_cap_list') do
28
+ context('with white space') do
29
+ before(:all) do
30
30
  @string = 'white space'
31
31
  end
32
32
 
33
- it( 'should format the string correctly' ) do
33
+ it('should format the string correctly') do
34
34
  @string.for_cap_list.should == '"white space"'
35
35
  end
36
36
  end
37
37
 
38
- context( 'without white space' ) do
39
- before( :all ) do
40
- @string= 'one'
38
+ context('without white space') do
39
+ before(:all) do
40
+ @string = 'one'
41
41
  end
42
- it( 'should format the string correctly' ) do
42
+ it('should format the string correctly') do
43
43
  @string.for_cap_list.should == 'one'
44
44
  end
45
45
  end
46
46
  end
47
47
 
48
- describe( 'unpack_cap_list' ) do
49
- it( 'shoud unpack strings in quotes correctly' ) do
50
- 'Item1 "Item 2" Item3'.unpack_cap_list.should == [ "Item1", "Item 2", "Item3" ]
48
+ describe('unpack_cap_list') do
49
+ it('shoud unpack strings in quotes correctly') do
50
+ 'Item1 "Item 2" Item3'.unpack_cap_list.should == ['Item1', 'Item 2', 'Item3']
51
51
  end
52
52
 
53
- it( 'should unpack strings correclty' ) do
54
- 'Item1 Item2 Item3'.unpack_cap_list.should == [ "Item1", "Item2", "Item3" ]
53
+ it('should unpack strings correclty') do
54
+ 'Item1 Item2 Item3'.unpack_cap_list.should == %w(Item1 Item2 Item3)
55
55
  end
56
56
  end
57
57
 
58
- describe( 'attribute_values_to_hash' ) do
59
- it( 'should reject nil values' ) do
60
- RCAP.attribute_values_to_hash( ["a", nil ]).should == {}
58
+ describe('attribute_values_to_hash') do
59
+ it('should reject nil values') do
60
+ RCAP.attribute_values_to_hash(['a', nil]).should == {}
61
61
  end
62
62
 
63
- it( 'should not reject non-nil and non-empty values' ) do
64
- RCAP.attribute_values_to_hash( [ "a", 1 ], [ "b", [ 2 ]]).should == { "a" => 1, "b" => [ 2 ]}
63
+ it('should not reject non-nil and non-empty values') do
64
+ RCAP.attribute_values_to_hash(['a', 1], ['b', [2]]).should == { 'a' => 1, 'b' => [2] }
65
65
  end
66
66
  end
67
67
  end
@@ -1,34 +1,34 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe( RCAP::Info ) do
4
- describe( 'initialising' ) do
5
- context( 'a CAP 1.2 info' ) do
6
- let( :alert ) do
3
+ describe(RCAP::Info) do
4
+ describe('initialising') do
5
+ context('a CAP 1.2 info') do
6
+ let(:alert) do
7
7
  RCAP::CAP_1_2::Alert.new
8
8
  end
9
9
 
10
- let( :original_info ) do
10
+ let(:original_info) do
11
11
  RCAP::CAP_1_2::Info.new do |info|
12
- info.event = "Event"
12
+ info.event = 'Event'
13
13
  info.urgency = RCAP::CAP_1_2::Info::URGENCY_EXPECTED
14
14
  info.severity = RCAP::CAP_1_2::Info::SEVERITY_SEVERE
15
15
  info.certainty = RCAP::CAP_1_2::Info::CERTAINTY_LIKELY
16
16
  end
17
17
  end
18
18
 
19
- shared_examples_for( 'the 1.2 Info object is initialised correctly' ) do
20
- it( 'sets the event' ){ info.event.should == original_info.event }
21
- it( 'sets the urgency' ){ info.urgency.should == original_info.urgency }
22
- it( 'sets the severity' ){ info.severity.should == original_info.severity }
23
- it( 'sets the certainty' ){ info.certainty.should == original_info.certainty }
19
+ shared_examples_for('the 1.2 Info object is initialised correctly') do
20
+ it('sets the event') { info.event.should == original_info.event }
21
+ it('sets the urgency') { info.urgency.should == original_info.urgency }
22
+ it('sets the severity') { info.severity.should == original_info.severity }
23
+ it('sets the certainty') { info.certainty.should == original_info.certainty }
24
24
  end
25
25
 
26
- context( 'from a Hash' ) do
27
- let( :info ) do
28
- RCAP::Info.from_h( alert, original_info.to_h )
26
+ context('from a Hash') do
27
+ let(:info) do
28
+ RCAP::Info.from_h(alert, original_info.to_h)
29
29
  end
30
30
 
31
- it_should_behave_like( 'the 1.2 Info object is initialised correctly' )
31
+ it_should_behave_like('the 1.2 Info object is initialised correctly')
32
32
  end
33
33
  end
34
34
  end
@@ -2,7 +2,7 @@ require 'rcap'
2
2
  require 'webmock/rspec'
3
3
 
4
4
  def random_circle_hash
5
- { :lattitude => rand( 360 ) - 180,
6
- :longitude => rand( 180 ) - 90,
7
- :radius => rand( 50 ) }
5
+ { lattitude: rand(360) - 180,
6
+ longitude: rand(180) - 90,
7
+ radius: rand(50) }
8
8
  end
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  class ObjectWithValidatesCollection
4
4
  include Validation
5
- attr_accessor( :collection )
6
- validates_collection_of( :collection )
5
+ attr_accessor(:collection)
6
+ validates_collection_of(:collection)
7
7
  def initialize
8
8
  @collection = []
9
9
  end
@@ -11,54 +11,54 @@ end
11
11
 
12
12
  class DependencyObject
13
13
  include Validation
14
- attr_accessor( :dependent_value, :contingent_value )
15
- validates_dependency_of( :dependent_value, :on => :contingent_value )
14
+ attr_accessor(:dependent_value, :contingent_value)
15
+ validates_dependency_of(:dependent_value, on: :contingent_value)
16
16
  end
17
17
 
18
18
  class DependencyWithObject
19
19
  include Validation
20
- attr_accessor( :dependent_value, :contingent_value )
21
- validates_dependency_of( :dependent_value, :on => :contingent_value, :with_value => 1 )
20
+ attr_accessor(:dependent_value, :contingent_value)
21
+ validates_dependency_of(:dependent_value, on: :contingent_value, with_value: 1)
22
22
  end
23
23
 
24
24
  class ConditionalPresenceObject
25
25
  include Validation
26
- attr_accessor( :dependent_value, :contingent_value )
27
- validates_conditional_presence_of( :dependent_value, when: :contingent_value )
26
+ attr_accessor(:dependent_value, :contingent_value)
27
+ validates_conditional_presence_of(:dependent_value, when: :contingent_value)
28
28
  end
29
29
 
30
30
  class ConditionalPresenceIsObject
31
31
  include Validation
32
- attr_accessor( :dependent_value, :contingent_value )
33
- validates_conditional_presence_of( :dependent_value, when: :contingent_value, is: 1 )
32
+ attr_accessor(:dependent_value, :contingent_value)
33
+ validates_conditional_presence_of(:dependent_value, when: :contingent_value, is: 1)
34
34
  end
35
35
 
36
36
  class NumericalityObject
37
37
  include Validation
38
- attr_accessor( :gt, :gte )
38
+ attr_accessor(:gt, :gte)
39
39
 
40
- validates_numericality_of( :gt, greater_than: 0 )
41
- validates_numericality_of( :gte, greater_than_or_equal: 0 )
40
+ validates_numericality_of(:gt, greater_than: 0)
41
+ validates_numericality_of(:gte, greater_than_or_equal: 0)
42
42
  end
43
43
 
44
- describe( Validation::ClassMethods ) do
45
- describe( 'validates_collection_of' ) do
46
- before( :each ) do
44
+ describe(Validation::ClassMethods) do
45
+ describe('validates_collection_of') do
46
+ before(:each) do
47
47
  @object_with_collection = ObjectWithValidatesCollection.new
48
48
  end
49
49
 
50
- it( 'should be valid if all the members are valid' ) do
50
+ it('should be valid if all the members are valid') do
51
51
  @object_with_collection.collection = Array.new(3) do
52
52
  RCAP::CAP_1_1::Point.new do |point|
53
53
  point.lattitude = 0
54
54
  point.longitude = 0
55
55
  end
56
56
  end
57
- @object_with_collection.should( be_valid )
57
+ @object_with_collection.should(be_valid)
58
58
  end
59
59
 
60
- it( 'should not be valid some of the members are invalid' ) do
61
- @object_with_collection.collection = Array.new( 2 ) do
60
+ it('should not be valid some of the members are invalid') do
61
+ @object_with_collection.collection = Array.new(2) do
62
62
  RCAP::CAP_1_1::Point.new do |point|
63
63
  point.lattitude = 0
64
64
  point.longitude = 0
@@ -66,151 +66,151 @@ describe( Validation::ClassMethods ) do
66
66
  end
67
67
 
68
68
  @object_with_collection.collection << RCAP::CAP_1_1::Point.new do |point|
69
- point.lattitude = "not a number"
69
+ point.lattitude = 'not a number'
70
70
  point.longitude = 0
71
71
  end
72
72
 
73
- @object_with_collection.should_not( be_valid )
73
+ @object_with_collection.should_not(be_valid)
74
74
  end
75
75
  end
76
76
 
77
- describe( 'validates_dependency_of' ) do
78
- context( 'without :with_value' ) do
79
- before( :each ) do
77
+ describe('validates_dependency_of') do
78
+ context('without :with_value') do
79
+ before(:each) do
80
80
  @object = DependencyObject.new
81
81
  @object.dependent_value = 1
82
82
  @object.contingent_value = 1
83
- @object.should( be_valid )
83
+ @object.should(be_valid)
84
84
  end
85
85
 
86
- it( 'should not be valid if the contigent value is nil' ) do
86
+ it('should not be valid if the contigent value is nil') do
87
87
  @object.contingent_value = nil
88
- @object.should_not( be_valid )
88
+ @object.should_not(be_valid)
89
89
  end
90
90
 
91
- it( 'should be valid if the dependent value is nil' ) do
91
+ it('should be valid if the dependent value is nil') do
92
92
  @object.dependent_value = nil
93
- @object.should( be_valid )
93
+ @object.should(be_valid)
94
94
  end
95
95
 
96
- it( 'should be valid if both are nil' ) do
96
+ it('should be valid if both are nil') do
97
97
  @object.dependent_value = nil
98
98
  @object.contingent_value = nil
99
- @object.should( be_valid )
99
+ @object.should(be_valid)
100
100
  end
101
101
  end
102
102
 
103
- context( 'with :with_value' ) do
104
- before( :each ) do
103
+ context('with :with_value') do
104
+ before(:each) do
105
105
  @object = DependencyWithObject.new
106
106
  @object.dependent_value = 1
107
107
  @object.contingent_value = 1
108
- @object.should( be_valid )
108
+ @object.should(be_valid)
109
109
  end
110
110
 
111
- it( 'should not be valid if the contigent value is nil' ) do
111
+ it('should not be valid if the contigent value is nil') do
112
112
  @object.contingent_value = nil
113
- @object.should_not( be_valid )
113
+ @object.should_not(be_valid)
114
114
  end
115
115
 
116
- it( 'should not be valid if the contingent value is not the required value' ) do
116
+ it('should not be valid if the contingent value is not the required value') do
117
117
  @object.contingent_value = 0
118
- @object.should_not( be_valid )
118
+ @object.should_not(be_valid)
119
119
  end
120
120
 
121
- it( 'should be valid if the dependent value is nil' ) do
121
+ it('should be valid if the dependent value is nil') do
122
122
  @object.dependent_value = nil
123
- @object.should( be_valid )
123
+ @object.should(be_valid)
124
124
  end
125
125
 
126
- it( 'should be valid if both are nil' ) do
126
+ it('should be valid if both are nil') do
127
127
  @object.dependent_value = nil
128
128
  @object.contingent_value = nil
129
- @object.should( be_valid )
129
+ @object.should(be_valid)
130
130
  end
131
131
  end
132
132
  end
133
133
 
134
- describe( 'validates_conditional_presence_of' ) do
135
- context( 'without :is' ) do
136
- before( :each ) do
134
+ describe('validates_conditional_presence_of') do
135
+ context('without :is') do
136
+ before(:each) do
137
137
  @object = ConditionalPresenceObject.new
138
138
  @object.dependent_value = 1
139
139
  @object.contingent_value = 1
140
- @object.should( be_valid )
140
+ @object.should(be_valid)
141
141
  end
142
142
 
143
- it( 'should not be valid if dependent_value is nil' ) do
143
+ it('should not be valid if dependent_value is nil') do
144
144
  @object.dependent_value = nil
145
- @object.should_not( be_valid )
145
+ @object.should_not(be_valid)
146
146
  end
147
147
 
148
- it( 'should be valid if contingent_value is nil' ) do
148
+ it('should be valid if contingent_value is nil') do
149
149
  @object.contingent_value = nil
150
- @object.should( be_valid )
150
+ @object.should(be_valid)
151
151
  end
152
152
 
153
- it( 'should be valid if both dependent_value and contingent_value is nil' ) do
153
+ it('should be valid if both dependent_value and contingent_value is nil') do
154
154
  @object.dependent_value = nil
155
155
  @object.contingent_value = nil
156
- @object.should( be_valid )
156
+ @object.should(be_valid)
157
157
  end
158
158
 
159
159
  end
160
160
 
161
- context( 'with :is' ) do
162
- before( :each ) do
161
+ context('with :is') do
162
+ before(:each) do
163
163
  @object = ConditionalPresenceIsObject.new
164
164
  @object.dependent_value = 1
165
165
  @object.contingent_value = 1
166
- @object.should( be_valid )
166
+ @object.should(be_valid)
167
167
  end
168
168
 
169
- it( 'should not be valid if dependent_value is nil' ) do
169
+ it('should not be valid if dependent_value is nil') do
170
170
  @object.dependent_value = nil
171
- @object.should_not( be_valid )
171
+ @object.should_not(be_valid)
172
172
  end
173
173
 
174
- it( 'should be valid if contingent_value is nil' ) do
174
+ it('should be valid if contingent_value is nil') do
175
175
  @object.contingent_value = nil
176
- @object.should( be_valid )
176
+ @object.should(be_valid)
177
177
  end
178
178
 
179
- it( 'should be valid if dependent_value is nil and contingent_value is not required value' ) do
179
+ it('should be valid if dependent_value is nil and contingent_value is not required value') do
180
180
  @object.dependent_value = nil
181
181
  @object.contingent_value = 2
182
- @object.should( be_valid )
182
+ @object.should(be_valid)
183
183
  end
184
184
 
185
- it( 'should be valid if both dependent_value and contingent_value is nil' ) do
185
+ it('should be valid if both dependent_value and contingent_value is nil') do
186
186
  @object.dependent_value = nil
187
187
  @object.contingent_value = nil
188
- @object.should( be_valid )
188
+ @object.should(be_valid)
189
189
  end
190
190
  end
191
191
  end
192
192
 
193
- describe( 'validates_numericality_of' ) do
194
- before( :each ) do
193
+ describe('validates_numericality_of') do
194
+ before(:each) do
195
195
  @object = NumericalityObject.new
196
196
  @object.gt = 1
197
197
  @object.gte = 0
198
- @object.should( be_valid )
198
+ @object.should(be_valid)
199
199
  end
200
200
 
201
- it( 'should not be valid with a non-numerical value' ) do
201
+ it('should not be valid with a non-numerical value') do
202
202
  @object.gt = 'one'
203
- @object.should_not( be_valid )
203
+ @object.should_not(be_valid)
204
204
  end
205
205
 
206
- it( 'should not be valid if set :greater_than is false' ) do
206
+ it('should not be valid if set :greater_than is false') do
207
207
  @object.gt = 0
208
- @object.should_not( be_valid )
208
+ @object.should_not(be_valid)
209
209
  end
210
210
 
211
- it( 'should not be valid if set :greater_than_or_equal is false' ) do
211
+ it('should not be valid if set :greater_than_or_equal is false') do
212
212
  @object.gte = -1
213
- @object.should_not( be_valid )
213
+ @object.should_not(be_valid)
214
214
  end
215
215
  end
216
216
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcap
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Farrel Lifson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-07 00:00:00.000000000 Z
11
+ date: 2014-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json