rcap 0.3 → 0.4
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.rdoc +6 -0
- data/README.rdoc +44 -10
- data/lib/rcap.rb +3 -1
- data/lib/rcap/alert.rb +165 -103
- data/lib/rcap/area.rb +28 -2
- data/lib/rcap/circle.rb +27 -19
- data/lib/rcap/info.rb +73 -3
- data/lib/rcap/parameter.rb +10 -0
- data/lib/rcap/point.rb +13 -0
- data/lib/rcap/polygon.rb +10 -0
- data/lib/rcap/resource.rb +31 -4
- data/lib/rcap/utilities.rb +46 -26
- data/lib/rcap/validations.rb +17 -17
- data/spec/alert_spec.rb +52 -13
- data/spec/area_spec.rb +79 -20
- data/spec/circle_spec.rb +39 -10
- data/spec/geocode_spec.rb +18 -6
- data/spec/info_spec.rb +172 -21
- data/spec/point_spec.rb +13 -1
- data/spec/polygon_spec.rb +24 -1
- data/spec/resource_spec.rb +88 -6
- data/spec/spec_helper.rb +2 -1
- data/spec/utilities_spec.rb +1 -1
- data/spec/validations_spec.rb +1 -1
- metadata +36 -12
data/spec/point_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe( RCAP::Point ) do
|
4
4
|
describe( 'is not valid if' ) do
|
@@ -31,4 +31,16 @@ describe( RCAP::Point ) do
|
|
31
31
|
@point.should_not( be_valid )
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
35
|
+
context( 'when exported' ) do
|
36
|
+
before( :each ) do
|
37
|
+
@point = RCAP::Point.new( :lattitude => 1, :longitude => 1 )
|
38
|
+
end
|
39
|
+
|
40
|
+
context( 'to hash' ) do
|
41
|
+
it( 'should export correctly' ) do
|
42
|
+
@point.to_h.should == { RCAP::Point::LATTITUDE_KEY => 1, RCAP::Point::LONGITUDE_KEY => 1 }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
34
46
|
end
|
data/spec/polygon_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe( RCAP::Polygon ) do
|
4
4
|
describe( 'is not valid if it' ) do
|
@@ -41,5 +41,28 @@ describe( RCAP::Polygon ) do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
45
|
+
context( 'from a hash' ) do
|
46
|
+
before( :each ) do
|
47
|
+
@polygon = RCAP::Polygon.new( :points => Array.new(3){|i| RCAP::Point.new( :lattitude => i, :longitude => i )})
|
48
|
+
end
|
49
|
+
|
50
|
+
it( 'should load all the points' ) do
|
51
|
+
@new_polygon = RCAP::Polygon.from_h( @polygon.to_h )
|
52
|
+
@new_polygon.points.should == @polygon.points
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context( 'when exported' ) do
|
58
|
+
before( :each ) do
|
59
|
+
@polygon = RCAP::Polygon.new( :points => Array.new(3){|i| RCAP::Point.new( :lattitude => i, :longitude => i )})
|
60
|
+
end
|
61
|
+
|
62
|
+
context( 'to a hash' ) do
|
63
|
+
it( 'should export correctly' ) do
|
64
|
+
@polygon.to_h.should == { RCAP::Polygon::POINTS_KEY => @polygon.points.map{ |point| point.to_h }}
|
65
|
+
end
|
66
|
+
end
|
44
67
|
end
|
45
68
|
end
|
data/spec/resource_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe( RCAP::Resource ) do
|
4
4
|
context( 'on initialisation' ) do
|
@@ -6,11 +6,11 @@ describe( RCAP::Resource ) do
|
|
6
6
|
@resource = RCAP::Resource.new
|
7
7
|
end
|
8
8
|
|
9
|
-
it( 'should have no mime_type' ){
|
10
|
-
it( 'should have no size' ){
|
11
|
-
it( 'should have no uri' ){
|
12
|
-
it( 'should have no deref_uri' ){
|
13
|
-
it( 'should have no digest' ){
|
9
|
+
it( 'should have no mime_type' ){ @resource.mime_type.should( be_nil )}
|
10
|
+
it( 'should have no size' ){ @resource.size.should( be_nil )}
|
11
|
+
it( 'should have no uri' ){ @resource.uri.should( be_nil )}
|
12
|
+
it( 'should have no deref_uri' ){ @resource.deref_uri.should( be_nil )}
|
13
|
+
it( 'should have no digest' ){ @resource.digest.should( be_nil )}
|
14
14
|
it( 'should have no resource_desc' ){ @resource.resource_desc.should( be_nil )}
|
15
15
|
|
16
16
|
context( 'from XML' ) do
|
@@ -56,6 +56,88 @@ describe( RCAP::Resource ) do
|
|
56
56
|
@resource.digest.should == @original_resource.digest
|
57
57
|
end
|
58
58
|
end
|
59
|
+
|
60
|
+
|
61
|
+
context( 'from a hash' ) do
|
62
|
+
before( :each ) do
|
63
|
+
@original_resource = RCAP::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"
|
70
|
+
|
71
|
+
@resource = RCAP::Resource.from_h( @original_resource.to_h )
|
72
|
+
end
|
73
|
+
|
74
|
+
it( 'should parse resource_desc correctly' ) do
|
75
|
+
@resource.resource_desc.should == @original_resource.resource_desc
|
76
|
+
end
|
77
|
+
|
78
|
+
it( 'should parse uri correctly' ) do
|
79
|
+
@resource.uri.should == @original_resource.uri
|
80
|
+
end
|
81
|
+
|
82
|
+
it( 'should parse mime_type correctly' ) do
|
83
|
+
@resource.mime_type.should == @original_resource.mime_type
|
84
|
+
end
|
85
|
+
|
86
|
+
it( 'should parse deref_uri correctly' ) do
|
87
|
+
@resource.deref_uri.should == @original_resource.deref_uri
|
88
|
+
end
|
89
|
+
|
90
|
+
it( 'should parse size correctly' ) do
|
91
|
+
@resource.size.should == @original_resource.size
|
92
|
+
end
|
93
|
+
|
94
|
+
it( 'should parse digest correctly' ) do
|
95
|
+
@resource.digest.should == @original_resource.digest
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
context( 'when exported' ) do
|
102
|
+
before( :each ) do
|
103
|
+
@resource = RCAP::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"
|
110
|
+
end
|
111
|
+
|
112
|
+
context( 'to a hash' ) do
|
113
|
+
before( :each ) do
|
114
|
+
@resource_hash = @resource.to_h
|
115
|
+
end
|
116
|
+
|
117
|
+
it( 'should set the resource description' ) do
|
118
|
+
@resource_hash[ RCAP::Resource::RESOURCE_DESC_KEY ].should == @resource.resource_desc
|
119
|
+
end
|
120
|
+
|
121
|
+
it( 'should set the mime type' ) do
|
122
|
+
@resource_hash[ RCAP::Resource::MIME_TYPE_KEY ].should == @resource.mime_type
|
123
|
+
end
|
124
|
+
|
125
|
+
it( 'should set the size' ) do
|
126
|
+
@resource_hash[ RCAP::Resource::SIZE_KEY ].should == @resource.size
|
127
|
+
end
|
128
|
+
|
129
|
+
it( 'should set the URI' ) do
|
130
|
+
@resource_hash[ RCAP::Resource::URI_KEY ].should == @resource.uri
|
131
|
+
end
|
132
|
+
|
133
|
+
it( 'should set the dereferenced URI' ) do
|
134
|
+
@resource_hash[ RCAP::Resource::DEREF_URI_KEY ].should == @resource.deref_uri
|
135
|
+
end
|
136
|
+
|
137
|
+
it( 'should set the digest' ) do
|
138
|
+
@resource_hash[ RCAP::Resource::DIGEST_KEY ].should == @resource.digest
|
139
|
+
end
|
140
|
+
end
|
59
141
|
end
|
60
142
|
|
61
143
|
context( 'which is valid' ) do
|
data/spec/spec_helper.rb
CHANGED
data/spec/utilities_spec.rb
CHANGED
data/spec/validations_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rcap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 4
|
8
|
+
version: "0.4"
|
5
9
|
platform: ruby
|
6
10
|
authors:
|
7
11
|
- Farrel Lifson
|
@@ -9,29 +13,47 @@ autorequire:
|
|
9
13
|
bindir: bin
|
10
14
|
cert_chain: []
|
11
15
|
|
12
|
-
date:
|
16
|
+
date: 2011-03-06 00:00:00 +02:00
|
13
17
|
default_executable:
|
14
18
|
dependencies:
|
15
19
|
- !ruby/object:Gem::Dependency
|
16
20
|
name: assistance
|
21
|
+
prerelease: false
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
segments:
|
27
|
+
- 0
|
28
|
+
version: "0"
|
17
29
|
type: :runtime
|
18
|
-
|
19
|
-
|
30
|
+
version_requirements: *id001
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: json
|
33
|
+
prerelease: false
|
34
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
20
35
|
requirements:
|
21
36
|
- - ">="
|
22
37
|
- !ruby/object:Gem::Version
|
38
|
+
segments:
|
39
|
+
- 0
|
23
40
|
version: "0"
|
24
|
-
|
41
|
+
type: :runtime
|
42
|
+
version_requirements: *id002
|
25
43
|
- !ruby/object:Gem::Dependency
|
26
44
|
name: uuidtools
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
prerelease: false
|
46
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
30
47
|
requirements:
|
31
48
|
- - ">="
|
32
49
|
- !ruby/object:Gem::Version
|
50
|
+
segments:
|
51
|
+
- 2
|
52
|
+
- 0
|
53
|
+
- 0
|
33
54
|
version: 2.0.0
|
34
|
-
|
55
|
+
type: :runtime
|
56
|
+
version_requirements: *id003
|
35
57
|
description: A Ruby API providing parsing and generation of CAP(Common Alerting Protocol) messages.
|
36
58
|
email: farrel.lifson@aimred.com
|
37
59
|
executables: []
|
@@ -70,18 +92,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
92
|
requirements:
|
71
93
|
- - ">="
|
72
94
|
- !ruby/object:Gem::Version
|
95
|
+
segments:
|
96
|
+
- 0
|
73
97
|
version: "0"
|
74
|
-
version:
|
75
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
99
|
requirements:
|
77
100
|
- - ">="
|
78
101
|
- !ruby/object:Gem::Version
|
102
|
+
segments:
|
103
|
+
- 0
|
79
104
|
version: "0"
|
80
|
-
version:
|
81
105
|
requirements: []
|
82
106
|
|
83
107
|
rubyforge_project:
|
84
|
-
rubygems_version: 1.3.
|
108
|
+
rubygems_version: 1.3.7
|
85
109
|
signing_key:
|
86
110
|
specification_version: 3
|
87
111
|
summary: CAP(Common Alerting Protocol) API
|