Class: Pilot::TesterImporter
- Defined in:
- lib/pilot/tester_importer.rb
Instance Method Summary collapse
Methods inherited from Manager
#app, #config, #fetch_app_id, #fetch_app_identifier, #login, #start
Instance Method Details
#import_testers(options) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pilot/tester_importer.rb', line 5 def import_testers() raise "Import file path is required".red unless [:testers_file_path] start() require 'csv' file = config[:testers_file_path] tester_manager = Pilot::TesterManager.new imported_tester_count = 0 is_first = true CSV.foreach(file, "r") do |row| if is_first is_first = false next end first_name, last_name, email = row unless email Helper.log.error "No email found in row: #{row}".red next end # Add this the existing config hash to pass it to the TesterManager config[:first_name] = first_name config[:last_name] = last_name config[:email] = email begin tester_manager.add_tester(config) imported_tester_count += 1 rescue => ex # do nothing, move on to the next row end end Helper.log.info "Successfully imported #{imported_tester_count} testers from #{file}".green end |