Class: AppInfo::Parser::InfoPlist
- Defined in:
- lib/app_info/parser/ipa/info_plist.rb
Overview
iOS Info.plist parser
Instance Method Summary collapse
- #build_version ⇒ Object
- #bundle_name ⇒ Object
- #device_type ⇒ Object
- #display_name ⇒ Object
- #icons ⇒ Object
- #identifier ⇒ Object (also: #bundle_id)
- #info ⇒ Object
- #info_path ⇒ Object
-
#initialize(app_path) ⇒ InfoPlist
constructor
A new instance of InfoPlist.
- #ipad? ⇒ Boolean
- #iphone? ⇒ Boolean
- #name ⇒ Object
- #release_type ⇒ Object
- #release_version ⇒ Object
- #universal? ⇒ Boolean
Constructor Details
#initialize(app_path) ⇒ InfoPlist
Returns a new instance of InfoPlist.
7 8 9 |
# File 'lib/app_info/parser/ipa/info_plist.rb', line 7 def initialize(app_path) @app_path = app_path end |
Instance Method Details
#build_version ⇒ Object
11 12 13 |
# File 'lib/app_info/parser/ipa/info_plist.rb', line 11 def build_version info.try(:[], 'CFBundleVersion') end |
#bundle_name ⇒ Object
31 32 33 |
# File 'lib/app_info/parser/ipa/info_plist.rb', line 31 def bundle_name info.try(:[], 'CFBundleName') end |
#device_type ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/app_info/parser/ipa/info_plist.rb', line 62 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_name ⇒ Object
27 28 29 |
# File 'lib/app_info/parser/ipa/info_plist.rb', line 27 def display_name info.try(:[], 'CFBundleDisplayName') end |
#icons ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/app_info/parser/ipa/info_plist.rb', line 35 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.count == 0 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 |
#identifier ⇒ Object Also known as: bundle_id
19 20 21 |
# File 'lib/app_info/parser/ipa/info_plist.rb', line 19 def identifier info.try(:[], 'CFBundleIdentifier') end |
#info ⇒ Object
96 97 98 |
# File 'lib/app_info/parser/ipa/info_plist.rb', line 96 def info @info ||= CFPropertyList.native_types(CFPropertyList::List.new(file: info_path).value) end |
#info_path ⇒ Object
100 101 102 |
# File 'lib/app_info/parser/ipa/info_plist.rb', line 100 def info_path File.join(@app_path, 'Info.plist') end |
#ipad? ⇒ Boolean
80 81 82 |
# File 'lib/app_info/parser/ipa/info_plist.rb', line 80 def ipad? device_type == 'iPad' end |
#iphone? ⇒ Boolean
76 77 78 |
# File 'lib/app_info/parser/ipa/info_plist.rb', line 76 def iphone? device_type == 'iPhone' end |
#name ⇒ Object
23 24 25 |
# File 'lib/app_info/parser/ipa/info_plist.rb', line 23 def name display_name || bundle_name end |
#release_type ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/app_info/parser/ipa/info_plist.rb', line 88 def release_type if stored? 'Store' else build_type end end |
#release_version ⇒ Object
15 16 17 |
# File 'lib/app_info/parser/ipa/info_plist.rb', line 15 def release_version info.try(:[], 'CFBundleShortVersionString') end |
#universal? ⇒ Boolean
84 85 86 |
# File 'lib/app_info/parser/ipa/info_plist.rb', line 84 def universal? device_type == 'Universal' end |