rcap 2.5.1 → 2.6.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -0
- data/lib/rcap/base/alert.rb +2 -1
- data/lib/rcap/base/circle.rb +9 -0
- data/lib/rcap/base/polygon.rb +6 -0
- data/lib/rcap/cap_1_0/alert.rb +2 -1
- data/lib/rcap/cap_1_0/parameter.rb +0 -1
- data/lib/rcap/cap_1_0/polygon.rb +1 -1
- data/lib/rcap/cap_1_1/parameter.rb +0 -1
- data/lib/rcap/cap_1_1/polygon.rb +1 -1
- data/lib/rcap/cap_1_1/resource.rb +0 -1
- data/lib/rcap/cap_1_2/parameter.rb +0 -1
- data/lib/rcap/cap_1_2/polygon.rb +1 -1
- data/lib/rcap/cap_1_2/resource.rb +0 -1
- data/lib/rcap/formatters/yaml.rb +4 -0
- data/lib/rcap/version.rb +1 -1
- data/spec/cap_1_0/circle_spec.rb +9 -0
- data/spec/cap_1_0/polygon_spec.rb +7 -0
- data/spec/cap_1_1/circle_spec.rb +9 -0
- data/spec/cap_1_1/polygon_spec.rb +7 -0
- data/spec/cap_1_2/circle_spec.rb +9 -0
- data/spec/cap_1_2/polygon_spec.rb +8 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c06491f4a40f61743ca71921a056c7bccc85ee6
|
4
|
+
data.tar.gz: cc95caeb32f34167d42654727142d69058fbceb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a90ac3ef2225df636936d4eb3e91b622e76bb39e301378099ebf610da0e95d0c690d4b363abf2cc9b29307f98fbb275fccaac7bde8cc679d7f65121875f4014
|
7
|
+
data.tar.gz: 32b4642bb840d73051b40d42dcf076933190e6a502037e7444b13eb1e1014979a93acfd1ea554997d2360ef1553d5a4cb3961f009013f143d8891f4cd00c1771
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/lib/rcap/base/alert.rb
CHANGED
@@ -193,7 +193,8 @@ module RCAP
|
|
193
193
|
'Codes:',
|
194
194
|
@codes.map { |code| ' ' + code }.join("\n") + '',
|
195
195
|
"Note: #{ @note }",
|
196
|
-
"References:
|
196
|
+
"References:",
|
197
|
+
@references.join("\n "),
|
197
198
|
"Incidents: #{ @incidents.join(' ')}",
|
198
199
|
'Information:',
|
199
200
|
@infos.map { |info| ' ' + info.to_s }.join("\n")].join("\n")
|
data/lib/rcap/base/circle.rb
CHANGED
@@ -21,6 +21,15 @@ module RCAP
|
|
21
21
|
yield(self) if block_given?
|
22
22
|
end
|
23
23
|
|
24
|
+
# Returns GeoJSON representation of the circle in the form of a Point
|
25
|
+
# with radius property
|
26
|
+
def to_geojson
|
27
|
+
{ 'type' => 'Feature',
|
28
|
+
'geometry' => { 'type' => 'Point',
|
29
|
+
'coordinates' => [@longitude, @lattitude] },
|
30
|
+
'properties' => { 'radius' => @radius } }.to_json
|
31
|
+
end
|
32
|
+
|
24
33
|
# Returns a string representation of the circle of the form
|
25
34
|
# lattitude,longitude radius
|
26
35
|
#
|
data/lib/rcap/base/polygon.rb
CHANGED
@@ -27,6 +27,12 @@ module RCAP
|
|
27
27
|
point
|
28
28
|
end
|
29
29
|
|
30
|
+
# Returns GeoJSON representation of the polygon
|
31
|
+
def to_geojson
|
32
|
+
coordinates = @points.map { |point| [point.longitude, point.lattitude] }
|
33
|
+
{ 'type' => 'Polygon', 'coordinates' => coordinates }.to_json
|
34
|
+
end
|
35
|
+
|
30
36
|
# Returns a string representation of the polygon of the form
|
31
37
|
# points[0] points[1] points[2] ...
|
32
38
|
# where each point is formatted with Point#to_s
|
data/lib/rcap/cap_1_0/alert.rb
CHANGED
@@ -75,7 +75,8 @@ module RCAP
|
|
75
75
|
'Codes:',
|
76
76
|
@codes.map { |code| ' ' + code }.join("\n"),
|
77
77
|
"Note: #{ @note }",
|
78
|
-
"References:
|
78
|
+
"References:",
|
79
|
+
@references.join("\n "),
|
79
80
|
"Incidents: #{ @incidents.join(' ')}",
|
80
81
|
'Information:',
|
81
82
|
@infos.map { |info| ' ' + info.to_s }.join("\n")].join("\n")
|
data/lib/rcap/cap_1_0/polygon.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module RCAP
|
2
2
|
module CAP_1_0
|
3
3
|
# A Polygon object is valid if
|
4
|
-
# * it has a minimum of three points
|
4
|
+
# * if points are given it has a minimum of three points
|
5
5
|
# * each Point object in the points collection is valid
|
6
6
|
class Polygon < RCAP::Base::Polygon
|
7
7
|
# @return [Class]
|
data/lib/rcap/cap_1_1/polygon.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module RCAP
|
2
2
|
module CAP_1_1
|
3
3
|
# A Polygon object is valid if
|
4
|
-
# * it has a minimum of three points
|
4
|
+
# * if points are given it has a minimum of three points
|
5
5
|
# * each Point object in the points collection is valid
|
6
6
|
class Polygon < RCAP::Base::Polygon
|
7
7
|
# @return [Class]
|
@@ -11,7 +11,6 @@ module RCAP
|
|
11
11
|
|
12
12
|
# @return [REXML::Element]
|
13
13
|
def to_xml_element
|
14
|
-
xml_element = super
|
15
14
|
xml_element = REXML::Element.new(XML_ELEMENT_NAME)
|
16
15
|
xml_element.add_element(RESOURCE_DESC_ELEMENT_NAME).add_text(@resource_desc)
|
17
16
|
xml_element.add_element(MIME_TYPE_ELEMENT_NAME).add_text(@mime_type) if @mime_type
|
data/lib/rcap/cap_1_2/polygon.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module RCAP
|
2
2
|
module CAP_1_2
|
3
3
|
# A Polygon object is valid if
|
4
|
-
# * it has a minimum of three points
|
4
|
+
# * if points are given it has a minimum of three points
|
5
5
|
# * each Point object in the points collection is valid
|
6
6
|
class Polygon < RCAP::Base::Polygon
|
7
7
|
validates_length_of(:points, minimum: 4, allow_blank: true)
|
@@ -15,7 +15,6 @@ module RCAP
|
|
15
15
|
|
16
16
|
# @return [REXML::Element]
|
17
17
|
def to_xml_element
|
18
|
-
xml_element = super
|
19
18
|
xml_element = REXML::Element.new(XML_ELEMENT_NAME)
|
20
19
|
xml_element.add_element(RESOURCE_DESC_ELEMENT_NAME).add_text(@resource_desc)
|
21
20
|
xml_element.add_element(MIME_TYPE_ELEMENT_NAME).add_text(@mime_type) if @mime_type
|
data/lib/rcap/version.rb
CHANGED
data/spec/cap_1_0/circle_spec.rb
CHANGED
@@ -99,6 +99,15 @@ describe(RCAP::CAP_1_0::Circle) do
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
+
context('to geojson') do
|
103
|
+
it('should be valid geojson') do
|
104
|
+
@circle.longitude = 5.6
|
105
|
+
expected = '{"type":"Feature","geometry":{"type":"Point",' \
|
106
|
+
'"coordinates":[5.6,30]},"properties":{"radius":10.5}}'
|
107
|
+
expect(@circle.to_geojson).to eq expected
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
102
111
|
context('to hash') do
|
103
112
|
it('should be correct') do
|
104
113
|
@circle.to_h.should == { 'radius' => 10.5, 'lattitude' => 30, 'longitude' => 60 }
|
@@ -101,6 +101,13 @@ describe(RCAP::CAP_1_0::Polygon) do
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
+
context('to geojson') do
|
105
|
+
it('should be valid geojson') do
|
106
|
+
expected = '{"type":"Polygon","coordinates":[[0,0],[1,1],[2,2]]}'
|
107
|
+
expect(@polygon.to_geojson).to eq expected
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
104
111
|
context('to a hash') do
|
105
112
|
it('should export correctly') do
|
106
113
|
@polygon.to_h.should == { RCAP::CAP_1_0::Polygon::POINTS_KEY => @polygon.points.map { |point| point.to_a } }
|
data/spec/cap_1_1/circle_spec.rb
CHANGED
@@ -102,6 +102,15 @@ describe(RCAP::CAP_1_1::Circle) do
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
+
context('to geojson') do
|
106
|
+
it('should be valid geojson') do
|
107
|
+
@circle.longitude = 5.6
|
108
|
+
expected = '{"type":"Feature","geometry":{"type":"Point",' \
|
109
|
+
'"coordinates":[5.6,30]},"properties":{"radius":10.5}}'
|
110
|
+
expect(@circle.to_geojson).to eq expected
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
105
114
|
context('to hash') do
|
106
115
|
it('should be correct') do
|
107
116
|
@circle.to_h.should == { 'radius' => 10.5, 'lattitude' => 30, 'longitude' => 60 }
|
@@ -97,6 +97,13 @@ describe(RCAP::CAP_1_1::Polygon) do
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
+
context('to geojson') do
|
101
|
+
it('should be valid geojson') do
|
102
|
+
expected = '{"type":"Polygon","coordinates":[[0,0],[1,1],[2,2]]}'
|
103
|
+
expect(@polygon.to_geojson).to eq expected
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
100
107
|
context('to a hash') do
|
101
108
|
it('should export correctly') do
|
102
109
|
@polygon.to_h.should == { RCAP::CAP_1_1::Polygon::POINTS_KEY => @polygon.points.map { |point| point.to_a } }
|
data/spec/cap_1_2/circle_spec.rb
CHANGED
@@ -93,6 +93,15 @@ describe(RCAP::CAP_1_2::Circle) do
|
|
93
93
|
@circle = RCAP::CAP_1_2::Circle.new(&@circle_builder)
|
94
94
|
end
|
95
95
|
|
96
|
+
context('to geojson') do
|
97
|
+
it('should be valid geojson') do
|
98
|
+
@circle.longitude = 5.6
|
99
|
+
expected = '{"type":"Feature","geometry":{"type":"Point",' \
|
100
|
+
'"coordinates":[5.6,0]},"properties":{"radius":1}}'
|
101
|
+
expect(@circle.to_geojson).to eq expected
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
96
105
|
context('to hash') do
|
97
106
|
it('should be correct') do
|
98
107
|
@circle.to_h.should == { 'radius' => 1, 'lattitude' => 0, 'longitude' => 0 }
|
@@ -83,6 +83,14 @@ describe(RCAP::CAP_1_2::Polygon) do
|
|
83
83
|
@polygon = RCAP::CAP_1_2::Polygon.new(&@polygon_builder)
|
84
84
|
end
|
85
85
|
|
86
|
+
context('to geojson') do
|
87
|
+
it('should be valid geojson') do
|
88
|
+
expected = '{"type":"Polygon","coordinates":[[0,0],[1,1],[2,2],' \
|
89
|
+
'[0,0]]}'
|
90
|
+
expect(@polygon.to_geojson).to eq expected
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
86
94
|
context('to a hash') do
|
87
95
|
it('should export correctly') do
|
88
96
|
@polygon.to_h.should == { RCAP::CAP_1_2::Polygon::POINTS_KEY => @polygon.points.map { |point| point.to_a } }
|
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
|
+
version: 2.6.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:
|
11
|
+
date: 2016-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- lib/rcap/extensions/nil_class.rb
|
148
148
|
- lib/rcap/extensions/string.rb
|
149
149
|
- lib/rcap/extensions/time.rb
|
150
|
+
- lib/rcap/formatters/yaml.rb
|
150
151
|
- lib/rcap/info.rb
|
151
152
|
- lib/rcap/utilities.rb
|
152
153
|
- lib/rcap/validation.rb
|
@@ -220,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
221
|
version: '0'
|
221
222
|
requirements: []
|
222
223
|
rubyforge_project: rcap
|
223
|
-
rubygems_version: 2.
|
224
|
+
rubygems_version: 2.5.1
|
224
225
|
signing_key:
|
225
226
|
specification_version: 4
|
226
227
|
summary: CAP(Common Alerting Protocol) API
|