Class: Fastlane::Helper::AdbHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::AdbHelper
- Defined in:
- lib/fastlane/helper/adb_helper.rb
Instance Attribute Summary collapse
-
#adb_path ⇒ Object
Path to the adb binary.
-
#devices ⇒ Object
All available devices.
Instance Method Summary collapse
- #device_avalaible?(serial) ⇒ Boolean
-
#initialize(adb_path: nil) ⇒ AdbHelper
constructor
A new instance of AdbHelper.
- #load_all_devices ⇒ Object
-
#trigger(command: nil, serial: nil) ⇒ Object
Run a certain action.
Constructor Details
#initialize(adb_path: nil) ⇒ AdbHelper
Returns a new instance of AdbHelper.
18 19 20 |
# File 'lib/fastlane/helper/adb_helper.rb', line 18 def initialize(adb_path: nil) self.adb_path = adb_path end |
Instance Attribute Details
#adb_path ⇒ Object
Path to the adb binary
13 14 15 |
# File 'lib/fastlane/helper/adb_helper.rb', line 13 def adb_path @adb_path end |
#devices ⇒ Object
All available devices
16 17 18 |
# File 'lib/fastlane/helper/adb_helper.rb', line 16 def devices @devices end |
Instance Method Details
#device_avalaible?(serial) ⇒ Boolean
29 30 31 32 |
# File 'lib/fastlane/helper/adb_helper.rb', line 29 def device_avalaible?(serial) load_all_devices return devices.map(&:serial).include?(serial) end |
#load_all_devices ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fastlane/helper/adb_helper.rb', line 34 def load_all_devices self.devices = [] command = [adb_path, "devices"].join(" ") output = Actions.sh(command, log: false) output.split("\n").each do |line| if (result = line.match(/(.*)\tdevice$/)) self.devices << AdbDevice.new(serial: result[1]) end end self.devices end |
#trigger(command: nil, serial: nil) ⇒ Object
Run a certain action
23 24 25 26 27 |
# File 'lib/fastlane/helper/adb_helper.rb', line 23 def trigger(command: nil, serial: nil) android_serial = serial != "" ? "ANDROID_SERIAL=#{serial}" : nil command = [android_serial, adb_path, command].join(" ") Action.sh(command) end |