Class: AppInfo::InfoPlist

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

Overview

iOS Info.plist parser

Instance Method Summary collapse

Constructor Details

#initialize(app_path) ⇒ InfoPlist

Returns a new instance of InfoPlist.



9
10
11
# File 'lib/app_info/ipa/info_plist.rb', line 9

def initialize(app_path)
  @app_path = app_path
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



110
111
112
113
114
# File 'lib/app_info/ipa/info_plist.rb', line 110

def method_missing(method_name, *args, &block)
  info.try(:[], Util.format_key(method_name)) ||
    info.send(method_name) ||
    super
end

Instance Method Details

#[](key) ⇒ Object



106
107
108
# File 'lib/app_info/ipa/info_plist.rb', line 106

def [](key)
  info.try(:[], key.to_s)
end

#build_versionObject



13
14
15
# File 'lib/app_info/ipa/info_plist.rb', line 13

def build_version
  info.try(:[], 'CFBundleVersion')
end

#bundle_nameObject



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

def bundle_name
  info.try(:[], 'CFBundleName')
end

#device_typeObject



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/app_info/ipa/info_plist.rb', line 72

def device_type
  device_family = info.try(:[], 'UIDeviceFamily')
  if device_family.length == 1
    case device_family
    when [1]
      'iPhone'
    when [2]
      'iPad'
    end
  elsif device_family.length == 2 && device_family == [1, 2]
    'Universal'
  end
end

#display_nameObject



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

def display_name
  info.try(:[], 'CFBundleDisplayName')
end

#iconsObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/app_info/ipa/info_plist.rb', line 45

def icons
  return @icons if @icons

  @icons = []
  icons_root_path.each do |name|
    icon_array = info.try(:[], name)
                     .try(:[], 'CFBundlePrimaryIcon')
                     .try(:[], 'CFBundleIconFiles')

    next if icon_array.nil? || icon_array.empty?

    icon_array.each do |items|
      Dir.glob(File.join(@app_path, "#{items}*")).find_all.each do |file|
        dict = {
          name: File.basename(file),
          file: file,
          dimensions: Pngdefry.dimensions(file)
        }

        @icons.push(dict)
      end
    end
  end

  @icons
end

#identifierObject Also known as: bundle_id



21
22
23
# File 'lib/app_info/ipa/info_plist.rb', line 21

def identifier
  info.try(:[], 'CFBundleIdentifier')
end

#ipad?Boolean

Returns:

  • (Boolean)


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

def ipad?
  device_type == 'iPad'
end

#iphone?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/app_info/ipa/info_plist.rb', line 86

def iphone?
  device_type == 'iPhone'
end

#min_sdk_versionObject

Extract the Minimum OS Version from the Info.plist



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

def min_sdk_version
  info.try(:[], 'MinimumOSVersion')
end

#nameObject



26
27
28
# File 'lib/app_info/ipa/info_plist.rb', line 26

def name
  display_name || bundle_name
end

#release_typeObject



98
99
100
101
102
103
104
# File 'lib/app_info/ipa/info_plist.rb', line 98

def release_type
  if stored?
    'Store'
  else
    build_type
  end
end

#release_versionObject



17
18
19
# File 'lib/app_info/ipa/info_plist.rb', line 17

def release_version
  info.try(:[], 'CFBundleShortVersionString')
end

#respond_to_missing?(method_name, *args) ⇒ Boolean

Returns:

  • (Boolean)


116
117
118
119
120
# File 'lib/app_info/ipa/info_plist.rb', line 116

def respond_to_missing?(method_name, *args)
  info.key?(Util.format_key(method_name)) ||
    info.respond_to?(method_name) ||
    super
end

#universal?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/app_info/ipa/info_plist.rb', line 94

def universal?
  device_type == 'Universal'
end