Module: Ash::Adb::Client
- Defined in:
- lib/ash/adb/client.rb
Class Method Summary collapse
Class Method Details
.devices ⇒ Object
3 4 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 |
# File 'lib/ash/adb/client.rb', line 3 def self.devices devices = [] devices_output = run('adb devices -l') # Device output is newline separated and we also want to drop the first # line which is the "List of devices attached" string device_strings = devices_output.split("\n").drop(1) device_strings.each do |device_string| # At this point a qualified device_string might look something like: # # "emulator-5554 device product:sdk_google_phone_x86 model:Android_SDK_built_for_x86 device:generic_x86" # # So we'll want to split this up and parse it accordingly attributes = device_string.split # Now attributes might look like: # ["emulator-5554", "device", "product:sdk_google_phone_x86", "model:Android_SDK_built_for_x86", "device:generic_x86"] serial_number = attributes.shift state = attributes.shift qualifiers = attributes devices << Device.new(serial_number, state, qualifiers) end devices end |
.run(cmd) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/ash/adb/client.rb', line 32 def self.run(cmd) output, errors, status = Open3.capture3(cmd) raise "Error running #{ cmd }: #{ errors.inspect }" unless errors.empty? return output end |