aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichel Etienne2014-12-16 14:50:11 +0100
committerMichel Etienne2014-12-16 14:50:11 +0100
commit29e1a1e015d9986bb01e95324c282749873f1921 (patch)
treedfd49a012822fe5ec4566d5dc5c63f202d574424
parentec4d6f38a6009b1b23d9a6fe7e9aa9294d098cbd (diff)
parent7130e32053655e437b984633300123fed0a8a736 (diff)
downloadchouette-core-29e1a1e015d9986bb01e95324c282749873f1921.tar.bz2
isolate ninoxe extensions
-rw-r--r--app/models/referential.rb145
-rw-r--r--app/views/help/index.textile8
-rw-r--r--app/views/help/introduction.textile2
-rw-r--r--config/deploy.rb2
-rw-r--r--config/environment.rb2
-rw-r--r--config/initializers/ninoxe_extension.rb44
-rw-r--r--lib/ninoxe_extension/projection_fields.rb63
-rw-r--r--spec/models/ninoxe_extension_spec.rb57
-rw-r--r--spec/models/referential_spec.rb55
9 files changed, 175 insertions, 203 deletions
diff --git a/app/models/referential.rb b/app/models/referential.rb
index 41d239961..5940b57ea 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -193,149 +193,4 @@ class Referential < ActiveRecord::Base
end
-Rails.application.config.after_initialize do
-
- Chouette::TridentActiveRecord
-
- class Chouette::TridentActiveRecord
-
- # add referential relationship for objectid and localization functions
- def referential
- @referential ||= Referential.where(:slug => Apartment::Database.current_database).first!
- end
-
- # override prefix for good prefix in objectid generation
- def prefix
- self.referential.prefix
- end
-
- end
-
- Chouette::StopArea
-
- class Chouette::StopArea
-
- attr_accessible :projection_x,:projection_y,:projection_xy
-
- # override default_position method to add referential envelope when no stoparea is positioned
- def default_position
- # for first StopArea ... the bounds is nil , set to referential center
- Chouette::StopArea.bounds ? Chouette::StopArea.bounds.center : self.referential.envelope.center
- end
-
- # add projection_type set on pre-insert and pre_update action
- before_save :set_projections
- def set_projections
- if ! self.coordinates.blank?
- self.long_lat_type = 'WGS84'
- else
- self.long_lat_type = nil
- end
- end
-
- def projection
- if self.referential.projection_type.nil? || self.referential.projection_type.empty?
- nil
- else
- self.referential.projection_type
- end
- end
- @point = nil
-
- def projection_x
- if self.long_lat_type.nil? || self.projection.nil?
- nil
- else
- @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
- @point.x
- end
- end
- def projection_y
- if self.long_lat_type.nil? || self.projection.nil?
- nil
- else
- @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
- @point.y
- end
- end
- def projection_xy
- if self.long_lat_type.nil? || self.projection.nil?
- nil
- else
- @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
- @point.x.to_s+","+@point.y.to_s
- end
- end
- def projection_x=(dummy)
- # dummy method
- end
- def projection_y=(dummy)
- # dummy method
- end
- def projection_xy=(dummy)
- # dummy method
- end
-
- end
-
- Chouette::AccessPoint
-
- class Chouette::AccessPoint
- attr_accessible :projection_x,:projection_y,:projection_xy
-
- # add projection_type set on pre-insert and pre_update action
- before_save :set_projections
- def set_projections
- if ! self.coordinates.blank?
- self.long_lat_type = 'WGS84'
- else
- self.long_lat_type = nil
- end
- end
-
- def projection
- if self.referential.projection_type.nil? || self.referential.projection_type.empty?
- nil
- else
- self.referential.projection_type
- end
- end
- @point = nil
-
- def projection_x
- if self.long_lat_type.nil? || self.projection.nil?
- nil
- else
- @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
- @point.x
- end
- end
- def projection_y
- if self.long_lat_type.nil? || self.projection.nil?
- nil
- else
- @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
- @point.y
- end
- end
- def projection_xy
- if self.long_lat_type.nil? || self.projection.nil?
- nil
- else
- @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
- @point.x.to_s+","+@point.y.to_s
- end
- end
- def projection_x=(dummy)
- # dummy method
- end
- def projection_y=(dummy)
- # dummy method
- end
- def projection_xy=(dummy)
- # dummy method
- end
- end
-
-end
diff --git a/app/views/help/index.textile b/app/views/help/index.textile
index a94fa7f89..19eeb63e2 100644
--- a/app/views/help/index.textile
+++ b/app/views/help/index.textile
@@ -3,7 +3,7 @@ layout: default
title: Chouette v2
---
-Version 2.5.1
+Version 2.5.2
h3. Logiciel libre propriété de :
@@ -24,6 +24,12 @@ A cet égard l'attention de l'utilisateur est attirée sur les risques associé
h3. Notes de version
+h4. Version 2.5.2
+
+* Nouvelles foctionnalités :
+** Ajout des particularités de monté/descente aux arrêts d'une séquence
+** Ajout de tests sur les données pour l'export
+
h4. Version 2.5.1
* Nouvelles foctionnalités :
diff --git a/app/views/help/introduction.textile b/app/views/help/introduction.textile
index 78fdfa561..525ef133c 100644
--- a/app/views/help/introduction.textile
+++ b/app/views/help/introduction.textile
@@ -17,7 +17,7 @@ D'autres utilisateurs potentiels sont également identifiés : services de l'ét
h3. Ce que vous trouverez dans ce manuel
Vous trouverez dans ce document, toutes les informations nécessaires à la prise en main de l’application.
-Le manuel couvre la version 2.5.1.
+Le manuel couvre la version 2.5.2.
diff --git a/config/deploy.rb b/config/deploy.rb
index 1d5782462..0f8a3f673 100644
--- a/config/deploy.rb
+++ b/config/deploy.rb
@@ -73,6 +73,8 @@ namespace :deploy do
run "cd /usr/local/opt/chouette-command && rm -rf chouette-cmd_#{gui_cmd}"
run "cd /usr/local/opt/chouette-command && unzip chouette-gui-command-#{gui_cmd}.zip"
run "cd /usr/local/opt/chouette-command/chouette-cmd_#{gui_cmd} && chmod a+w . && sudo chgrp -R wheel ."
+ run "cd /usr/local/opt/chouette-command && rm -f chouette-cmd-current"
+ run "cd /usr/local/opt/chouette-command && ln -s chouette-cmd_#{gui_cmd} chouette-cmd-current"
end
desc "Make group writable all deployed files"
diff --git a/config/environment.rb b/config/environment.rb
index cc5593ce1..4524c894c 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -6,4 +6,4 @@ require File.expand_path('../application', __FILE__)
ChouetteIhm::Application.initialize!
# Fix version
-APP_VERSION = '2.5.1'
+APP_VERSION = '2.5.2'
diff --git a/config/initializers/ninoxe_extension.rb b/config/initializers/ninoxe_extension.rb
new file mode 100644
index 000000000..aaeb16d76
--- /dev/null
+++ b/config/initializers/ninoxe_extension.rb
@@ -0,0 +1,44 @@
+# encoding: utf-8
+
+
+Rails.application.config.after_initialize do
+
+
+ Chouette::TridentActiveRecord
+
+ class Chouette::TridentActiveRecord
+
+ # add referential relationship for objectid and localization functions
+ def referential
+ @referential ||= Referential.where(:slug => Apartment::Database.current_database).first!
+ end
+
+ # override prefix for good prefix in objectid generation
+ def prefix
+ self.referential.prefix
+ end
+
+ end
+
+ Chouette::StopArea
+
+ class Chouette::StopArea
+
+ include NinoxeExtension::ProjectionFields
+
+ # override default_position method to add referential envelope when no stoparea is positioned
+ def default_position
+ # for first StopArea ... the bounds is nil , set to referential center
+ Chouette::StopArea.bounds ? Chouette::StopArea.bounds.center : self.referential.envelope.center
+ end
+
+
+ end
+
+ Chouette::AccessPoint
+
+ class Chouette::AccessPoint
+ include NinoxeExtension::ProjectionFields
+ end
+
+end \ No newline at end of file
diff --git a/lib/ninoxe_extension/projection_fields.rb b/lib/ninoxe_extension/projection_fields.rb
new file mode 100644
index 000000000..1d12e9519
--- /dev/null
+++ b/lib/ninoxe_extension/projection_fields.rb
@@ -0,0 +1,63 @@
+
+ module NinoxeExtension::ProjectionFields
+ extend ActiveSupport::Concern
+
+ included do
+ attr_accessible :projection_x,:projection_y,:projection_xy
+
+ # add projection_type set on pre-insert and pre_update action
+ before_save :set_projections
+ def set_projections
+ if ! self.coordinates.blank?
+ self.long_lat_type = 'WGS84'
+ else
+ self.long_lat_type = nil
+ end
+ end
+
+ def projection
+ if self.referential.projection_type.nil? || self.referential.projection_type.empty?
+ nil
+ else
+ self.referential.projection_type
+ end
+ end
+ @point = nil
+
+ def projection_x
+ if self.long_lat_type.nil? || self.projection.nil?
+ nil
+ else
+ @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
+ @point.x
+ end
+ end
+ def projection_y
+ if self.long_lat_type.nil? || self.projection.nil?
+ nil
+ else
+ @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
+ @point.y
+ end
+ end
+ def projection_xy
+ if self.long_lat_type.nil? || self.projection.nil?
+ nil
+ else
+ @point ||= GeoRuby::SimpleFeatures::Point::from_lat_lng(Geokit::LatLng.new(self.latitude,self.longitude)).project_to(self.projection.to_i)
+ @point.x.to_s+","+@point.y.to_s
+ end
+ end
+ def projection_x=(dummy)
+ # dummy method
+ end
+ def projection_y=(dummy)
+ # dummy method
+ end
+ def projection_xy=(dummy)
+ # dummy method
+ end
+ end
+ end
+
+
diff --git a/spec/models/ninoxe_extension_spec.rb b/spec/models/ninoxe_extension_spec.rb
new file mode 100644
index 000000000..91d259fb6
--- /dev/null
+++ b/spec/models/ninoxe_extension_spec.rb
@@ -0,0 +1,57 @@
+require 'spec_helper'
+
+describe Chouette::StopArea do
+ # check override methods
+
+ subject {Factory(:stop_area)}
+
+ it "should return referential projection " do
+ subject.referential.projection_type='27572'
+ subject.projection.should == subject.referential.projection_type
+ end
+
+ it "should return projection coordinates when referential has projection" do
+ subject.latitude = 45
+ subject.longitude = 0
+ subject.referential.projection_type='27572'
+ subject.projection_x.should_not be_nil
+ subject.projection_y.should_not be_nil
+ end
+
+ it "should return nil projection coordinates when referential has no projection" do
+ subject.latitude = 45
+ subject.longitude = 0
+ subject.referential.projection_type=nil
+ subject.projection_x.should be_nil
+ subject.projection_y.should be_nil
+ end
+
+end
+
+describe Chouette::AccessPoint do
+ # check override methods
+
+ subject {Factory(:access_point)}
+
+ it "should return referential projection " do
+ subject.referential.projection_type='27572'
+ subject.projection.should == subject.referential.projection_type
+ end
+
+ it "should return projection coordinates when referential has projection" do
+ subject.latitude = 45
+ subject.longitude = 0
+ subject.referential.projection_type='27572'
+ subject.projection_x.should_not be_nil
+ subject.projection_y.should_not be_nil
+ end
+
+ it "should return nil projection coordinates when referential has no projection" do
+ subject.latitude = 45
+ subject.longitude = 0
+ subject.referential.projection_type=nil
+ subject.projection_x.should be_nil
+ subject.projection_y.should be_nil
+ end
+
+end
diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb
index a11bbd9de..5ea88ad20 100644
--- a/spec/models/referential_spec.rb
+++ b/spec/models/referential_spec.rb
@@ -13,58 +13,3 @@ describe Referential do
end
end
-describe Chouette::StopArea do
- # check override methods
-
- subject {Factory(:stop_area)}
-
- it "should return referential projection " do
- subject.referential.projection_type='27572'
- subject.projection.should == subject.referential.projection_type
- end
-
- it "should return projection coordinates when referential has projection" do
- subject.latitude = 45
- subject.longitude = 0
- subject.referential.projection_type='27572'
- subject.projection_x.should_not be_nil
- subject.projection_y.should_not be_nil
- end
-
- it "should return nil projection coordinates when referential has no projection" do
- subject.latitude = 45
- subject.longitude = 0
- subject.referential.projection_type=nil
- subject.projection_x.should be_nil
- subject.projection_y.should be_nil
- end
-
-end
-
-describe Chouette::AccessPoint do
- # check override methods
-
- subject {Factory(:access_point)}
-
- it "should return referential projection " do
- subject.referential.projection_type='27572'
- subject.projection.should == subject.referential.projection_type
- end
-
- it "should return projection coordinates when referential has projection" do
- subject.latitude = 45
- subject.longitude = 0
- subject.referential.projection_type='27572'
- subject.projection_x.should_not be_nil
- subject.projection_y.should_not be_nil
- end
-
- it "should return nil projection coordinates when referential has no projection" do
- subject.latitude = 45
- subject.longitude = 0
- subject.referential.projection_type=nil
- subject.projection_x.should be_nil
- subject.projection_y.should be_nil
- end
-
-end