Class: FIR::Parser::Ipa

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

Defined Under Namespace

Classes: App

Instance Method Summary collapse

Methods included from Common

#generate_tmp_icon

Constructor Details

#initialize(path) ⇒ Ipa

Returns a new instance of Ipa.



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

def initialize(path)
  @path = path
end

Instance Method Details

#appObject



14
15
16
# File 'lib/fir/util/parser/ipa.rb', line 14

def app
  @app ||= App.new(app_path, is_stored)
end

#app_pathObject



18
19
20
# File 'lib/fir/util/parser/ipa.rb', line 18

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

#cleanupObject



22
23
24
25
26
# File 'lib/fir/util/parser/ipa.rb', line 22

def cleanup
  return unless @contents
  FileUtils.rm_rf(@contents)
  @contents = nil
end

#contentsObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fir/util/parser/ipa.rb', line 45

def contents
  return if @contents
  @contents = "#{Dir.tmpdir}/ipa_files-#{Time.now.to_i}"

  Zip::File.open(@path) do |zip_file|
    zip_file.each do |f|
      f_path = File.join(@contents, f.name)
      FileUtils.mkdir_p(File.dirname(f_path))
      zip_file.extract(f, f_path) unless File.exist?(f_path)
    end
  end

  @contents
end

#has_metadata?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/fir/util/parser/ipa.rb', line 33

def has_metadata?
  File.file?()
end

#is_storedObject



41
42
43
# File 'lib/fir/util/parser/ipa.rb', line 41

def is_stored
  has_metadata? ? true : false
end

#metadataObject



28
29
30
31
# File 'lib/fir/util/parser/ipa.rb', line 28

def 
  return unless has_metadata?
  @metadata ||= CFPropertyList.native_types(CFPropertyList::List.new(file: ).value)
end

#metadata_pathObject



37
38
39
# File 'lib/fir/util/parser/ipa.rb', line 37

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