Class: Flappy::IpaInfo::App

Inherits:
Object show all
Defined in:
lib/flappy/util/ipa_info.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, is_stored = false) ⇒ App

Returns a new instance of App.



68
69
70
71
# File 'lib/flappy/util/ipa_info.rb', line 68

def initialize(path, is_stored = false)
  @path      = path       # app的路径
  @is_stored = is_stored
end

Instance Method Details

#basic_infoObject



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/flappy/util/ipa_info.rb', line 81

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



140
141
142
# File 'lib/flappy/util/ipa_info.rb', line 140

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

#display_nameObject



108
109
110
# File 'lib/flappy/util/ipa_info.rb', line 108

def display_name
  info['CFBundleDisplayName']
end

#distribution_nameObject



148
149
150
# File 'lib/flappy/util/ipa_info.rb', line 148

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

#full_info(options) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/flappy/util/ipa_info.rb', line 73

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

  basic_info
end

#get_image_path(name) ⇒ Object



190
191
192
193
194
# File 'lib/flappy/util/ipa_info.rb', line 190

def get_image_path(name)
  path = File.join(@path, "#{name}.png")
  return nil unless File.exist?(path)
  path
end

#has_mobileprovision?Boolean

Returns:

  • (Boolean)


124
125
126
# File 'lib/flappy/util/ipa_info.rb', line 124

def has_mobileprovision?
  File.file? mobileprovision_path
end

#hide_developer_certificatesObject



144
145
146
# File 'lib/flappy/util/ipa_info.rb', line 144

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

#iconsObject



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/flappy/util/ipa_info.rb', line 166

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

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

#identifierObject



100
101
102
# File 'lib/flappy/util/ipa_info.rb', line 100

def identifier
  info['CFBundleIdentifier']
end

#infoObject



95
96
97
98
# File 'lib/flappy/util/ipa_info.rb', line 95

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

#mobileprovisionObject



128
129
130
131
132
133
134
135
136
137
138
# File 'lib/flappy/util/ipa_info.rb', line 128

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



120
121
122
# File 'lib/flappy/util/ipa_info.rb', line 120

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

#nameObject



104
105
106
# File 'lib/flappy/util/ipa_info.rb', line 104

def name
  info['CFBundleName']
end

#release_typeObject



152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/flappy/util/ipa_info.rb', line 152

def release_type
  if @is_stored
    'Release'
  else
    if has_mobileprovision?
      if devices
        'AdHoc'
      else
        'InHouse'
      end
    end
  end
end

#short_versionObject



116
117
118
# File 'lib/flappy/util/ipa_info.rb', line 116

def short_version
  info['CFBundleShortVersionString']
end

#versionObject



112
113
114
# File 'lib/flappy/util/ipa_info.rb', line 112

def version
  info['CFBundleVersion']
end