Class: ParallelCalabash::AdbHelper
- Inherits:
-
Object
- Object
- ParallelCalabash::AdbHelper
show all
- Includes:
- DevicesHelper
- Defined in:
- lib/parallel_calabash/adb_helper.rb
Instance Method Summary
collapse
#device_for_process, #number_of_connected_devices
Constructor Details
#initialize(filter = []) ⇒ AdbHelper
Returns a new instance of AdbHelper.
17
18
19
|
# File 'lib/parallel_calabash/adb_helper.rb', line 17
def initialize(filter = [])
@filter = filter
end
|
Instance Method Details
#adb_devices_l ⇒ Object
21
22
23
|
# File 'lib/parallel_calabash/adb_helper.rb', line 21
def adb_devices_l
`adb devices -l`
end
|
#connected_devices_with_model_info ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/parallel_calabash/adb_helper.rb', line 25
def connected_devices_with_model_info
begin
list =
adb_devices_l.split("\n").collect do |line|
device = device_id_and_model(line)
filter_device(device)
end
list.compact.each { |device_data| device_data << screenshot_prefix(device_data.first) }
rescue
[]
end
end
|
#device_id_and_model(line) ⇒ Object
42
43
44
45
46
|
# File 'lib/parallel_calabash/adb_helper.rb', line 42
def device_id_and_model line
if line.match(/device(?!s)/)
[line.split(" ").first, line.scan(/model:(.*) device/).flatten.first]
end
end
|
#filter_device(device) ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/parallel_calabash/adb_helper.rb', line 48
def filter_device device
if @filter && !@filter.empty? && device
device unless @filter.collect { |f| device[0].match(f) || device[1].match(f) }.compact.empty?
else
device
end
end
|
#screenshot_prefix(device_id) ⇒ Object
38
39
40
|
# File 'lib/parallel_calabash/adb_helper.rb', line 38
def screenshot_prefix device_id
device_id.gsub('.', '_').gsub(/:(.*)/, '').to_s + '_'
end
|