Class: AndroidCLI
- Inherits:
-
Object
- Object
- AndroidCLI
- Defined in:
- lib/android-cli.rb
Overview
Finds Android SDK ID
Constant Summary collapse
- @@sdkPath =
nil
Class Method Summary collapse
- .getCMD ⇒ Object
- .getSDKPath ⇒ Object
-
.installed? ⇒ Boolean
Determines if android is installed.
-
.listTargets ⇒ Object
Runs`android list targets`.
-
.searchTargets(targetString) ⇒ Integer?
Determines the Android SDK ID.
- .setSDKPath(path) ⇒ Object
-
.updateProject(targetId) ⇒ Boolean
Runs ‘android update project`.
-
.updateProjectFromString(targetStr) ⇒ Boolean
Updates a project based in a human readable target.
Class Method Details
.getCMD ⇒ Object
24 25 26 27 |
# File 'lib/android-cli.rb', line 24 def self.getCMD raise "Android not installed" unless installed? return "#{getSDKPath}/android" end |
.getSDKPath ⇒ Object
13 14 15 16 |
# File 'lib/android-cli.rb', line 13 def self.getSDKPath return File.dirname(`which android`.strip) if @@sdkPath.nil? @@sdkPath end |
.installed? ⇒ Boolean
Determines if android is installed
20 21 22 |
# File 'lib/android-cli.rb', line 20 def self.installed? return system("which #{getSDKPath}/android") end |
.listTargets ⇒ Object
Runs`android list targets`
32 33 34 |
# File 'lib/android-cli.rb', line 32 def self.listTargets `#{getCMD} list targets` end |
.searchTargets(targetString) ⇒ Integer?
Determines the Android SDK ID
Searches the STDOUT of ‘android list targets` for specified Android target human-readable string
43 44 45 46 47 48 49 50 |
# File 'lib/android-cli.rb', line 43 def self.searchTargets(targetString) matches = /id: ([0-9]+) or "#{targetString}"/.match(AndroidCLI.listTargets) return nil if matches.nil? return matches.captures[0].to_i end |
.setSDKPath(path) ⇒ Object
9 10 11 |
# File 'lib/android-cli.rb', line 9 def self.setSDKPath(path) @@sdkPath = path end |
.updateProject(targetId) ⇒ Boolean
Runs ‘android update project`
56 57 58 |
# File 'lib/android-cli.rb', line 56 def self.updateProject(targetId) system("#{getCMD} update project -p . --subprojects --target #{targetId}") end |
.updateProjectFromString(targetStr) ⇒ Boolean
Updates a project based in a human readable target
64 65 66 67 68 69 70 71 |
# File 'lib/android-cli.rb', line 64 def self.updateProjectFromString(targetStr) targetId = AndroidCLI.searchTargets(targetStr) return false if targetId.nil? return AndroidCLI.updateProject(targetId) end |