lib/app_info/apk.rb in app-info-2.5.4 vs lib/app_info/apk.rb in app-info-2.6.0

- old
+ new

@@ -1,11 +1,10 @@ # frozen_string_literal: true require 'ruby_apk' require 'image_size' require 'forwardable' -require 'app_info/util' module AppInfo # Parse APK file class APK extend Forwardable @@ -22,12 +21,12 @@ def initialize(file) @file = file end - def size(humanable = false) - AppInfo::Util.file_size(@file, humanable) + def size(human_size: false) + AppInfo::Util.file_size(@file, human_size) end def os AppInfo::Platform::ANDROID end @@ -108,33 +107,27 @@ def services components.select { |c| c.type == 'service' } end def apk - Zip.warn_invalid_date = false # fix invaild date format warnings - @apk ||= ::Android::Apk.new(@file) end def icons - unless @icons - @icons = apk.icon.each_with_object([]) do |(path, data), obj| - icon_name = File.basename(path) - icon_path = File.join(contents, File.dirname(path)) - icon_file = File.join(icon_path, icon_name) - FileUtils.mkdir_p icon_path - File.open(icon_file, 'wb') { |f| f.write(data) } + @icons ||= apk.icon.each_with_object([]) do |(path, data), obj| + icon_name = File.basename(path) + icon_path = File.join(contents, File.dirname(path)) + icon_file = File.join(icon_path, icon_name) + FileUtils.mkdir_p icon_path + File.open(icon_file, 'wb') { |f| f.write(data) } - obj << { - name: icon_name, - file: icon_file, - dimensions: ImageSize.path(icon_file).size - } - end + obj << { + name: icon_name, + file: icon_file, + dimensions: ImageSize.path(icon_file).size + } end - - @icons end def clear! return unless @contents @@ -162,18 +155,20 @@ end # Android Certificate class Certificate attr_reader :path, :certificate + def initialize(path, certificate) @path = path @certificate = certificate end end # Android Sign class Sign attr_reader :path, :sign + def initialize(path, sign) @path = path @sign = sign end end