aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMichel Etienne2015-09-24 14:56:42 +0200
committerMichel Etienne2015-09-24 14:56:42 +0200
commitd0ae24fa9d0082a322ed7457090e4dfecf89042f (patch)
tree8d101e5017aeac41e95bb81bd5460f77e9419d11 /lib
parentdf9469f96e7ac102e27e682581f3f7b604934578 (diff)
downloadchouette-core-d0ae24fa9d0082a322ed7457090e4dfecf89042f.tar.bz2
adapt to Neptune specifications V4
Diffstat (limited to 'lib')
-rw-r--r--lib/ninoxe_extension/hub/company_restrictions.rb3
-rw-r--r--lib/ninoxe_extension/hub/connection_link_restrictions.rb4
-rw-r--r--lib/ninoxe_extension/hub/group_of_line_restrictions.rb3
-rw-r--r--lib/ninoxe_extension/hub/journey_pattern_restrictions.rb3
-rw-r--r--lib/ninoxe_extension/hub/line_restrictions.rb3
-rw-r--r--lib/ninoxe_extension/hub/network_restrictions.rb11
-rw-r--r--lib/ninoxe_extension/hub/objectid_restrictions.rb2
-rw-r--r--lib/ninoxe_extension/hub/stop_area_restrictions.rb24
-rw-r--r--lib/ninoxe_extension/hub/time_table_restrictions.rb7
-rw-r--r--lib/ninoxe_extension/hub/vehicle_journey_restrictions.rb4
10 files changed, 38 insertions, 26 deletions
diff --git a/lib/ninoxe_extension/hub/company_restrictions.rb b/lib/ninoxe_extension/hub/company_restrictions.rb
index 190b63cd2..6cb12f0b6 100644
--- a/lib/ninoxe_extension/hub/company_restrictions.rb
+++ b/lib/ninoxe_extension/hub/company_restrictions.rb
@@ -9,7 +9,8 @@ module NinoxeExtension::Hub
# HUB-7
g.validate :specific_objectid
# HUB-8
- g.validates_format_of :name, :with => %r{\A[\w]{1,75}\z}
+ #g.validates_format_of :name, :with => %r{\A[\w ]{1,75}\z}
+ g.validates_length_of :name, :minimum => 1, :maximum => 75
# HUB-9
g.validates_format_of :registration_number, :with => %r{\A[\d]{1,8}\z}
g.validates_uniqueness_of :registration_number
diff --git a/lib/ninoxe_extension/hub/connection_link_restrictions.rb b/lib/ninoxe_extension/hub/connection_link_restrictions.rb
index bf433379b..600222455 100644
--- a/lib/ninoxe_extension/hub/connection_link_restrictions.rb
+++ b/lib/ninoxe_extension/hub/connection_link_restrictions.rb
@@ -6,9 +6,9 @@ module NinoxeExtension::Hub
included do
include ObjectidRestrictions
- with_options if: :hub_restricted? do |jp|
+ with_options if: :hub_restricted? do |cl|
# HUB-34
- jp.validates :link_distance, :numericality => { :max => 10000.0 }
+ cl.validates :link_distance, :numericality => { :max => 10000.0 }
end
end
end
diff --git a/lib/ninoxe_extension/hub/group_of_line_restrictions.rb b/lib/ninoxe_extension/hub/group_of_line_restrictions.rb
index d5de71ce0..f8370faf1 100644
--- a/lib/ninoxe_extension/hub/group_of_line_restrictions.rb
+++ b/lib/ninoxe_extension/hub/group_of_line_restrictions.rb
@@ -10,7 +10,8 @@ module NinoxeExtension::Hub
# HUB-11
g.validate :specific_objectid
# HUB-12
- g.validates_format_of :name, :with => %r{\A[\w]{1,75}\z}
+ #g.validates_format_of :name, :with => %r{\A[\w ]{1,75}\z}
+ g.validates_length_of :name, :minimum => 1, :maximum => 75
# HUB-13
g.validates_format_of :registration_number, :with => %r{\A[\d]{1,8}\z}
g.validates_uniqueness_of :registration_number
diff --git a/lib/ninoxe_extension/hub/journey_pattern_restrictions.rb b/lib/ninoxe_extension/hub/journey_pattern_restrictions.rb
index 448be9665..d4e881d1f 100644
--- a/lib/ninoxe_extension/hub/journey_pattern_restrictions.rb
+++ b/lib/ninoxe_extension/hub/journey_pattern_restrictions.rb
@@ -12,7 +12,8 @@ module NinoxeExtension::Hub
# HUB-40
jp.validates :registration_number, :numericality => { :less_than => 10 ** 8 }
# HUB-41
- jp.validates_format_of :name, :with => %r{\A[\w]{0,75}\z}
+ #jp.validates_format_of :name, :with => %r{\A[\w ]{0,75}\z}
+ jp.validates_length_of :name, :maximum => 75, :allow_blank => true, :allow_nil => true
end
end
def specific_objectid
diff --git a/lib/ninoxe_extension/hub/line_restrictions.rb b/lib/ninoxe_extension/hub/line_restrictions.rb
index 616d1fd52..9d8f22112 100644
--- a/lib/ninoxe_extension/hub/line_restrictions.rb
+++ b/lib/ninoxe_extension/hub/line_restrictions.rb
@@ -14,7 +14,8 @@ module NinoxeExtension::Hub
# HUB-16
l.validates_format_of :number, :with => %r{\A[\w]{1,6}\z}
# HUB-17
- l.validates_format_of :name, :with => %r{\A[\w]{0,75}\z}
+ #l.validates_format_of :name, :with => %r{\A[\w ]{0,75}\z}
+ l.validates_length_of :name, :maximum => 75
# HUB-21
l.validates :registration_number, :numericality => { :less_than => 10 ** 8 }
# HUB-22
diff --git a/lib/ninoxe_extension/hub/network_restrictions.rb b/lib/ninoxe_extension/hub/network_restrictions.rb
index 7966736ec..b18a6c033 100644
--- a/lib/ninoxe_extension/hub/network_restrictions.rb
+++ b/lib/ninoxe_extension/hub/network_restrictions.rb
@@ -5,14 +5,15 @@ module NinoxeExtension::Hub
included do
include ObjectidRestrictions
- with_options if: :hub_restricted? do |g|
+ with_options if: :hub_restricted? do |n|
# HUB-3
- g.validate :specific_objectid
+ n.validate :specific_objectid
# HUB-4
- g.validates_format_of :name, :with => %r{\A[\w]{1,75}\z}
+ #n.validates_format_of :name, :with => %r{\A[\w ]{1,75}\z}
+ n.validates_length_of :name, :minimum => 1, :maximum => 75
# HUB-5
- g.validates_format_of :registration_number, :with => %r{\A[\d]{1,8}\z}
- g.validates_uniqueness_of :registration_number
+ n.validates_format_of :registration_number, :with => %r{\A[\d]{1,8}\z}
+ n.validates_uniqueness_of :registration_number
end
end
def specific_objectid
diff --git a/lib/ninoxe_extension/hub/objectid_restrictions.rb b/lib/ninoxe_extension/hub/objectid_restrictions.rb
index a84e1428f..1fcdb94cb 100644
--- a/lib/ninoxe_extension/hub/objectid_restrictions.rb
+++ b/lib/ninoxe_extension/hub/objectid_restrictions.rb
@@ -22,7 +22,7 @@ module NinoxeExtension::Hub::ObjectidRestrictions
return unless hub_restricted?
return true unless third_part_objectid
- likes = Chouette::Line.where( "objectid LIKE ?", "%:#{self.third_part_objectid}" )
+ likes = self.class.where( "objectid LIKE ?", "%:#{self.third_part_objectid}" )
likes.size.zero? || ( likes.size==1 && likes.first.id==self.id)
end
end
diff --git a/lib/ninoxe_extension/hub/stop_area_restrictions.rb b/lib/ninoxe_extension/hub/stop_area_restrictions.rb
index 8701c291c..676dac05e 100644
--- a/lib/ninoxe_extension/hub/stop_area_restrictions.rb
+++ b/lib/ninoxe_extension/hub/stop_area_restrictions.rb
@@ -10,10 +10,10 @@ module NinoxeExtension::Hub
self.area_type=="CommercialStopPoint"
end
def physical_hub_restricted?
- hub_restricted? && commercial?
+ hub_restricted? && physical?
end
def commercial_hub_restricted?
- hub_restricted? && physical?
+ hub_restricted? && commercial?
end
def commercial_and_physical_hub_restricted?
physical_hub_restricted? || commercial_hub_restricted?
@@ -27,28 +27,34 @@ module NinoxeExtension::Hub
with_options if: :commercial_and_physical_hub_restricted? do |sa|
- # HUB-23
+ # HUB-23
sa.validate :specific_objectid
- sa.validates_format_of :name, :with => %r{\A[\w]{1,75}\z}
+ #sa.validates_format_of :name, :with => %r{\A[\w ]{1,75}\z}
+ sa.validates_length_of :name, :minimum => 1, :maximum => 75
end
+
with_options if: :commercial_hub_restricted? do |sa|
# HUB-24
- validates_format_of :nearest_topic_name, :with => %r{\A[\w]{0,255}\z}
+ #sa.validates_format_of :nearest_topic_name, :with => %r{\A[\w ]{0,255}\z}
+ sa.validates_length_of :nearest_topic_name, :maximum => 255, :allow_blank => true, :allow_nil => true
end
with_options if: :physical_hub_restricted? do |sa|
# HUB-25
- sa.validates_format_of :nearest_topic_name, :with => %r{\A[\w]{0,60}\z}
+ #sa.validates_format_of :nearest_topic_name, :with => %r{\A[\w ]{0,60}\z}
+ sa.validates_length_of :nearest_topic_name, :maximum => 60, :allow_blank => true, :allow_nil => true
# HUB-28
sa.validates_presence_of :longitude
sa.validates_presence_of :latitude
# HUB-29
- sa.validates_format_of :city_name, :with => %r{\A[\w]{1,80}\z}
+ #sa.validates_format_of :city_name, :with => %r{\A[\w ]{1,80}\z}
+ sa.validates_length_of :city_name, :minimum => 1, :maximum => 80
+
# HUB-30
sa.validates_format_of :zip_code, :with => %r{\A[\d]{5}\z}
# HUB-31
- sa.validates_format_of :comment, :with => %r{\A[\w]{0,255}\z}
- # HUB-32
+ # sa.validates_format_of :comment, :with => %r{\A[\w ]{0,255}\z}
+ sa.validates_length_of :comment, :maximum => 255, :allow_blank => true, :allow_nil => true
sa.validates_format_of :registration_number, :with => %r{\A[\w]{1,8}\z}, :allow_blank => true, :allow_nil => true
end
end
diff --git a/lib/ninoxe_extension/hub/time_table_restrictions.rb b/lib/ninoxe_extension/hub/time_table_restrictions.rb
index 591810f42..36e6846ae 100644
--- a/lib/ninoxe_extension/hub/time_table_restrictions.rb
+++ b/lib/ninoxe_extension/hub/time_table_restrictions.rb
@@ -6,11 +6,12 @@ module NinoxeExtension::Hub
included do
include ObjectidRestrictions
- with_options if: :hub_restricted? do |jp|
+ with_options if: :hub_restricted? do |tt|
# HUB-44
- jp.validate :specific_objectid
+ tt.validate :specific_objectid
# HUB-45
- jp.validates_format_of :comment, :with => %r{\A[\w]{0,75}\z}
+ #tt.validates_format_of :comment, :with => %r{\A[\w ]{0,75}\z}
+ tt.validates_length_of :comment, :maximum => 75, :allow_blank => true, :allow_nil => true
end
end
def specific_objectid
diff --git a/lib/ninoxe_extension/hub/vehicle_journey_restrictions.rb b/lib/ninoxe_extension/hub/vehicle_journey_restrictions.rb
index 151123a43..b1a493207 100644
--- a/lib/ninoxe_extension/hub/vehicle_journey_restrictions.rb
+++ b/lib/ninoxe_extension/hub/vehicle_journey_restrictions.rb
@@ -7,8 +7,8 @@ module NinoxeExtension::Hub
include ObjectidRestrictions
# HUB-42
- with_options if: :hub_restricted? do |jp|
- jp.validate :specific_objectid
+ with_options if: :hub_restricted? do |vj|
+ vj.validate :specific_objectid
end
end
def specific_objectid