rcap 1.0.0.rc.3 → 1.0.0.rc.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rcap/cap_1_1/area.rb +8 -8
- data/lib/rcap/cap_1_1/polygon.rb +1 -1
- data/lib/rcap/cap_1_2/area.rb +8 -8
- data/lib/rcap/cap_1_2/polygon.rb +1 -1
- data/lib/rcap/utilities.rb +1 -1
- data/lib/rcap/validations.rb +8 -8
- data/lib/rcap/version.rb +1 -1
- metadata +3 -3
data/lib/rcap/cap_1_1/area.rb
CHANGED
@@ -23,8 +23,8 @@ module RCAP
|
|
23
23
|
attr_reader( :polygons )
|
24
24
|
|
25
25
|
validates_presence_of( :area_desc )
|
26
|
-
validates_collection_of( :circles, :geocodes, :polygons )
|
27
|
-
validates_dependency_of( :ceiling, :
|
26
|
+
validates_collection_of( :circles, :geocodes, :polygons, allow_empty: true )
|
27
|
+
validates_dependency_of( :ceiling, on: :altitude )
|
28
28
|
|
29
29
|
XML_ELEMENT_NAME = 'area' # :nodoc:
|
30
30
|
AREA_DESC_ELEMENT_NAME = 'areaDesc' # :nodoc:
|
@@ -158,12 +158,12 @@ RCAP.format_lines_for_inspect( 'AREA', area_inspect )
|
|
158
158
|
POLYGONS_KEY = 'polygons' # :nodoc:
|
159
159
|
|
160
160
|
def to_h # :nodoc:
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
161
|
+
RCAP.attribute_values_to_hash( [ AREA_DESC_KEY, self.area_desc ],
|
162
|
+
[ ALTITUDE_KEY, self.altitude ],
|
163
|
+
[ CEILING_KEY, self.ceiling ],
|
164
|
+
[ CIRCLES_KEY, self.circles.map{ |circle| circle.to_h } ],
|
165
|
+
[ GEOCODES_KEY, self.geocodes.map{ |geocode| geocode.to_h } ],
|
166
|
+
[ POLYGONS_KEY, self.polygons.map{ |polygon| polygon.to_h } ])
|
167
167
|
end
|
168
168
|
|
169
169
|
def self.from_h( area_hash ) # :nodoc:
|
data/lib/rcap/cap_1_1/polygon.rb
CHANGED
@@ -54,7 +54,7 @@ module RCAP
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def self.from_xml_element( polygon_xml_element ) # :nodoc:
|
57
|
-
if !polygon_xml_element.text.nil?
|
57
|
+
if !polygon_xml_element.text.nil? && !polygon_xml_element.text.empty?
|
58
58
|
coordinates = self.parse_polygon_string( polygon_xml_element.text )
|
59
59
|
points = coordinates.map{ |lattitude, longitude| Point.new( :lattitude => lattitude, :longitude => longitude )}[0..-2]
|
60
60
|
polygon = self.new( :points => points )
|
data/lib/rcap/cap_1_2/area.rb
CHANGED
@@ -23,8 +23,8 @@ module RCAP
|
|
23
23
|
attr_reader( :polygons )
|
24
24
|
|
25
25
|
validates_presence_of( :area_desc )
|
26
|
-
validates_collection_of( :circles, :geocodes, :polygons )
|
27
|
-
validates_dependency_of( :ceiling, :
|
26
|
+
validates_collection_of( :circles, :geocodes, :polygons, allow_empty: true )
|
27
|
+
validates_dependency_of( :ceiling, on: :altitude )
|
28
28
|
|
29
29
|
XML_ELEMENT_NAME = 'area' # :nodoc:
|
30
30
|
AREA_DESC_ELEMENT_NAME = 'areaDesc' # :nodoc:
|
@@ -158,12 +158,12 @@ RCAP.format_lines_for_inspect( 'AREA', area_inspect )
|
|
158
158
|
POLYGONS_KEY = 'polygons' # :nodoc:
|
159
159
|
|
160
160
|
def to_h # :nodoc:
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
161
|
+
RCAP.attribute_values_to_hash( [ AREA_DESC_KEY, self.area_desc ],
|
162
|
+
[ ALTITUDE_KEY, self.altitude ],
|
163
|
+
[ CEILING_KEY, self.ceiling ],
|
164
|
+
[ CIRCLES_KEY, self.circles.map{ |circle| circle.to_h } ],
|
165
|
+
[ GEOCODES_KEY, self.geocodes.map{ |geocode| geocode.to_h } ],
|
166
|
+
[ POLYGONS_KEY, self.polygons.map{ |polygon| polygon.to_h } ])
|
167
167
|
end
|
168
168
|
|
169
169
|
def self.from_h( area_hash ) # :nodoc:
|
data/lib/rcap/cap_1_2/polygon.rb
CHANGED
@@ -55,7 +55,7 @@ module RCAP
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def self.from_xml_element( polygon_xml_element ) # :nodoc:
|
58
|
-
if !polygon_xml_element.text.
|
58
|
+
if polygon_xml_element.text && !polygon_xml_element.text.empty?
|
59
59
|
coordinates = self.parse_polygon_string( polygon_xml_element.text )
|
60
60
|
points = coordinates.map{ |lattitude, longitude| Point.new( :lattitude => lattitude, :longitude => longitude )}
|
61
61
|
polygon = self.new( :points => points )
|
data/lib/rcap/utilities.rb
CHANGED
@@ -70,7 +70,7 @@ module RCAP # :nodoc:
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def self.attribute_values_to_hash( *attribute_values )
|
73
|
-
Hash[ *attribute_values.reject{ |key, value| value.
|
73
|
+
Hash[ *attribute_values.reject{ |key, value| value.nil? || ( value.respond_to?( :'emtpy?' ) && value.empty? )}.flatten( 1 )]
|
74
74
|
end
|
75
75
|
|
76
76
|
def self.to_s_for_cap( object )
|
data/lib/rcap/validations.rb
CHANGED
@@ -10,7 +10,7 @@ module Validation # :nodoc:
|
|
10
10
|
}.merge!( attributes.extract_options! )
|
11
11
|
|
12
12
|
validates_each( *attributes ) do |object, attribute, value|
|
13
|
-
next if ( value.nil? && options[ :allow_nil ])
|
13
|
+
next if ( value.nil? && options[ :allow_nil ])
|
14
14
|
unless options[ :in ].include?( value )
|
15
15
|
object.errors[ attribute ] << options[ :message ]
|
16
16
|
end
|
@@ -23,7 +23,7 @@ module Validation # :nodoc:
|
|
23
23
|
}.merge!( attributes.extract_options! )
|
24
24
|
|
25
25
|
validates_each( *attributes ) do |object, attribute, collection|
|
26
|
-
next if ( collection.nil? && options[ :allow_nil ]) || (collection.
|
26
|
+
next if ( collection.nil? && options[ :allow_nil ]) || ( collection.empty? && options[ :allow_empty ])
|
27
27
|
unless collection.all?{ |member| options[ :in ].include?( member )}
|
28
28
|
object.errors[ attribute ] << options[ :message ]
|
29
29
|
end
|
@@ -36,7 +36,7 @@ module Validation # :nodoc:
|
|
36
36
|
}.merge!( attributes.extract_options! )
|
37
37
|
|
38
38
|
validates_each( *attributes ) do |object, attribute, collection|
|
39
|
-
next if ( collection.nil? && options[ :allow_nil ])
|
39
|
+
next if ( collection.nil? && options[ :allow_nil ])
|
40
40
|
unless options[ :minimum ] && collection.length >= options[ :minimum ]
|
41
41
|
object.errors[ attribute ] << options[ :message ]
|
42
42
|
end
|
@@ -49,7 +49,7 @@ module Validation # :nodoc:
|
|
49
49
|
}.merge!( attributes.extract_options! )
|
50
50
|
|
51
51
|
validates_each( *attributes ) do |object, attribute, value|
|
52
|
-
next if ( value.nil? && options[ :allow_nil ])
|
52
|
+
next if ( value.nil? && options[ :allow_nil ])
|
53
53
|
unless value && value.valid?
|
54
54
|
object.errors[ attribute ] << options[ :message ]
|
55
55
|
end
|
@@ -62,7 +62,7 @@ module Validation # :nodoc:
|
|
62
62
|
}.merge!( attributes.extract_options! )
|
63
63
|
|
64
64
|
validates_each( *attributes ) do |object, attribute, collection|
|
65
|
-
next if ( collection.nil? && options[ :allow_nil ]) || ( collection.
|
65
|
+
next if ( collection.nil? && options[ :allow_nil ]) || ( collection.empty? && options[ :allow_empty ])
|
66
66
|
unless collection.all?{ |element| element.valid? }
|
67
67
|
object.errors[ attribute ] << options[ :message ]
|
68
68
|
end
|
@@ -110,7 +110,7 @@ module Validation # :nodoc:
|
|
110
110
|
re = options[:only_integer] ? CAP_INTEGER_REGEX : CAP_NUMBER_REGEX
|
111
111
|
|
112
112
|
validates_each( *attributes ) do |object, attribute, value|
|
113
|
-
next if (value.nil? && options[ :allow_nil ])
|
113
|
+
next if (value.nil? && options[ :allow_nil ])
|
114
114
|
unless ( value.to_s =~ re ) &&
|
115
115
|
( options[ :greater_than ].nil? || value && value > options[ :greater_than ]) &&
|
116
116
|
( options[ :greater_than_or_equal ].nil? || value && value >= options[ :greater_than_or_equal])
|
@@ -126,7 +126,7 @@ module Validation # :nodoc:
|
|
126
126
|
}.merge!( attributes.extract_options! )
|
127
127
|
|
128
128
|
validates_each( *attributes ) do |object, attribute, value|
|
129
|
-
next if ( collection.nil? && options[ :allow_nil ])
|
129
|
+
next if ( collection.nil? && options[ :allow_nil ])
|
130
130
|
unless options[ :to ].all?{ |method_name| object.respond_to?( method_name )}
|
131
131
|
object.errors[ attribute ] << options [ :message ]
|
132
132
|
end
|
@@ -139,7 +139,7 @@ module Validation # :nodoc:
|
|
139
139
|
}.merge!( attributes.extract_options! )
|
140
140
|
|
141
141
|
validates_each( *attributes ) do |object, attribute, collection|
|
142
|
-
next if ( collection.nil? && options[ :allow_nil ])
|
142
|
+
next if ( collection.nil? && options[ :allow_nil ])
|
143
143
|
unless collection.first == collection.last
|
144
144
|
object.errors[ attribute ] << options[ :message ]
|
145
145
|
end
|
data/lib/rcap/version.rb
CHANGED
metadata
CHANGED
@@ -7,8 +7,8 @@ version: !ruby/object:Gem::Version
|
|
7
7
|
- 0
|
8
8
|
- 0
|
9
9
|
- rc
|
10
|
-
-
|
11
|
-
version: 1.0.0.rc.
|
10
|
+
- 4
|
11
|
+
version: 1.0.0.rc.4
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Farrel Lifson
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-04-
|
19
|
+
date: 2011-04-05 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|