Module: FIR::Info

Defined in:
lib/fir/util/info.rb

Instance Method Summary collapse

Instance Method Details

#apk_info(apk_path, is_all) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/fir/util/info.rb', line 55

def apk_info apk_path, is_all
  apk  = Android::Apk.new(apk_path)
  info = {
    type:       'android',
    identifier: apk.manifest.package_name,
    name:       apk.label,
    build:      apk.manifest.version_code,
    version:    apk.manifest.version_name
  }

  # apk.icon is a hash, { icon_name: icon_data }
  if is_all
    info[:icons] = []
    apk.icon.each do |name, data|
      tmp_icon_path = "#{Dir.tmpdir}/icon-#{SecureRandom.hex[4..9]}.png"
      File.open(tmp_icon_path, 'w+') { |f| f << data }
      info[:icons] << tmp_icon_path
    end
  end

  info
end

#info(*args, options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fir/util/info.rb', line 6

def info *args, options
  file_path = File.absolute_path(args.first.to_s)
  is_all    = !options[:all].blank?

  check_supported_file file_path

  file_type = File.extname(file_path).delete('.')

  logger.info "Analyzing #{file_type} file......"
  logger_info_dividing_line

  app_info  = send("#{file_type}_info", file_path, is_all)
  app_info.each { |k, v| logger.info "#{k}: #{v}" }
end

#ipa_info(ipa_path, is_all) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fir/util/info.rb', line 21

def ipa_info ipa_path, is_all
  ipa = Parser::IPA.new(ipa_path)
  app = ipa.app

  info = {
    type:              'ios',
    identifier:        app.identifier,
    name:              app.name,
    display_name:      app.display_name,
    build:             app.version,
    version:           app.short_version,
    devices:           app.devices,
    release_type:      app.release_type || ipa.release_type,
    distribution_name: app.distribution_name
  }

  if is_all
    info[:icons] = []
    app.icons.each do |icon|
      tmp_icon_path = "#{Dir.tmpdir}/icon-#{SecureRandom.hex[4..9]}.png"
      FileUtils.cp(icon, tmp_icon_path)
      info[:icons] << tmp_icon_path
    end

    app.hide_developer_certificates

    info[:plist]           = app.info
    info[:mobileprovision] = app.mobileprovision
  end

  ipa.cleanup
  info
end