Class: AppInfo::InfoPlist

Inherits:
Object show all
Extended by:
Forwardable
Defined in:
lib/app_info/info_plist.rb

Overview

iOS Info.plist parser

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ InfoPlist

Returns a new instance of InfoPlist.



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

def initialize(file)
  @file = file
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



114
115
116
117
118
# File 'lib/app_info/info_plist.rb', line 114

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



108
109
110
# File 'lib/app_info/info_plist.rb', line 108

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

#build_versionObject



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

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

#bundle_nameObject



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

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

#device_familyObject



96
97
98
# File 'lib/app_info/info_plist.rb', line 96

def device_family
  info.try(:[], 'UIDeviceFamily') || []
end

#device_typeObject



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/app_info/info_plist.rb', line 67

def device_type
  device_family = info.try(:[], 'UIDeviceFamily')
  if device_family == [1]
    AppInfo::Device::IPHONE
  elsif device_family == [2]
    AppInfo::Device::IPAD
  elsif device_family == [1, 2]
    AppInfo::Device::UNIVERSAL
  elsif !info.try(:[], 'DTSDKName').nil? || !info.try(:[], 'DTPlatformName').nil?
    AppInfo::Device::MACOS
  end
end

#display_nameObject



37
38
39
# File 'lib/app_info/info_plist.rb', line 37

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

#iconsObject



63
64
65
# File 'lib/app_info/info_plist.rb', line 63

def icons
  @icons ||= ICON_KEYS[device_type]
end

#identifierObject Also known as: bundle_id



28
29
30
# File 'lib/app_info/info_plist.rb', line 28

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

#ipad?Boolean

Returns:

  • (Boolean)


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

def ipad?
  device_type == Device::IPAD
end

#iphone?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/app_info/info_plist.rb', line 80

def iphone?
  device_type == Device::IPHONE
end

#macos?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/app_info/info_plist.rb', line 92

def macos?
  device_type == Device::MACOS
end

#min_os_versionObject



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

def min_os_version
  min_sdk_version || min_system_version
end

#min_sdk_versionObject

Extract the Minimum OS Version from the Info.plist (iOS Only)



52
53
54
# File 'lib/app_info/info_plist.rb', line 52

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

#min_system_versionObject

Extract the Minimum OS Version from the Info.plist (macOS Only)



59
60
61
# File 'lib/app_info/info_plist.rb', line 59

def min_system_version
  info.try(:[], 'LSMinimumSystemVersion')
end

#nameObject



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

def name
  display_name || bundle_name
end

#release_typeObject



100
101
102
103
104
105
106
# File 'lib/app_info/info_plist.rb', line 100

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

#release_versionObject



24
25
26
# File 'lib/app_info/info_plist.rb', line 24

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

#respond_to_missing?(method_name, *args) ⇒ Boolean

Returns:

  • (Boolean)


120
121
122
123
124
# File 'lib/app_info/info_plist.rb', line 120

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)


88
89
90
# File 'lib/app_info/info_plist.rb', line 88

def universal?
  device_type == Device::UNIVERSAL
end

#versionObject



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

def version
  release_version || build_version
end