class Lagunitas::App
Representation of an app inside an IPA
Public Class Methods
new(path)
click to toggle source
# File lib/lagunitas/app.rb, line 9 def initialize(path) @path = path end
Public Instance Methods
bundle_name()
click to toggle source
# File lib/lagunitas/app.rb, line 21 def bundle_name info['CFBundleName'] end
display_name()
click to toggle source
# File lib/lagunitas/app.rb, line 25 def display_name info['CFBundleDisplayName'] end
icon(size)
click to toggle source
# File lib/lagunitas/app.rb, line 37 def icon(size) icons.each do |icon| return icon[:path] if icon[:width] >= size end nil end
icons()
click to toggle source
# File lib/lagunitas/app.rb, line 44 def icons @icons ||= begin icons = [] info['CFBundleIcons']['CFBundlePrimaryIcon']['CFBundleIconFiles'].each do |name| icons << get_image(name) icons << get_image("#{name}@2x") end icons.delete_if(&:!) rescue NoMethodError # fix a ipa without icons [] end end
identifier()
click to toggle source
# File lib/lagunitas/app.rb, line 17 def identifier info['CFBundleIdentifier'] end
info()
click to toggle source
# File lib/lagunitas/app.rb, line 13 def info @info ||= CFPropertyList.native_types(CFPropertyList::List.new(file: File.join(@path, 'Info.plist')).value) end
short_version()
click to toggle source
# File lib/lagunitas/app.rb, line 33 def short_version info['CFBundleShortVersionString'] end
version()
click to toggle source
# File lib/lagunitas/app.rb, line 29 def version info['CFBundleVersion'] end
Private Instance Methods
get_image(name)
click to toggle source
# File lib/lagunitas/app.rb, line 59 def get_image(name) path = File.join(@path, "#{name}.png") return nil unless File.exist?(path) dimensions = Pngdefry.dimensions(path) { path: path, width: dimensions.first, height: dimensions.last } rescue Errno::ENOENT nil end