Class: KrakenMobile::DevicesHelper::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/kraken-mobile/helpers/devices_helper/manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Manager

Returns a new instance of Manager.



9
10
11
12
# File 'lib/kraken-mobile/helpers/devices_helper/manager.rb', line 9

def initialize(options)
  @runner_name = options[:runner]
  @config_path = options[:config_path]
end

Instance Method Details

#connected_devicesObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/kraken-mobile/helpers/devices_helper/manager.rb', line 14

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

#device_helperObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/kraken-mobile/helpers/devices_helper/manager.rb', line 31

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