diff options
| author | Zog | 2018-02-14 15:13:21 +0100 | 
|---|---|---|
| committer | Johan Van Ryseghem | 2018-02-20 09:50:28 +0100 | 
| commit | 736bd34d8c496b81d456d4e4897197eac344247d (patch) | |
| tree | 59a3b5c324b433286d19320ec873e37dd9fa40db /lib/tasks | |
| parent | 786aca6d55f05af6ecb95dbd845e796d213df044 (diff) | |
| download | chouette-core-736bd34d8c496b81d456d4e4897197eac344247d.tar.bz2 | |
Refs #5924 @2h; Update specs
Diffstat (limited to 'lib/tasks')
| -rw-r--r-- | lib/tasks/imports.rake | 28 | 
1 files changed, 28 insertions, 0 deletions
| 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 | 
