lib/ADB.rb in ADB-0.1 vs lib/ADB.rb in ADB-0.2

- old
+ new

@@ -108,9 +108,45 @@ def uninstall(package, target={}, timeout=30) execute_adb_with(timeout, "#{which_one(target)} uninstall #{package}") raise ADBError, "Could not uninstall #{package}" unless stdout_contains "Success" end + # + # execute shell command + # + # @param [String] command to be passed to the shell command + # @param [Hash] which device to wait for. Valid keys are :device, + # :emulator, and :serial. + # @param timeout value for the command to complete. Defaults to 30 + # seconds. + # + def shell(command, target={}, timeout=30) + execute_adb_with(timeout, "#{which_one(target)} wait-for-device shell #{command}") + end + + # + # format a date for adb shell date command + # + # @param date to format. Defaults current date + # + def format_date_for_adb(date=Date.new) + date.strftime("%C%y%m%d.%H%M00") + end + + # + # setup port forwarding + # + # @param the source protocol:port + # @param the destination protocol:port + # @param [Hash] which device to wait for. Valid keys are :device, + # :emulator, and :serial. + # @param timeout value for the command to complete. Defaults to 30 + # seconds. + # + def forward(source, destination, target={}, timeout=30) + execute_adb_with(timeout, "#{which_one(target)} forward #{source} #{destination}") + end + private def execute_adb_with(timeout, arguments) args = arguments.split process = ChildProcess.build('adb', *args)