Class: Fastlane::Helper::AdbHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::AdbHelper
- Defined in:
- fastlane/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_available?(serial) ⇒ Boolean
- #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 21 22 23 24 |
# File 'fastlane/lib/fastlane/helper/adb_helper.rb', line 18 def initialize(adb_path: nil) android_home = ENV['ANDROID_HOME'] || ENV['ANDROID_SDK_ROOT'] || ENV['ANDROID_SDK'] if (adb_path.nil? || adb_path == "adb") && android_home adb_path = File.join(android_home, "platform-tools", "adb") end self.adb_path = adb_path end |
Instance Attribute Details
#adb_path ⇒ Object
Path to the adb binary
13 14 15 |
# File 'fastlane/lib/fastlane/helper/adb_helper.rb', line 13 def adb_path @adb_path end |
#devices ⇒ Object
All available devices
16 17 18 |
# File 'fastlane/lib/fastlane/helper/adb_helper.rb', line 16 def devices @devices end |
Instance Method Details
#device_available?(serial) ⇒ Boolean
38 39 40 41 |
# File 'fastlane/lib/fastlane/helper/adb_helper.rb', line 38 def device_available?(serial) load_all_devices return devices.map(&:serial).include?(serial) end |
#device_avalaible?(serial) ⇒ Boolean
33 34 35 36 |
# File 'fastlane/lib/fastlane/helper/adb_helper.rb', line 33 def device_avalaible?(serial) UI.deprecated("Please use `device_available?` instead... This will be removed in a future version of fastlane") device_available?(serial) end |
#load_all_devices ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'fastlane/lib/fastlane/helper/adb_helper.rb', line 43 def load_all_devices self.devices = [] command = [adb_path.shellescape, "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
27 28 29 30 31 |
# File 'fastlane/lib/fastlane/helper/adb_helper.rb', line 27 def trigger(command: nil, serial: nil) android_serial = serial != "" ? "ANDROID_SERIAL=#{serial}" : nil command = [android_serial, adb_path.shellescape, command].join(" ").strip Action.sh(command) end |