Sha256: 237714072a2e63ed89460573775d1a4cb7c06d13836dc7e56896a165825bff75

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

require "fastlane_core"

module Pilot
  class TesterImporter < Manager
    def import_testers(options)
      raise "Import file path is required".red unless options[:testers_file_path]

      start(options)

      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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pilot-0.1.7 lib/pilot/tester_importer.rb
pilot-0.1.6 lib/pilot/tester_importer.rb
pilot-0.1.5 lib/pilot/tester_importer.rb
pilot-0.1.4 lib/pilot/tester_importer.rb
pilot-0.1.3 lib/pilot/tester_importer.rb
pilot-0.1.2 lib/pilot/tester_importer.rb