Class: AppInfo::IPA

Inherits:
Apple show all
Defined in:
lib/app_info/ipa.rb

Constant Summary collapse

DEFAULT_MOBILEPROVISION_FILE =
'embedded.mobileprovision'

Constants included from Helper::HumanFileSize

Helper::HumanFileSize::FILE_SIZE_UNITS

Instance Attribute Summary

Attributes inherited from File

#file, #logger

Instance Method Summary collapse

Methods inherited from Apple

#archs, #build_type, #build_version, #bundle_id, #bundle_name, #contents, #device, #devices, #display_name, #distribution_name, #expired_date, #hide_developer_certificates, #identifier, #info, #ipad?, #iphone?, #manufacturer, #min_os_version, #min_sdk_version, #mobileprovision, #mobileprovision?, #name, #platform, #profile_name, #release_type, #release_version, #size, #team_identifier, #team_name, #universal?

Methods included from Helper::Archive

#tempdir, #unarchive

Methods included from Helper::HumanFileSize

#file_to_human_size, #number_to_human_size

Methods inherited from File

#device, #format, #initialize, #manufacturer, #not_implemented_error!, #platform, #size

Constructor Details

This class inherits a constructor from AppInfo::File

Instance Method Details

#app_pathString

Returns:

  • (String)


89
90
91
# File 'lib/app_info/ipa.rb', line 89

def app_path
  @app_path ||= Dir.glob(::File.join(contents, 'Payload', '*.app')).first
end

#binary_pathString

Returns:

  • (String)


79
80
81
# File 'lib/app_info/ipa.rb', line 79

def binary_path
  @binary_path ||= ::File.join(app_path, info.bundle_name)
end

#clear!Object



112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/app_info/ipa.rb', line 112

def clear!
  return unless @contents

  FileUtils.rm_rf(@contents)

  @contents = nil
  @app_path = nil
  @info_path = nil
  @info = nil
  @metadata_path = nil
  @metadata = nil
  @icons_path = nil
  @icons = nil
end

#frameworksArray<Framework>

Returns:



45
46
47
# File 'lib/app_info/ipa.rb', line 45

def frameworks
  @frameworks ||= Framework.parse(app_path)
end

#icons(uncrush: true) ⇒ Array<Hash{Symbol => String, Array<Integer>}>

Full icons metadata

Examples:

ipa.icons
# => [
#   {
#     name: 'icon.png',
#     file: '/path/to/icon.png',
#     uncrushed_file: '/path/to/uncrushed_icon.png',
#     dimensions: [64, 64]
#   },
#   {
#     name: 'icon1.png',
#     file: '/path/to/icon1.png',
#     uncrushed_file: '/path/to/uncrushed_icon1.png',
#     dimensions: [120, 120]
#   }
# ]

Returns:

  • (Array<Hash{Symbol => String, Array<Integer>}>)

    icons paths of icons



28
29
30
31
32
# File 'lib/app_info/ipa.rb', line 28

def icons(uncrush: true)
  @icons ||= icons_path.each_with_object([]) do |file, obj|
    obj << (file, uncrush: uncrush)
  end
end

#icons_pathArray<String>

Returns:

  • (Array<String>)


94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/app_info/ipa.rb', line 94

def icons_path
  @icons_path ||= lambda {
    icon_keys.each_with_object([]) do |name, icons|
      filenames = info.try(:[], name)
                      .try(:[], 'CFBundlePrimaryIcon')
                      .try(:[], 'CFBundleIconFiles')

      next if filenames.nil? || filenames.empty?

      filenames.each do |filename|
        Dir.glob(::File.join(app_path, "#{filename}*")).find_all.each do |file|
          icons << file
        end
      end
    end
  }.call
end

#info_pathString

Returns:

  • (String)


84
85
86
# File 'lib/app_info/ipa.rb', line 84

def info_path
  @info_path ||= ::File.join(app_path, 'Info.plist')
end

#metadataCFPropertyList

Returns:

  • (CFPropertyList)


62
63
64
65
66
# File 'lib/app_info/ipa.rb', line 62

def 
  return unless metadata?

  @metadata ||= CFPropertyList.native_types(CFPropertyList::List.new(file: ).value)
end

#metadata?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/app_info/ipa.rb', line 69

def metadata?
  ::File.exist?()
end

#metadata_pathString

Returns:

  • (String)


74
75
76
# File 'lib/app_info/ipa.rb', line 74

def 
  @metadata_path ||= ::File.join(contents, 'iTunesMetadata.plist')
end

#mobileprovision_pathString

Returns:

  • (String)


52
53
54
55
56
57
58
59
# File 'lib/app_info/ipa.rb', line 52

def mobileprovision_path
  @mobileprovision_path ||= ::File.join(@file, DEFAULT_MOBILEPROVISION_FILE)
  unless ::File.exist?(@mobileprovision_path)
    @mobileprovision_path = ::File.join(app_path, DEFAULT_MOBILEPROVISION_FILE)
  end

  @mobileprovision_path
end

#pluginsArray<Plugin>

Returns:



40
41
42
# File 'lib/app_info/ipa.rb', line 40

def plugins
  @plugins ||= Plugin.parse(app_path)
end

#stored?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/app_info/ipa.rb', line 35

def stored?
  !!metadata?
end