Class: Pilot::TesterImporter
- Defined in:
- lib/pilot/tester_importer.rb
Instance Attribute Summary
Attributes inherited from Manager
Instance Method Summary collapse
Methods inherited from Manager
#app, #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 |
# File 'lib/pilot/tester_importer.rb', line 5 def import_testers() UI.user_error!("Import file path is required") unless [:testers_file_path] start() require 'csv' file = config[:testers_file_path] tester_manager = Pilot::TesterManager.new imported_tester_count = 0 CSV.foreach(file, "r") do |row| first_name, last_name, email = row unless email UI.error("No email found in row: #{row}") next end unless email.index("@") UI.error("No email found in row: #{row}") 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 # do nothing, move on to the next row end end UI.success("Successfully imported #{imported_tester_count} testers from #{file}") end |