Class: FIR::Parser::Apk

Inherits:
Object show all
Includes:
Common
Defined in:
lib/fir/util/parser/apk.rb

Instance Method Summary collapse

Methods included from Common

#generate_tmp_icon

Constructor Details

#initialize(path) ⇒ Apk

Returns a new instance of Apk.



10
11
12
13
# File 'lib/fir/util/parser/apk.rb', line 10

def initialize(path)
  Zip.warn_invalid_date = false
  @apk = ::Android::Apk.new(path)
end

Instance Method Details

#basic_infoObject



23
24
25
26
27
28
29
30
31
# File 'lib/fir/util/parser/apk.rb', line 23

def basic_info
  @basic_info ||= {
    type:       'android',
    identifier: @apk.manifest.package_name,
    name:       @apk.label,
    build:      @apk.manifest.version_code.to_s,
    version:    @apk.manifest.version_name.to_s
  }
end

#full_info(options) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/fir/util/parser/apk.rb', line 15

def full_info(options)
  if options.fetch(:full_info, false)
    basic_info.merge!(icons: tmp_icons)
  end

  basic_info
end

#tmp_iconsObject



34
35
36
37
38
39
40
# File 'lib/fir/util/parser/apk.rb', line 34

def tmp_icons
  begin
    @apk.icon.map { |_, data| generate_tmp_icon(data, :apk) }
  rescue
    []
  end
end