diff options
| -rw-r--r-- | app/models/gtfs_import.rb | 18 | ||||
| -rw-r--r-- | app/models/import.rb | 2 | ||||
| -rw-r--r-- | app/views/imports/_fields_gtfs_import.erb | 7 | ||||
| -rw-r--r-- | config/locales/imports.yml | 34 | ||||
| -rw-r--r-- | spec/models/gtfs_import_spec.rb | 75 |
5 files changed, 135 insertions, 1 deletions
diff --git a/app/models/gtfs_import.rb b/app/models/gtfs_import.rb new file mode 100644 index 000000000..a332fe65e --- /dev/null +++ b/app/models/gtfs_import.rb @@ -0,0 +1,18 @@ +class GtfsImport < Import + + validates_presence_of :objectid_prefix + option :objectid_prefix + option :max_distance_for_commercial + option :ignore_last_word + option :ignore_end_chars + option :max_distance_for_connection_link + + def import_options + super.merge(:format => :gtfs, :objectid_prefix => objectid_prefix, + :max_distance_for_commercial => max_distance_for_commercial, + :ignore_last_word => ignore_last_word, + :ignore_end_chars => ignore_end_chars, + :max_distance_for_connection_link => max_distance_for_connection_link) + end + +end diff --git a/app/models/import.rb b/app/models/import.rb index b898cc8e3..414e667b9 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -36,7 +36,7 @@ class Import < ActiveRecord::Base subclasses.map(&:to_s) else # FIXME - %w{NeptuneImport CsvImport} + %w{NeptuneImport CsvImport GtfsImport} end end diff --git a/app/views/imports/_fields_gtfs_import.erb b/app/views/imports/_fields_gtfs_import.erb new file mode 100644 index 000000000..dd75a41a5 --- /dev/null +++ b/app/views/imports/_fields_gtfs_import.erb @@ -0,0 +1,7 @@ +<%= form.input :objectid_prefix, :input_html => { :value => @referential.prefix } %> +<%= form.input :max_distance_for_commercial , :as => :number , :input_html => { :value => 50 } %> +<%= form.input :ignore_last_word , :as => :boolean , :input_html => { :value => false }%> +<%= form.input :ignore_end_chars , :as => :number , :input_html => { :value => 0 }%> +<%= form.input :max_distance_for_connection_link , :as => :number , :input_html => { :value => 100 }%> + + diff --git a/config/locales/imports.yml b/config/locales/imports.yml index 70f15979d..6f353a7d4 100644 --- a/config/locales/imports.yml +++ b/config/locales/imports.yml @@ -64,6 +64,8 @@ en: SAVE: Save SAVE_OK: "%{0} saved" SAVE_ERROR: "%{0} save failed : %{1}" + IMPORT_ERROR: "Import Error" + EXCEPTION: "Problem : %{0}" severities: info: Information uncheck: Unchecked @@ -85,15 +87,30 @@ en: zero: CSV import one: CSV import other: CSV imports + gtfs_import: + zero: GTFS import + one: GTFS import + other: GTFS imports attributes: import: resources: File to import status: Status objectid_prefix: "Neptune Id prefix" + max_distance_for_commercial: "Max distance for commercial stop" + max_distance_for_connection_link: "Max distance for connection link" + ignore_last_word: "ignore last word" + ignore_end_chars: "ignore last chars" import_log_message: created_at: Date position: N. full_message: Message + formtastic: + hints: + import: + max_distance_for_commercial: "Maximal distance to merge homonymous stops in commercial stop in meter" + max_distance_for_connection_link: "Maximal distance to link stops by connection link stop in meter" + ignore_last_word: "ignore last word on stop name in homonymous detection (inappliable when just one word occurs)" + ignore_end_chars: "ignore some chars at the end of stop names in homonymous detection" fr: imports: actions: @@ -160,6 +177,8 @@ fr: SAVE: Sauvegarde SAVE_OK: "%{0} enregistré" SAVE_ERROR: "Echec de l'enregistrement de %{0} : %{1}" + IMPORT_ERROR: "Erreur d'import" + EXCEPTION: "Problème : %{0}" severities: info: Information uncheck: Non testé @@ -181,12 +200,27 @@ fr: zero: import CSV one: import CSV other: imports CSV + gtfs_import: + zero: import GTFS + one: import GTFS + other: imports GTFS attributes: import: resources: Fichier à importer status: Status objectid_prefix: "Préfixe d'identifiants" + max_distance_for_commercial: "Distance max pour créer les zones" + max_distance_for_connection_link: "Distance max pour créer les correspondances" + ignore_last_word: "ignorer le dernier mot" + ignore_end_chars: "ignorer les n derniers caractères" import_log_message: created_at: Date position: "No" full_message: Message + formtastic: + hints: + import: + max_distance_for_commercial: "Distance maximale entre deux arrêts homonymes pour créer les zones d'arrêt (en mètre)" + max_distance_for_connection_link: "Distance maximale entre deux arrêts pour créer les correspondances (en mètre)" + ignore_last_word: "ignorer le dernier mot pour détecter l'homonymie des noms d'arrêt (inappliable quand le nom ne comporte qu'un mot)" + ignore_end_chars: "ignorer les n derniers caractères du nom de l'arrêt pour détecter l'homonymie" diff --git a/spec/models/gtfs_import_spec.rb b/spec/models/gtfs_import_spec.rb new file mode 100644 index 000000000..f22a2d20d --- /dev/null +++ b/spec/models/gtfs_import_spec.rb @@ -0,0 +1,75 @@ +require 'spec_helper' + +describe GtfsImport do + + describe "#objectid_prefix" do + + it "should be included in options" do + subject.objectid_prefix = "dummy" + subject.options.should include "objectid_prefix" => "dummy" + end + + it "should be included in import_options" do + subject.objectid_prefix = "dummy" + subject.import_options.should include :objectid_prefix => "dummy" + end + + end + + describe "#max_distance_for_commercial" do + + it "should be included in options" do + subject.max_distance_for_commercial = 300 + subject.options.should include "max_distance_for_commercial" => 300 + end + + it "should be included in import_options" do + subject.max_distance_for_commercial = 300 + subject.import_options.should include :max_distance_for_commercial => 300 + end + + end + + describe "#max_distance_for_connection_link" do + + it "should be included in options" do + subject.max_distance_for_connection_link = 300 + subject.options.should include "max_distance_for_connection_link" => 300 + end + + it "should be included in import_options" do + subject.max_distance_for_connection_link = 300 + subject.import_options.should include :max_distance_for_connection_link => 300 + end + + end + + describe "#ignore_last_word" do + + it "should be included in options" do + subject.ignore_last_word = true + subject.options.should include "ignore_last_word" => true + end + + it "should be included in import_options" do + subject.ignore_last_word = true + subject.import_options.should include :ignore_last_word => true + end + + end + + describe "#ignore_end_chars" do + + it "should be included in options" do + subject.ignore_end_chars = 2 + subject.options.should include "ignore_end_chars" => 2 + end + + it "should be included in import_options" do + subject.ignore_end_chars = 2 + subject.import_options.should include :ignore_end_chars => 2 + end + + end + +end |
