Class: Rubtools::Tools::Android

Inherits:
Recipe
  • Object
show all
Defined in:
lib/tools/android.rb

Instance Attribute Summary collapse

Attributes inherited from Recipe

#options

Instance Method Summary collapse

Methods inherited from Recipe

#exec, #exec_without_output

Constructor Details

#initializeAndroid

Initialize the Android recipe



8
9
10
# File 'lib/tools/android.rb', line 8

def initialize
  @adb = "adb"
end

Instance Attribute Details

#adbObject

Returns the value of attribute adb.



4
5
6
# File 'lib/tools/android.rb', line 4

def adb
  @adb
end

Instance Method Details

#devicesObject

Puts the list of available devices



14
15
16
# File 'lib/tools/android.rb', line 14

def devices
  puts get_devices()
end

#remove(package) ⇒ Object

Remove packages



20
21
22
# File 'lib/tools/android.rb', line 20

def remove(package)
  uninstall(package)
end

#uninstall(packages) ⇒ Object

Uninstall packages



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/tools/android.rb', line 26

def uninstall(packages) 
  devices = get_devices()

  if devices.any?
    if devices.size > 1
      Logger.info "There is more than one device:"
      devices.each_with_index {|device, index| puts "#{index}: #{device}"}
      print "Choose one: "

      answer = STDIN.gets.chomp
      begin
        device = devices[Integer(answer)]
      rescue ArgumentError => e
        Logger.error "Error: Not a valid option (" + e.message + ")"
      end
    else
      device = devices.first
    end

    if device
      while packages.size > 0 do
        exec(@adb + " -s " + device + " uninstall " + packages.pop)
      end
    end
  else
    Logger.error "No found devices..."
  end
end