android-cli 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/android-cli.rb +57 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 53b6d377a97c761b81b548345593dacc11571f22
4
+ data.tar.gz: d7b9b7014e48d09b1362a18aaa89a595d8a838ef
5
+ SHA512:
6
+ metadata.gz: bb72f59dcac0385babaf0da3b84b802f905bdf3f6b1df69ef633fbf404dc050facffb1a1eee942f0118693aaa902a356d6e2cd9705430094b341b7346fd41282
7
+ data.tar.gz: 39603d44b5027e789447ef274cd43658e535d3141042fd8830e403b1408e9ab2f2af811112d6348177030c9d58029181c7118261128f2b39614f4bec57d4bfc7
@@ -0,0 +1,57 @@
1
+ # Finds Android SDK ID
2
+ #
3
+ # @author Thys Ballard Here <tballard@ishoutout.net>
4
+
5
+ class AndroidCLI
6
+
7
+ # Determines if android is installed
8
+ # @return BOOLEAN
9
+ def self.installed?
10
+ return system("which android")
11
+ end
12
+
13
+ # Runs`android list targets`
14
+ #
15
+ # @return STDOUT `android list targets`
16
+ def self.listTargets
17
+ `android list targets`
18
+ end
19
+
20
+ # Determines the Android SDK ID
21
+ #
22
+ # Searches the STDOUT of `android list targets`
23
+ # for specified Android target human-readable string
24
+ #
25
+ # @param [String] target human-readable string
26
+ # @return [Integer, nil] The android target id or nil if none could be found
27
+ def self.searchTargets(targetString)
28
+
29
+ matches = /id: ([0-9]+) or "#{targetString}"/.match(AndroidCLI.listTargets)
30
+
31
+ return nil if matches.nil?
32
+
33
+ return matches.captures[0]
34
+ end
35
+
36
+ # Runs `android update project`
37
+ #
38
+ # @param [Integer] target target ID from android list targets
39
+ # @return [Boolean] did it update the project successfully
40
+ def self.updateProject(targetId)
41
+ system("android update project -p . --subprojects --target #{targetId}")
42
+ end
43
+
44
+ # Updates a project based in a human readable target
45
+ #
46
+ # @param [String] target target string from android list targets
47
+ # @return [Boolean] did it update the project successfully
48
+ def self.updateProjectFromString(targetStr)
49
+ targetId = AndroidCLI.searchTargets(targetStr)
50
+
51
+ return false if targetId.nil?
52
+
53
+ return AndroidCLI.updateProject(targetId)
54
+
55
+ end
56
+
57
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: android-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Thys Ballard
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-08 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Runs android commands from ruby such as `android update project`
14
+ email: https://bitbucket.org/ishoutout/gem-android-cli
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/android-cli.rb
20
+ homepage: https://bitbucket.org/ishoutout/gem-android-cli
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.0.14
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: A ruby wrapper for android
44
+ test_files: []
45
+ has_rdoc: