rcap 1.3.1 → 2.0.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.
- data/CHANGELOG.md +5 -0
- data/README.md +78 -151
- data/Rakefile +1 -1
- data/lib/rcap/alert.rb +2 -2
- data/lib/rcap/base/alert.rb +446 -0
- data/lib/rcap/base/area.rb +228 -0
- data/lib/rcap/base/circle.rb +121 -0
- data/lib/rcap/base/event_code.rb +6 -0
- data/lib/rcap/base/geocode.rb +6 -0
- data/lib/rcap/base/info.rb +498 -0
- data/lib/rcap/base/parameter.rb +88 -0
- data/lib/rcap/base/point.rb +87 -0
- data/lib/rcap/base/polygon.rb +120 -0
- data/lib/rcap/base/resource.rb +168 -0
- data/lib/rcap/cap_1_0/alert.rb +59 -342
- data/lib/rcap/cap_1_0/area.rb +13 -188
- data/lib/rcap/cap_1_0/circle.rb +2 -100
- data/lib/rcap/cap_1_0/event_code.rb +8 -3
- data/lib/rcap/cap_1_0/geocode.rb +8 -3
- data/lib/rcap/cap_1_0/info.rb +16 -468
- data/lib/rcap/cap_1_0/parameter.rb +9 -67
- data/lib/rcap/cap_1_0/point.rb +2 -61
- data/lib/rcap/cap_1_0/polygon.rb +5 -95
- data/lib/rcap/cap_1_0/resource.rb +4 -144
- data/lib/rcap/cap_1_1/alert.rb +7 -412
- data/lib/rcap/cap_1_1/area.rb +13 -188
- data/lib/rcap/cap_1_1/circle.rb +2 -100
- data/lib/rcap/cap_1_1/event_code.rb +8 -3
- data/lib/rcap/cap_1_1/geocode.rb +7 -3
- data/lib/rcap/cap_1_1/info.rb +127 -386
- data/lib/rcap/cap_1_1/parameter.rb +4 -76
- data/lib/rcap/cap_1_1/point.rb +2 -61
- data/lib/rcap/cap_1_1/polygon.rb +5 -95
- data/lib/rcap/cap_1_1/resource.rb +37 -143
- data/lib/rcap/cap_1_2/alert.rb +8 -413
- data/lib/rcap/cap_1_2/area.rb +13 -188
- data/lib/rcap/cap_1_2/circle.rb +2 -100
- data/lib/rcap/cap_1_2/event_code.rb +8 -3
- data/lib/rcap/cap_1_2/geocode.rb +8 -3
- data/lib/rcap/cap_1_2/info.rb +132 -419
- data/lib/rcap/cap_1_2/parameter.rb +4 -76
- data/lib/rcap/cap_1_2/point.rb +2 -61
- data/lib/rcap/cap_1_2/polygon.rb +5 -92
- data/lib/rcap/cap_1_2/resource.rb +31 -134
- data/lib/rcap/config.rb +3 -0
- data/lib/{extensions → rcap/extensions}/array.rb +1 -1
- data/lib/rcap/extensions/date.rb +11 -0
- data/lib/{extensions → rcap/extensions}/date_time.rb +2 -5
- data/lib/{extensions → rcap/extensions}/string.rb +1 -1
- data/lib/{extensions → rcap/extensions}/time.rb +2 -4
- data/lib/rcap/utilities.rb +11 -11
- data/lib/rcap/validations.rb +7 -2
- data/lib/rcap/version.rb +1 -1
- data/lib/rcap.rb +21 -4
- data/spec/alert_spec.rb +69 -37
- data/spec/cap_1_0/alert_spec.rb +46 -61
- data/spec/cap_1_0/area_spec.rb +77 -37
- data/spec/cap_1_0/circle_spec.rb +26 -6
- data/spec/cap_1_0/event_code_spec.rb +10 -3
- data/spec/cap_1_0/geocode_spec.rb +11 -4
- data/spec/cap_1_0/info_spec.rb +74 -77
- data/spec/cap_1_0/parameter_spec.rb +18 -5
- data/spec/cap_1_0/point_spec.rb +9 -2
- data/spec/cap_1_0/polygon_spec.rb +52 -9
- data/spec/cap_1_0/resource_spec.rb +28 -21
- data/spec/cap_1_1/alert_spec.rb +47 -60
- data/spec/cap_1_1/area_spec.rb +66 -43
- data/spec/cap_1_1/circle_spec.rb +29 -6
- data/spec/cap_1_1/event_code_spec.rb +11 -3
- data/spec/cap_1_1/geocode_spec.rb +11 -3
- data/spec/cap_1_1/info_spec.rb +262 -118
- data/spec/cap_1_1/parameter_spec.rb +12 -3
- data/spec/cap_1_1/point_spec.rb +8 -2
- data/spec/cap_1_1/polygon_spec.rb +57 -18
- data/spec/cap_1_1/resource_spec.rb +70 -20
- data/spec/cap_1_2/alert_spec.rb +97 -110
- data/spec/cap_1_2/area_spec.rb +59 -41
- data/spec/cap_1_2/circle_spec.rb +15 -8
- data/spec/cap_1_2/event_code_spec.rb +11 -3
- data/spec/cap_1_2/geocode_spec.rb +11 -3
- data/spec/cap_1_2/info_spec.rb +266 -119
- data/spec/cap_1_2/parameter_spec.rb +11 -3
- data/spec/cap_1_2/point_spec.rb +10 -3
- data/spec/cap_1_2/polygon_spec.rb +25 -10
- data/spec/cap_1_2/resource_spec.rb +33 -28
- data/spec/{utilities_spec.rb → extensions_spec.rb} +0 -0
- data/spec/validations_spec.rb +18 -2
- metadata +20 -46
@@ -1,6 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe( RCAP::CAP_1_2::Resource ) do
|
4
|
+
before( :each ) do
|
5
|
+
@resource_builder = lambda do |resource|
|
6
|
+
resource.resource_desc = "Image of incident"
|
7
|
+
resource.uri = "http://capetown.gov.za/cap/resources/image.png"
|
8
|
+
resource.mime_type = 'image/png'
|
9
|
+
resource.deref_uri = "IMAGE DATA"
|
10
|
+
resource.size = 20480
|
11
|
+
resource.digest = "2048"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
4
15
|
context( 'on initialisation' ) do
|
5
16
|
before( :each ) do
|
6
17
|
@resource = RCAP::CAP_1_2::Resource.new
|
@@ -15,15 +26,10 @@ describe( RCAP::CAP_1_2::Resource ) do
|
|
15
26
|
|
16
27
|
context( 'from XML' ) do
|
17
28
|
before( :each ) do
|
18
|
-
@original_resource = RCAP::CAP_1_2::Resource.new
|
19
|
-
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@original_resource.deref_uri = "IMAGE DATA"
|
23
|
-
@original_resource.size = 20480
|
24
|
-
@original_resource.digest = "2048"
|
25
|
-
|
26
|
-
@alert = RCAP::CAP_1_2::Alert.new( :infos => RCAP::CAP_1_2::Info.new( :resources => @original_resource ))
|
29
|
+
@original_resource = RCAP::CAP_1_2::Resource.new( &@resource_builder )
|
30
|
+
|
31
|
+
@alert = RCAP::CAP_1_2::Alert.new
|
32
|
+
@alert.add_info.add_resource( &@resource_builder )
|
27
33
|
@xml_string = @alert.to_xml
|
28
34
|
@xml_document = REXML::Document.new( @xml_string )
|
29
35
|
@info_element = RCAP.xpath_first( @xml_document.root, RCAP::CAP_1_2::Info::XPATH, RCAP::CAP_1_2::Alert::XMLNS )
|
@@ -60,13 +66,7 @@ describe( RCAP::CAP_1_2::Resource ) do
|
|
60
66
|
|
61
67
|
context( 'from a hash' ) do
|
62
68
|
before( :each ) do
|
63
|
-
@original_resource = RCAP::CAP_1_2::Resource.new
|
64
|
-
@original_resource.resource_desc = "Image of incident"
|
65
|
-
@original_resource.uri = "http://capetown.gov.za/cap/resources/image.png"
|
66
|
-
@original_resource.mime_type = 'image/png'
|
67
|
-
@original_resource.deref_uri = "IMAGE DATA"
|
68
|
-
@original_resource.size = 20480
|
69
|
-
@original_resource.digest = "2048"
|
69
|
+
@original_resource = RCAP::CAP_1_2::Resource.new( &@resource_builder )
|
70
70
|
|
71
71
|
@resource = RCAP::CAP_1_2::Resource.from_h( @original_resource.to_h )
|
72
72
|
end
|
@@ -95,18 +95,11 @@ describe( RCAP::CAP_1_2::Resource ) do
|
|
95
95
|
@resource.digest.should == @original_resource.digest
|
96
96
|
end
|
97
97
|
end
|
98
|
-
|
99
98
|
end
|
100
99
|
|
101
100
|
context( 'when exported' ) do
|
102
101
|
before( :each ) do
|
103
|
-
@resource = RCAP::CAP_1_2::Resource.new
|
104
|
-
@resource.resource_desc = "Image of incident"
|
105
|
-
@resource.uri = "http://capetown.gov.za/cap/resources/image.png"
|
106
|
-
@resource.mime_type = 'image/png'
|
107
|
-
@resource.deref_uri = "IMAGE DATA"
|
108
|
-
@resource.size = 20480
|
109
|
-
@resource.digest = "2048"
|
102
|
+
@resource = RCAP::CAP_1_2::Resource.new( &@resource_builder )
|
110
103
|
end
|
111
104
|
|
112
105
|
context( 'to a hash' ) do
|
@@ -148,7 +141,10 @@ describe( RCAP::CAP_1_2::Resource ) do
|
|
148
141
|
|
149
142
|
context( 'which is valid' ) do
|
150
143
|
before( :each ) do
|
151
|
-
@resource = RCAP::CAP_1_2::Resource.new
|
144
|
+
@resource = RCAP::CAP_1_2::Resource.new do |resource|
|
145
|
+
resource.resource_desc = 'Resource Description'
|
146
|
+
resource.mime_type = 'text/csv'
|
147
|
+
end
|
152
148
|
@resource.should( be_valid )
|
153
149
|
end
|
154
150
|
|
@@ -167,7 +163,11 @@ describe( RCAP::CAP_1_2::Resource ) do
|
|
167
163
|
|
168
164
|
context( 'with a non-rereferenced URI' ) do
|
169
165
|
before( :each ) do
|
170
|
-
@resource = RCAP::CAP_1_2::Resource.new
|
166
|
+
@resource = RCAP::CAP_1_2::Resource.new do |resource|
|
167
|
+
resource.resource_desc = 'Resource Description'
|
168
|
+
resource.mime_type = 'text/csv'
|
169
|
+
resource.uri = 'http://tempuri.org/resource.csv'
|
170
|
+
end
|
171
171
|
@content = "1,2\n3,4"
|
172
172
|
@encoded_content = Base64.encode64( @content )
|
173
173
|
stub_request( :get, @resource.uri ).to_return( :status => 200, :body => @content )
|
@@ -189,10 +189,15 @@ describe( RCAP::CAP_1_2::Resource ) do
|
|
189
189
|
end
|
190
190
|
|
191
191
|
context( 'with a dereferenced URI' ) do
|
192
|
-
before( :each ) do
|
192
|
+
before( :each ) do
|
193
193
|
@content = "1,2\n3,4"
|
194
194
|
@encoded_content = Base64.encode64( @content )
|
195
|
-
@resource = RCAP::CAP_1_2::Resource.new
|
195
|
+
@resource = RCAP::CAP_1_2::Resource.new do |resource|
|
196
|
+
resource.resource_desc = 'Resource Description'
|
197
|
+
resource.mime_type = 'text/csv'
|
198
|
+
resource.uri = 'http://tempuri.org/resource.csv'
|
199
|
+
resource.deref_uri = @encoded_content
|
200
|
+
end
|
196
201
|
end
|
197
202
|
|
198
203
|
describe( '#calculate_hash_and_size' ) do
|
File without changes
|
data/spec/validations_spec.rb
CHANGED
@@ -48,12 +48,28 @@ describe( Validation::ClassMethods ) do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
it( 'should be valid if all the members are valid' ) do
|
51
|
-
@object_with_collection.collection = Array.new(3)
|
51
|
+
@object_with_collection.collection = Array.new(3) do
|
52
|
+
RCAP::CAP_1_1::Point.new do |point|
|
53
|
+
point.lattitude = 0
|
54
|
+
point.longitude = 0
|
55
|
+
end
|
56
|
+
end
|
52
57
|
@object_with_collection.should( be_valid )
|
53
58
|
end
|
54
59
|
|
55
60
|
it( 'should not be valid some of the members are invalid' ) do
|
56
|
-
@object_with_collection.collection = Array.new( 2 )
|
61
|
+
@object_with_collection.collection = Array.new( 2 ) do
|
62
|
+
RCAP::CAP_1_1::Point.new do |point|
|
63
|
+
point.lattitude = 0
|
64
|
+
point.longitude = 0
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
@object_with_collection.collection << RCAP::CAP_1_1::Point.new do |point|
|
69
|
+
point.lattitude = "not a number"
|
70
|
+
point.longitude = 0
|
71
|
+
end
|
72
|
+
|
57
73
|
@object_with_collection.should_not( be_valid )
|
58
74
|
end
|
59
75
|
end
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rcap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 25
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 1
|
8
|
-
- 3
|
9
|
-
- 1
|
10
|
-
version: 1.3.1
|
5
|
+
version: 2.0.0
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Farrel Lifson
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2012-
|
13
|
+
date: 2012-11-17 00:00:00 Z
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
16
|
name: assistance
|
@@ -25,11 +20,6 @@ dependencies:
|
|
25
20
|
requirements:
|
26
21
|
- - ">="
|
27
22
|
- !ruby/object:Gem::Version
|
28
|
-
hash: 17
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
- 1
|
32
|
-
- 5
|
33
23
|
version: 0.1.5
|
34
24
|
type: :runtime
|
35
25
|
version_requirements: *id001
|
@@ -41,11 +31,6 @@ dependencies:
|
|
41
31
|
requirements:
|
42
32
|
- - ">="
|
43
33
|
- !ruby/object:Gem::Version
|
44
|
-
hash: 1
|
45
|
-
segments:
|
46
|
-
- 1
|
47
|
-
- 5
|
48
|
-
- 1
|
49
34
|
version: 1.5.1
|
50
35
|
type: :runtime
|
51
36
|
version_requirements: *id002
|
@@ -57,11 +42,6 @@ dependencies:
|
|
57
42
|
requirements:
|
58
43
|
- - ">="
|
59
44
|
- !ruby/object:Gem::Version
|
60
|
-
hash: 15
|
61
|
-
segments:
|
62
|
-
- 2
|
63
|
-
- 1
|
64
|
-
- 2
|
65
45
|
version: 2.1.2
|
66
46
|
type: :runtime
|
67
47
|
version_requirements: *id003
|
@@ -73,11 +53,6 @@ dependencies:
|
|
73
53
|
requirements:
|
74
54
|
- - ">="
|
75
55
|
- !ruby/object:Gem::Version
|
76
|
-
hash: 27
|
77
|
-
segments:
|
78
|
-
- 2
|
79
|
-
- 5
|
80
|
-
- 0
|
81
56
|
version: 2.5.0
|
82
57
|
type: :development
|
83
58
|
version_requirements: *id004
|
@@ -89,9 +64,6 @@ dependencies:
|
|
89
64
|
requirements:
|
90
65
|
- - ">="
|
91
66
|
- !ruby/object:Gem::Version
|
92
|
-
hash: 3
|
93
|
-
segments:
|
94
|
-
- 0
|
95
67
|
version: "0"
|
96
68
|
type: :development
|
97
69
|
version_requirements: *id005
|
@@ -103,9 +75,6 @@ dependencies:
|
|
103
75
|
requirements:
|
104
76
|
- - ">="
|
105
77
|
- !ruby/object:Gem::Version
|
106
|
-
hash: 3
|
107
|
-
segments:
|
108
|
-
- 0
|
109
78
|
version: "0"
|
110
79
|
type: :development
|
111
80
|
version_requirements: *id006
|
@@ -125,12 +94,18 @@ files:
|
|
125
94
|
- Gemfile
|
126
95
|
- README.md
|
127
96
|
- Rakefile
|
128
|
-
- lib/extensions/array.rb
|
129
|
-
- lib/extensions/date_time.rb
|
130
|
-
- lib/extensions/string.rb
|
131
|
-
- lib/extensions/time.rb
|
132
97
|
- lib/rcap.rb
|
133
98
|
- lib/rcap/alert.rb
|
99
|
+
- lib/rcap/base/alert.rb
|
100
|
+
- lib/rcap/base/area.rb
|
101
|
+
- lib/rcap/base/circle.rb
|
102
|
+
- lib/rcap/base/event_code.rb
|
103
|
+
- lib/rcap/base/geocode.rb
|
104
|
+
- lib/rcap/base/info.rb
|
105
|
+
- lib/rcap/base/parameter.rb
|
106
|
+
- lib/rcap/base/point.rb
|
107
|
+
- lib/rcap/base/polygon.rb
|
108
|
+
- lib/rcap/base/resource.rb
|
134
109
|
- lib/rcap/cap_1_0/alert.rb
|
135
110
|
- lib/rcap/cap_1_0/area.rb
|
136
111
|
- lib/rcap/cap_1_0/circle.rb
|
@@ -162,6 +137,11 @@ files:
|
|
162
137
|
- lib/rcap/cap_1_2/polygon.rb
|
163
138
|
- lib/rcap/cap_1_2/resource.rb
|
164
139
|
- lib/rcap/config.rb
|
140
|
+
- lib/rcap/extensions/array.rb
|
141
|
+
- lib/rcap/extensions/date.rb
|
142
|
+
- lib/rcap/extensions/date_time.rb
|
143
|
+
- lib/rcap/extensions/string.rb
|
144
|
+
- lib/rcap/extensions/time.rb
|
165
145
|
- lib/rcap/utilities.rb
|
166
146
|
- lib/rcap/validations.rb
|
167
147
|
- lib/rcap/version.rb
|
@@ -210,9 +190,9 @@ files:
|
|
210
190
|
- spec/cap_1_2/point_spec.rb
|
211
191
|
- spec/cap_1_2/polygon_spec.rb
|
212
192
|
- spec/cap_1_2/resource_spec.rb
|
193
|
+
- spec/extensions_spec.rb
|
213
194
|
- spec/spec.opts
|
214
195
|
- spec/spec_helper.rb
|
215
|
-
- spec/utilities_spec.rb
|
216
196
|
- spec/validations_spec.rb
|
217
197
|
homepage: http://www.aimred.com/projects/rcap
|
218
198
|
licenses: []
|
@@ -227,23 +207,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
227
207
|
requirements:
|
228
208
|
- - ">="
|
229
209
|
- !ruby/object:Gem::Version
|
230
|
-
hash: 3
|
231
|
-
segments:
|
232
|
-
- 0
|
233
210
|
version: "0"
|
234
211
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
235
212
|
none: false
|
236
213
|
requirements:
|
237
214
|
- - ">="
|
238
215
|
- !ruby/object:Gem::Version
|
239
|
-
hash: 3
|
240
|
-
segments:
|
241
|
-
- 0
|
242
216
|
version: "0"
|
243
217
|
requirements: []
|
244
218
|
|
245
219
|
rubyforge_project: rcap
|
246
|
-
rubygems_version: 1.8.
|
220
|
+
rubygems_version: 1.8.10
|
247
221
|
signing_key:
|
248
222
|
specification_version: 3
|
249
223
|
summary: CAP(Common Alerting Protocol) API
|
@@ -292,8 +266,8 @@ test_files:
|
|
292
266
|
- spec/cap_1_2/point_spec.rb
|
293
267
|
- spec/cap_1_2/polygon_spec.rb
|
294
268
|
- spec/cap_1_2/resource_spec.rb
|
269
|
+
- spec/extensions_spec.rb
|
295
270
|
- spec/spec.opts
|
296
271
|
- spec/spec_helper.rb
|
297
|
-
- spec/utilities_spec.rb
|
298
272
|
- spec/validations_spec.rb
|
299
273
|
has_rdoc:
|