Class: Headdesk::ApkTool
- Inherits:
-
Object
- Object
- Headdesk::ApkTool
- Defined in:
- lib/headdesk/apktool.rb
Overview
Wrapper around using ibotpeaches.github.io/Apktool/
Class Method Summary collapse
- .apktool_jar ⇒ Object
-
.cmd(*args) ⇒ Object
Run apktool command.
-
.unpack_to(path, destination) ⇒ Object
Unpacks an APK to the specified path.
Class Method Details
.apktool_jar ⇒ Object
10 11 12 13 |
# File 'lib/headdesk/apktool.rb', line 10 def self.apktool_jar File.join(File.dirname(__FILE__), '..', '..', "ext/apktool_#{APKTOOL_VERSION}.jar") end |
.cmd(*args) ⇒ Object
Run apktool command
:reek:TooManyStatements
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/headdesk/apktool.rb', line 19 def self.cmd(*args) _stdin, stdout, stderr, wait_thr = Open3.popen3('java', '-jar', apktool_jar, *args) r_stdout = stdout.gets(nil) stdout.close r_stderr = stderr.gets(nil) stderr.close r_exit_code = wait_thr.value [r_stdout, r_stderr, r_exit_code] end |
.unpack_to(path, destination) ⇒ Object
Unpacks an APK to the specified path
:reek:TooManyStatements
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/headdesk/apktool.rb', line 34 def self.unpack_to(path, destination) throw CliError.new("File not found: #{path}") unless File.exist?(path) throw CliError.new("Path not found: #{destination}") unless Dir.exist?(destination) args = ['d', '--force', '--output', destination] stdout, stderr, exit_code = Headdesk::ApkTool.cmd(*args, path) raise stderr unless exit_code.to_i.zero? stdout end |