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::Apple::IPHONE => ['CFBundleIcons'],
  Device::Apple::IPAD => ['CFBundleIcons~ipad'],
  Device::Apple::UNIVERSAL => ['CFBundleIcons', 'CFBundleIcons~ipad'],
  Device::Apple::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 
  
  
  
  
    | 
193
194
195
196
197 | # File 'lib/app_info/info_plist.rb', line 193
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? 
  
  
  
  
    | 
185
186
187 | # File 'lib/app_info/info_plist.rb', line 185
def [](key)
  info.try(:[], key.to_s)
end | 
 
    
      
  
  
    #appletv?  ⇒ Boolean 
  
  
  
  
    | 
135
136
137 | # File 'lib/app_info/info_plist.rb', line 135
def appletv?
  device == Device::Apple::APPLETV
end | 
 
    
      
  
  
    #background_modes  ⇒ Array<String> 
  
  
  
  
    
Services provided by an app that require it to run in the background
   
 
  
    | 
180
181
182 | # File 'lib/app_info/info_plist.rb', line 180
def background_modes
  info.try(:[], 'UIBackgroundModes') || []
end | 
 
    
      
  
  
    #build_version  ⇒ String? 
  
  
  
  
    | 
62
63
64 | # File 'lib/app_info/info_plist.rb', line 62
def build_version
  info.try(:[], 'CFBundleVersion')
end | 
 
    
      
  
  
    #bundle_name  ⇒ String? 
  
  
  
  
    | 
88
89
90 | # File 'lib/app_info/info_plist.rb', line 88
def bundle_name
  info.try(:[], 'CFBundleName')
end | 
 
    
      
  
  
    #device  ⇒ Symbol 
  
  
  
  
    | 
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 | # File 'lib/app_info/info_plist.rb', line 38
def device
  if device_family == [1]
    Device::Apple::IPHONE
  elsif device_family == [2]
    Device::Apple::IPAD
  elsif device_family == [1, 2]
    Device::Apple::UNIVERSAL
  elsif device_family == [3]
    Device::Apple::APPLETV
  elsif device_family == [6]
    Device::Apple::APPMACOSLETV
  elsif !info.try(:[], 'DTSDKName').nil? || !info.try(:[], 'DTManufacturerName').nil?
    Device::Apple::MACOS
  else
    raise NotImplementedError, "Unkonwn device: #{device_family}"
  end
end | 
 
    
      
  
  
    #device_family  ⇒ Array<String> 
  
  
  
  
    | 
140
141
142 | # File 'lib/app_info/info_plist.rb', line 140
def device_family
  info.try(:[], 'UIDeviceFamily') || []
end | 
 
    
      
  
  
    #display_name  ⇒ String? 
  
  
  
  
    | 
83
84
85 | # File 'lib/app_info/info_plist.rb', line 83
def display_name
  info.try(:[], 'CFBundleDisplayName')
end | 
 
    
      
  
  
    #icons  ⇒ Array<String> 
  
  
  
  
    | 
110
111
112 | # File 'lib/app_info/info_plist.rb', line 110
def icons
  @icons ||= ICON_KEYS[device]
end | 
 
    
      
  
  
    #identifier  ⇒ String? 
  
  
    Also known as:
    bundle_id
    
  
  
  
    | 
72
73
74 | # File 'lib/app_info/info_plist.rb', line 72
def identifier
  info.try(:[], 'CFBundleIdentifier')
end | 
 
    
      
  
  
    #ipad?  ⇒ Boolean 
  
  
  
  
    | 
120
121
122 | # File 'lib/app_info/info_plist.rb', line 120
def ipad?
  device == Device::Apple::IPAD
end | 
 
    
      
  
  
    #iphone?  ⇒ Boolean 
  
  
  
  
    | 
115
116
117 | # File 'lib/app_info/info_plist.rb', line 115
def iphone?
  device == Device::Apple::IPHONE
end | 
 
    
      
  
  
    #macos?  ⇒ Boolean 
  
  
  
  
    | 
130
131
132 | # File 'lib/app_info/info_plist.rb', line 130
def macos?
  device == Device::Apple::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? 
  
  
  
  
    | 
93
94
95 | # File 'lib/app_info/info_plist.rb', line 93
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)
   
 
  
    | 
99
100
101 | # File 'lib/app_info/info_plist.rb', line 99
def min_sdk_version
  info.try(:[], 'MinimumOSVersion')
end | 
 
    
      
  
  
    #min_system_version  ⇒ String? 
  
  
  
  
    
Extract the Minimum OS Version from the Info.plist (macOS Only)
   
 
  
    | 
105
106
107 | # File 'lib/app_info/info_plist.rb', line 105
def min_system_version
  info.try(:[], 'LSMinimumSystemVersion')
end | 
 
    
      
  
  
    #name  ⇒ String? 
  
  
  
  
    | 
78
79
80 | # File 'lib/app_info/info_plist.rb', line 78
def name
  display_name || bundle_name
end | 
 
    
      
    
      
  
  
    #query_schemes  ⇒ Array<String> 
  
  
  
  
    
Specifies the URL schemes you want the app to be able to use
   
 
  
    | 
173
174
175 | # File 'lib/app_info/info_plist.rb', line 173
def query_schemes
  info.try(:[], 'LSApplicationQueriesSchemes') || []
end | 
 
    
      
  
  
    #release_type  ⇒ String 
  
  
  
  
    | 
145
146
147
148
149
150
151 | # File 'lib/app_info/info_plist.rb', line 145
def release_type
  if stored?
    'Store'
  else
    build_type
  end
end | 
 
    
      
  
  
    #release_version  ⇒ String? 
  
  
  
  
    | 
67
68
69 | # File 'lib/app_info/info_plist.rb', line 67
def release_version
  info.try(:[], 'CFBundleShortVersionString')
end | 
 
    
      
  
  
    #respond_to_missing?(method_name, *args)  ⇒ Boolean 
  
  
  
  
    | 
199
200
201
202
203 | # File 'lib/app_info/info_plist.rb', line 199
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 
  
  
  
  
    | 
191 | # File 'lib/app_info/info_plist.rb', line 191
def_delegators :info, :to_h | 
 
    
      
  
  
    #universal?  ⇒ Boolean 
  
  
  
  
    | 
125
126
127 | # File 'lib/app_info/info_plist.rb', line 125
def universal?
  device == Device::Apple::UNIVERSAL
end | 
 
    
      
  
  
    #url_schemes  ⇒ Array<String> 
  
  
  
  
    
A list of URL schemes (http, ftp, and so on) supported by the app.
   
 
  
    | 
156
157
158
159
160
161
162
163
164
165
166
167
168 | # File 'lib/app_info/info_plist.rb', line 156
def url_schemes
  url_types = info.try(:[], 'CFBundleURLTypes')
  return [] unless url_types
  url_types.each_with_object([]) do |url_type, obj|
    data = {
      role: url_type['CFBundleTypeRole'],
      name: url_type['CFBundleURLName'],
      schemes: url_type['CFBundleURLSchemes']
    }
    obj << data
  end
end | 
 
    
      
  
  
    #version  ⇒ String? 
  
  
  
  
    | 
57
58
59 | # File 'lib/app_info/info_plist.rb', line 57
def version
  release_version || build_version
end |