lib/lagunitas.ext.rb in fir-cli-0.0.4 vs lib/lagunitas.ext.rb in fir-cli-0.0.5

- old
+ new

@@ -1,26 +1,55 @@ require 'cfpropertylist' require 'lagunitas' module Lagunitas class App - def name - @info['CFBundleName'] - end - def mobileprovision - @mobileprovision = CFPropertyList.native_types CFPropertyList::List.new(:data => `security cms -D -i #{File.join @path, 'embedded.mobileprovision'}`).value - end - def devices - mobileprovision['ProvisionedDevices'] - end + def initialize(path, root) + @path = path + @root = root + end + def name + @info['CFBundleName'] + end + def mobileprovision + return if !mobileprovision? + @mobileprovision ||= CFPropertyList.native_types CFPropertyList::List.new(:data => `security cms -D -i #{File.join @path, 'embedded.mobileprovision'}`).value + end + def mobileprovision? + return true if @mobileprovision + File.exists? File.join @path, 'embedded.mobileprovision' + end + def devices + mobileprovision['ProvisionedDevices'] if mobileprovision + end def distribution_name - mobileprovision['DeveloperCertificates'] + mobileprovision['DeveloperCertificates'] if mobileprovision end - def release_type - if devices == nil - 'inhouse' - else - 'adhoc' - end - end - + def metadata + return if !metadata? + @metadata ||= CFPropertyList.native_types(CFPropertyList::List.new(file: File.join(@root, 'iTunesMetadata.plist')).value) + end + def metadata? + return true if @metadata + File.exists? File.join @root, 'iTunesMetadata.plist' + end + def release_type + @release_type ||= begin + if mobileprovision? + if devices + 'adhoc' + else + 'inhouse' + end + elsif metadata? + 'store' + else + 'adhoc' + end + end + end + end + class IPA + def root_path + contents + end end end