Class: FIR::Parser::Ipa::App

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

Instance Method Summary collapse

Methods included from Common

#generate_tmp_icon

Constructor Details

#initialize(path, is_stored = false) ⇒ App

Returns a new instance of App.



63
64
65
66
# File 'lib/fir/util/parser/ipa.rb', line 63

def initialize(path, is_stored = false)
  @path      = path
  @is_stored = is_stored
end

Instance Method Details

#basic_infoObject



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/fir/util/parser/ipa.rb', line 76

def basic_info
  @basic_info ||= {
    type:              'ios',
    identifier:        identifier,
    name:              name,
    display_name:      display_name,
    build:             version.to_s,
    version:           short_version.to_s,
    devices:           devices,
    release_type:      release_type,
    distribution_name: distribution_name
  }
end

#devicesObject



156
157
158
# File 'lib/fir/util/parser/ipa.rb', line 156

def devices
  mobileprovision['ProvisionedDevices'] if has_mobileprovision?
end

#display_nameObject



103
104
105
# File 'lib/fir/util/parser/ipa.rb', line 103

def display_name
  info['CFBundleDisplayName']
end

#distribution_nameObject



160
161
162
# File 'lib/fir/util/parser/ipa.rb', line 160

def distribution_name
  "#{mobileprovision['Name']} - #{mobileprovision['TeamName']}" if has_mobileprovision?
end

#full_info(options) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/fir/util/parser/ipa.rb', line 68

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

  basic_info
end

#has_mobileprovision?Boolean

Returns:

  • (Boolean)


144
145
146
# File 'lib/fir/util/parser/ipa.rb', line 144

def has_mobileprovision?
  File.file? mobileprovision_path
end

#hide_developer_certificatesObject



152
153
154
# File 'lib/fir/util/parser/ipa.rb', line 152

def hide_developer_certificates
  mobileprovision.delete('DeveloperCertificates') if has_mobileprovision?
end

#iconsObject



119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/fir/util/parser/ipa.rb', line 119

def icons
  @icons ||= begin
    icons = []
    info['CFBundleIcons']['CFBundlePrimaryIcon']['CFBundleIconFiles'].each do |name|
      icons << get_image(name)
      icons << get_image("#{name}@2x")
    end
    icons.delete_if &:!
  rescue NoMethodError
    []
  end
end

#identifierObject



99
100
101
# File 'lib/fir/util/parser/ipa.rb', line 99

def identifier
  info['CFBundleIdentifier']
end

#infoObject



90
91
92
93
# File 'lib/fir/util/parser/ipa.rb', line 90

def info
  @info ||= CFPropertyList.native_types(
    CFPropertyList::List.new(file: File.join(@path, 'Info.plist')).value)
end

#mobileprovisionObject



132
133
134
135
136
137
138
139
140
141
142
# File 'lib/fir/util/parser/ipa.rb', line 132

def mobileprovision
  return unless has_mobileprovision?
  return @mobileprovision if @mobileprovision

  cmd = "security cms -D -i \"#{mobileprovision_path}\""
  begin
    @mobileprovision = CFPropertyList.native_types(CFPropertyList::List.new(data: `#{cmd}`).value)
  rescue CFFormatError
    @mobileprovision = {}
  end
end

#mobileprovision_pathObject



148
149
150
# File 'lib/fir/util/parser/ipa.rb', line 148

def mobileprovision_path
  @mobileprovision_path ||= File.join(@path, 'embedded.mobileprovision')
end

#nameObject



95
96
97
# File 'lib/fir/util/parser/ipa.rb', line 95

def name
  info['CFBundleName']
end

#release_typeObject



164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/fir/util/parser/ipa.rb', line 164

def release_type
  if @is_stored
    'store'
  else
    if has_mobileprovision?
      if devices
        'adhoc'
      else
        'inhouse'
      end
    end
  end
end

#short_versionObject



111
112
113
# File 'lib/fir/util/parser/ipa.rb', line 111

def short_version
  info['CFBundleShortVersionString']
end

#tmp_iconsObject



115
116
117
# File 'lib/fir/util/parser/ipa.rb', line 115

def tmp_icons
  icons.map { |data| generate_tmp_icon(data, :ipa) }
end

#versionObject



107
108
109
# File 'lib/fir/util/parser/ipa.rb', line 107

def version
  info['CFBundleVersion']
end