From 736bd34d8c496b81d456d4e4897197eac344247d Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 14 Feb 2018 15:13:21 +0100 Subject: Refs #5924 @2h; Update specs --- lib/tasks/imports.rake | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'lib/tasks') diff --git a/lib/tasks/imports.rake b/lib/tasks/imports.rake index e1043106e..9c6b1fbcd 100644 --- a/lib/tasks/imports.rake +++ b/lib/tasks/imports.rake @@ -29,4 +29,32 @@ namespace :import do importer.import(verbose: true) puts "\n\e[33m***\e[0m Import done, status: " + (importer.status == "success" ? "\e[32m" : "\e[31m" ) + importer.status + "\e[0m" end + + desc "import the given file with the corresponding importer in the given Referential and StopAreaReferential" + task :import_in_referential_and_stop_area_referential, [:referential_id, :stop_area_referential_id, :configuration_name, :filepath] => :environment do |t, args| + referential = Referential.find args[:referential_id] + referential.switch + stop_area_referential = StopAreaReferential.find args[:stop_area_referential_id] + importer = SimpleImporter.create configuration_name: args[:configuration_name], filepath: args[:filepath] + importer.configure do |config| + config.add_value :stop_area_referential, referential + config.context = {stop_area_referential: stop_area_referential} + end + puts "\e[33m***\e[0m Start importing" + importer.import(verbose: true) + puts "\n\e[33m***\e[0m Import done, status: " + (importer.status == "success" ? "\e[32m" : "\e[31m" ) + importer.status + "\e[0m" + end + + desc "import the given file with the corresponding importer in the given LineReferential" + task :import_lines_in_referential, [:referential_id, :configuration_name, :filepath] => :environment do |t, args| + referential = LineReferential.find args[:referential_id] + importer = SimpleImporter.create configuration_name: args[:configuration_name], filepath: args[:filepath] + importer.configure do |config| + config.add_value :line_referential, referential + config.context = {line_referential: referential} + end + puts "\e[33m***\e[0m Start importing" + importer.import(verbose: true) + puts "\n\e[33m***\e[0m Import done, status: " + (importer.status == "success" ? "\e[32m" : "\e[31m" ) + importer.status + "\e[0m" + end end -- cgit v1.2.3