Class: AppInfo::InfoPlist
- Inherits:
-
File
- Object
- File
- AppInfo::InfoPlist
show all
- Extended by:
- Forwardable
- Defined in:
- lib/app_info/info_plist.rb
Overview
Constant Summary
collapse
- ICON_KEYS =
{
Device::IPHONE => ['CFBundleIcons'],
Device::IPAD => ['CFBundleIcons~ipad'],
Device::UNIVERSAL => ['CFBundleIcons', 'CFBundleIcons~ipad'],
Device::MACOS => %w[CFBundleIconFile CFBundleIconName]
}.freeze
Instance Attribute Summary
Attributes inherited from File
#file, #logger
Instance Method Summary
collapse
Methods inherited from File
#format, #initialize, #not_implemented_error!, #size
Constructor Details
This class inherits a constructor from AppInfo::File
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
151
152
153
154
155
|
# File 'lib/app_info/info_plist.rb', line 151
def method_missing(method_name, *args, &block)
info.try(:[], method_name.to_s.ai_camelcase) ||
info.send(method_name) ||
super
end
|
Instance Method Details
#[](key) ⇒ String?
143
144
145
|
# File 'lib/app_info/info_plist.rb', line 143
def [](key)
info.try(:[], key.to_s)
end
|
#build_version ⇒ String?
56
57
58
|
# File 'lib/app_info/info_plist.rb', line 56
def build_version
info.try(:[], 'CFBundleVersion')
end
|
#bundle_name ⇒ String?
82
83
84
|
# File 'lib/app_info/info_plist.rb', line 82
def bundle_name
info.try(:[], 'CFBundleName')
end
|
#device ⇒ Symbol
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/app_info/info_plist.rb', line 36
def device
if device_family == [1]
Device::IPHONE
elsif device_family == [2]
Device::IPAD
elsif device_family == [1, 2]
Device::UNIVERSAL
elsif !info.try(:[], 'DTSDKName').nil? || !info.try(:[], 'DTManufacturerName').nil?
Device::MACOS
else
raise NotImplementedError, "Unkonwn device: #{device_family}"
end
end
|
#device_family ⇒ Array<String>
129
130
131
|
# File 'lib/app_info/info_plist.rb', line 129
def device_family
info.try(:[], 'UIDeviceFamily') || []
end
|
#display_name ⇒ String?
77
78
79
|
# File 'lib/app_info/info_plist.rb', line 77
def display_name
info.try(:[], 'CFBundleDisplayName')
end
|
#icons ⇒ Array<String>
104
105
106
|
# File 'lib/app_info/info_plist.rb', line 104
def icons
@icons ||= ICON_KEYS[device]
end
|
#identifier ⇒ String?
Also known as:
bundle_id
66
67
68
|
# File 'lib/app_info/info_plist.rb', line 66
def identifier
info.try(:[], 'CFBundleIdentifier')
end
|
#ipad? ⇒ Boolean
114
115
116
|
# File 'lib/app_info/info_plist.rb', line 114
def ipad?
device == Device::IPAD
end
|
#iphone? ⇒ Boolean
109
110
111
|
# File 'lib/app_info/info_plist.rb', line 109
def iphone?
device == Device::IPHONE
end
|
#macos? ⇒ Boolean
124
125
126
|
# File 'lib/app_info/info_plist.rb', line 124
def macos?
device == Device::MACOS
end
|
#manufacturer ⇒ Symbol
21
22
23
|
# File 'lib/app_info/info_plist.rb', line 21
def manufacturer
Manufacturer::APPLE
end
|
#min_os_version ⇒ String?
87
88
89
|
# File 'lib/app_info/info_plist.rb', line 87
def min_os_version
min_sdk_version || min_system_version
end
|
#min_sdk_version ⇒ String?
Extract the Minimum OS Version from the Info.plist (iOS Only)
93
94
95
|
# File 'lib/app_info/info_plist.rb', line 93
def min_sdk_version
info.try(:[], 'MinimumOSVersion')
end
|
#min_system_version ⇒ String?
Extract the Minimum OS Version from the Info.plist (macOS Only)
99
100
101
|
# File 'lib/app_info/info_plist.rb', line 99
def min_system_version
info.try(:[], 'LSMinimumSystemVersion')
end
|
#name ⇒ String?
72
73
74
|
# File 'lib/app_info/info_plist.rb', line 72
def name
display_name || bundle_name
end
|
#release_type ⇒ String
134
135
136
137
138
139
140
|
# File 'lib/app_info/info_plist.rb', line 134
def release_type
if stored?
'Store'
else
build_type
end
end
|
#release_version ⇒ String?
61
62
63
|
# File 'lib/app_info/info_plist.rb', line 61
def release_version
info.try(:[], 'CFBundleShortVersionString')
end
|
#respond_to_missing?(method_name, *args) ⇒ Boolean
157
158
159
160
161
|
# File 'lib/app_info/info_plist.rb', line 157
def respond_to_missing?(method_name, *args)
info.key?(method_name.to_s.ai_camelcase) ||
info.respond_to?(method_name) ||
super
end
|
#to_h ⇒ Object
149
|
# File 'lib/app_info/info_plist.rb', line 149
def_delegators :info, :to_h
|
#universal? ⇒ Boolean
119
120
121
|
# File 'lib/app_info/info_plist.rb', line 119
def universal?
device == Device::UNIVERSAL
end
|
#version ⇒ String?
51
52
53
|
# File 'lib/app_info/info_plist.rb', line 51
def version
release_version || build_version
end
|