apktools 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/bin/get_app_version.rb +57 -0
  2. metadata +5 -2
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Copyright (C) 2012 Dave Smith
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of this
6
+ # software and associated documentation files (the "Software"), to deal in the Software
7
+ # without restriction, including without limitation the rights to use, copy, modify,
8
+ # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
9
+ # persons to whom the Software is furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in all copies
12
+ # or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15
+ # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16
+ # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
17
+ # FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18
+ # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19
+ # DEALINGS IN THE SOFTWARE.
20
+
21
+ require 'apktools/apkxml'
22
+
23
+ # Read version information out of the given APK
24
+ # Returns an array of [versionCode, versionName]
25
+
26
+ if ARGV.length != 1
27
+ puts "usage: get_app_version <APKFile>"
28
+ exit(1)
29
+ end
30
+
31
+ apk_file = ARGV[0]
32
+
33
+ # Load the XML data
34
+ parser = ApkXml.new(apk_file)
35
+ parser.parse_xml("AndroidManifest.xml", false, true)
36
+
37
+ elements = parser.xml_elements
38
+
39
+ versionCode = nil
40
+ versionName = nil
41
+
42
+ elements.each do |element|
43
+ if element.name != "manifest"
44
+ next
45
+ end
46
+
47
+
48
+ element.attributes.each do |attr|
49
+ if attr.name == "versionCode"
50
+ versionCode = attr.value
51
+ elsif attr.name == "versionName"
52
+ versionName = attr.value
53
+ end
54
+ end
55
+ end
56
+
57
+ puts [versionCode, versionName]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apktools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -29,13 +29,16 @@ dependencies:
29
29
  version: '0'
30
30
  description: Library to assist reading resource data out of Android APKs
31
31
  email: dave@xcellentcreations.com
32
- executables: []
32
+ executables:
33
+ - get_app_version.rb
33
34
  extensions: []
34
35
  extra_rdoc_files: []
35
36
  files:
36
37
  - lib/apktools/apkresources.rb
37
38
  - lib/apktools/apkxml.rb
38
39
  - lib/apktools/resconfiguration.rb
40
+ - !binary |-
41
+ YmluL2dldF9hcHBfdmVyc2lvbi5yYg==
39
42
  homepage: http://github.com/devunwired/apktools
40
43
  licenses: []
41
44
  post_install_message: