Sha256: fe08ef570c8b70ea6f1394605ae9e593060d2ac26a4812f4c9d150e0c6b5e2f7

Contents?: true

Size: 1.28 KB

Versions: 8

Compression:

Stored size: 1.28 KB

Contents

require 'kraken-mobile/models/device'
require 'kraken-mobile/helpers/devices_helper/adb_helper'
require 'kraken-mobile/constants'
require 'json'

module KrakenMobile
	module DevicesHelper
    class Manager
      def initialize(options)
        @runner_name = options[:runner]
        @config_path = options[:config_path]
      end

      def connected_devices
        if @config_path
          raise "The path of the configuration file is not valid" unless File.exist?(@config_path) && File.file?(@config_path) && @config_path.end_with?(".json")
          file = open(@config_path)
          content = file.read
          configured_devices = JSON.parse(content)
          devices = []
          configured_devices.each do |dev_data|
            device = Models::Device.new(dev_data["id"], dev_data["model"], devices.size + 1, dev_data["config"])
            devices << device
          end
          devices
        else
          device_helper.connected_devices
        end
      end

      def device_helper
        case @runner_name
        when KrakenMobile::Constants::CALABASH_ANDROID
          DevicesHelper::AdbHelper.new()
        when KrakenMobile::Constants::MONKEY
          DevicesHelper::AdbHelper.new()
        else
          raise "Runner is not supported"
        end
      end
    end
	end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
kraken-mobile-1.0.9 lib/kraken-mobile/helpers/devices_helper/manager.rb
kraken-mobile-1.0.8 lib/kraken-mobile/helpers/devices_helper/manager.rb
kraken-mobile-1.0.5 lib/kraken-mobile/helpers/devices_helper/manager.rb
kraken-mobile-1.0.4 lib/kraken-mobile/helpers/devices_helper/manager.rb
kraken-mobile-1.0.3 lib/kraken-mobile/helpers/devices_helper/manager.rb
kraken-mobile-1.0.2 lib/kraken-mobile/helpers/devices_helper/manager.rb
kraken-mobile-1.0.1 lib/kraken-mobile/helpers/devices_helper/manager.rb
kraken-mobile-1.0.0 lib/kraken-mobile/helpers/devices_helper/manager.rb