Class: AppInfo::InfoPlist

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

Overview

iOS Info.plist parser

Constant Summary collapse

ICON_KEYS =

Icon Key

{
  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?

Returns:

  • (String, nil)


143
144
145
# File 'lib/app_info/info_plist.rb', line 143

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

#build_versionString?

Returns:

  • (String, nil)


56
57
58
# File 'lib/app_info/info_plist.rb', line 56

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

#bundle_nameString?

Returns:

  • (String, nil)


82
83
84
# File 'lib/app_info/info_plist.rb', line 82

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

#deviceSymbol

Returns Device.

Returns:



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_familyArray<String>

Returns:

  • (Array<String>)


129
130
131
# File 'lib/app_info/info_plist.rb', line 129

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

#display_nameString?

Returns:

  • (String, nil)


77
78
79
# File 'lib/app_info/info_plist.rb', line 77

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

#iconsArray<String>

Returns:

  • (Array<String>)


104
105
106
# File 'lib/app_info/info_plist.rb', line 104

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

#identifierString? Also known as: bundle_id

Returns:

  • (String, nil)


66
67
68
# File 'lib/app_info/info_plist.rb', line 66

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

#ipad?Boolean

Returns:

  • (Boolean)


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

def ipad?
  device == Device::IPAD
end

#iphone?Boolean

Returns:

  • (Boolean)


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

def iphone?
  device == Device::IPHONE
end

#macos?Boolean

Returns:

  • (Boolean)


124
125
126
# File 'lib/app_info/info_plist.rb', line 124

def macos?
  device == Device::MACOS
end

#manufacturerSymbol

Returns Manufacturer.

Returns:



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

def manufacturer
  Manufacturer::APPLE
end

#min_os_versionString?

Returns:

  • (String, nil)


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_versionString?

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

Returns:

  • (String, nil)


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

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

#min_system_versionString?

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

Returns:

  • (String, nil)


99
100
101
# File 'lib/app_info/info_plist.rb', line 99

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

#nameString?

Returns:

  • (String, nil)


72
73
74
# File 'lib/app_info/info_plist.rb', line 72

def name
  display_name || bundle_name
end

#platformSymbol

Returns Platform.

Returns:



26
27
28
29
30
31
32
33
# File 'lib/app_info/info_plist.rb', line 26

def platform
  case device
  when Device::MACOS
    Platform::MACOS
  when Device::IPHONE, Device::IPAD, Device::UNIVERSAL
    Platform::IOS
  end
end

#release_typeString

Returns:

  • (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_versionString?

Returns:

  • (String, nil)


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

Returns:

  • (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_hObject

See Also:

  • CFPropertyList#to_h


149
# File 'lib/app_info/info_plist.rb', line 149

def_delegators :info, :to_h

#universal?Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/app_info/info_plist.rb', line 119

def universal?
  device == Device::UNIVERSAL
end

#versionString?

Returns:

  • (String, nil)


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

def version
  release_version || build_version
end