rcap 1.2.1 → 1.2.2

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  = Change Log
2
2
 
3
+ == 1.2.1 - 29 October 2011
4
+
5
+ * Fixed polygon parsing and made it consitent across versions
6
+
3
7
  == 1.2.1 - 27 October 2011
4
8
 
5
9
  * Fixed bug initialising 'audience' attribute in Info class
data/README.rdoc CHANGED
@@ -8,7 +8,7 @@ RCAP currently supports CAP 1.0, 1.1 and 1.2.
8
8
 
9
9
  == Version
10
10
 
11
- 1.2.0
11
+ 1.2.2
12
12
 
13
13
  == Dependencies
14
14
 
@@ -9,8 +9,9 @@ module RCAP
9
9
  # Collection of Point objects.
10
10
  attr_reader( :points )
11
11
 
12
- validates_length_of( :points, :minimum => 3 )
13
12
  validates_collection_of( :points )
13
+ validates_length_of( :points, :minimum => 3 )
14
+ validates_equality_of_first_and_last( :points )
14
15
 
15
16
  XML_ELEMENT_NAME = 'polygon' # :nodoc:
16
17
  XPATH = "cap:#{ XML_ELEMENT_NAME }" # :nodoc:
@@ -28,10 +29,10 @@ module RCAP
28
29
  end
29
30
 
30
31
  # Returns a string representation of the polygon of the form
31
- # points[0] points[1] points[2] ... points[n-1] points[0]
32
+ # points[0] points[1] points[2] ...
32
33
  # where each point is formatted with Point#to_s
33
34
  def to_s
34
- (@points + [ @points.first ]).join( ' ' )
35
+ @points.join( ' ' )
35
36
  end
36
37
 
37
38
  def inspect # :nodoc:
@@ -56,7 +57,7 @@ module RCAP
56
57
  def self.from_xml_element( polygon_xml_element ) # :nodoc:
57
58
  if !polygon_xml_element.text.nil? && !polygon_xml_element.text.empty?
58
59
  coordinates = self.parse_polygon_string( polygon_xml_element.text )
59
- points = coordinates.map{ |lattitude, longitude| Point.new( :lattitude => lattitude, :longitude => longitude )}[0..-2]
60
+ points = coordinates.map{ |lattitude, longitude| Point.new( :lattitude => lattitude, :longitude => longitude )}
60
61
  polygon = self.new( :points => points )
61
62
  else
62
63
  self.new
@@ -9,8 +9,9 @@ module RCAP
9
9
  # Collection of Point objects.
10
10
  attr_reader( :points )
11
11
 
12
- validates_length_of( :points, :minimum => 3 )
13
12
  validates_collection_of( :points )
13
+ validates_length_of( :points, :minimum => 3 )
14
+ validates_equality_of_first_and_last( :points )
14
15
 
15
16
  XML_ELEMENT_NAME = 'polygon' # :nodoc:
16
17
  XPATH = "cap:#{ XML_ELEMENT_NAME }" # :nodoc:
@@ -28,10 +29,10 @@ module RCAP
28
29
  end
29
30
 
30
31
  # Returns a string representation of the polygon of the form
31
- # points[0] points[1] points[2] ... points[n-1] points[0]
32
+ # points[0] points[1] points[2] ...
32
33
  # where each point is formatted with Point#to_s
33
34
  def to_s
34
- (@points + [ @points.first ]).join( ' ' )
35
+ @points.join( ' ' )
35
36
  end
36
37
 
37
38
  def inspect # :nodoc:
@@ -56,7 +57,7 @@ module RCAP
56
57
  def self.from_xml_element( polygon_xml_element ) # :nodoc:
57
58
  if !polygon_xml_element.text.nil? && !polygon_xml_element.text.empty?
58
59
  coordinates = self.parse_polygon_string( polygon_xml_element.text )
59
- points = coordinates.map{ |lattitude, longitude| Point.new( :lattitude => lattitude, :longitude => longitude )}[0..-2]
60
+ points = coordinates.map{ |lattitude, longitude| Point.new( :lattitude => lattitude, :longitude => longitude )}
60
61
  polygon = self.new( :points => points )
61
62
  else
62
63
  self.new
@@ -29,7 +29,7 @@ module RCAP
29
29
  end
30
30
 
31
31
  # Returns a string representation of the polygon of the form
32
- # points[0] points[1] points[2] ... points[n-1] points[0]
32
+ # points[0] points[1] points[2] ...
33
33
  # where each point is formatted with Point#to_s
34
34
  def to_s
35
35
  @points.join( ' ' )
data/lib/rcap/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RCAP
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.2'
3
3
  end
@@ -167,7 +167,7 @@ describe( RCAP::CAP_1_0::Area ) do
167
167
  @polygon = RCAP::CAP_1_0::Polygon.new
168
168
  @polygon.points.push( RCAP::CAP_1_0::Point.new( :lattitude => 0, :longitude => 0 ),
169
169
  RCAP::CAP_1_0::Point.new( :lattitude => 0, :longitude => 1 ),
170
- RCAP::CAP_1_0::Point.new( :lattitude => 1, :longitude => 0 ))
170
+ RCAP::CAP_1_0::Point.new( :lattitude => 0, :longitude => 0 ))
171
171
  @area.polygons << @polygon
172
172
  @area.should( be_valid )
173
173
  end
@@ -167,7 +167,7 @@ describe( RCAP::CAP_1_1::Area ) do
167
167
  @polygon = RCAP::CAP_1_1::Polygon.new
168
168
  @polygon.points.push( RCAP::CAP_1_1::Point.new( :lattitude => 0, :longitude => 0 ),
169
169
  RCAP::CAP_1_1::Point.new( :lattitude => 0, :longitude => 1 ),
170
- RCAP::CAP_1_1::Point.new( :lattitude => 1, :longitude => 0 ))
170
+ RCAP::CAP_1_1::Point.new( :lattitude => 0, :longitude => 0 ))
171
171
  @area.polygons << @polygon
172
172
  @area.should( be_valid )
173
173
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 1
10
- version: 1.2.1
9
+ - 2
10
+ version: 1.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Farrel Lifson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-27 00:00:00 Z
18
+ date: 2011-10-28 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: assistance