Sha256: 9c88b650199cf3208122b1b58cb28e02c86950ddf3fd8c2c1995ad9a8885f9f9

Contents?: true

Size: 1.43 KB

Versions: 42

Compression:

Stored size: 1.43 KB

Contents

module Deliver
  class IpaFileAnalyser

    # Fetches the app identifier (e.g. com.facebook.Facebook) from the given ipa file.
    def self.fetch_app_identifier(path)
      plist = IpaFileAnalyser.fetch_info_plist_file(path)
      return plist['CFBundleIdentifier'] if plist
      return nil
    end

    # Fetches the app version from the given ipa file.
    def self.fetch_app_version(path)
      plist = IpaFileAnalyser.fetch_info_plist_file(path)
      return plist['CFBundleShortVersionString'] if plist
      return nil
    end

    def self.fetch_info_plist_file(path)
      Zip::File.open(path) do |zipfile|
        zipfile.each do |file|
          if file.name.include?'.plist' and not ['.bundle', '.framework'].any? { |a| file.name.include?a }
            # We can not be completely sure, that's the correct plist file, so we have to try
            begin
              # The XML file has to be properly unpacked first
              tmp_path = "/tmp/deploytmp.plist"
              File.write(tmp_path, zipfile.read(file))
              system("plutil -convert xml1 #{tmp_path}")
              result = Plist::parse_xml(tmp_path)
              File.delete(tmp_path)

              if result['CFBundleIdentifier'] or result['CFBundleVersion']
                return result
              end
            rescue
              # We don't really care, look for another XML file
            end
          end
        end
      end

      nil
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
deliver-0.13.5 lib/deliver/ipa_file_analyser.rb
deliver-0.13.4 lib/deliver/ipa_file_analyser.rb
deliver-0.13.3 lib/deliver/ipa_file_analyser.rb
deliver-0.13.2 lib/deliver/ipa_file_analyser.rb
deliver-0.13.1 lib/deliver/ipa_file_analyser.rb
deliver-0.13.0 lib/deliver/ipa_file_analyser.rb
deliver-0.12.1 lib/deliver/ipa_file_analyser.rb
deliver-0.12.0 lib/deliver/ipa_file_analyser.rb
deliver-0.11.5 lib/deliver/ipa_file_analyser.rb
deliver-0.11.4 lib/deliver/ipa_file_analyser.rb
deliver-0.11.3 lib/deliver/ipa_file_analyser.rb
deliver-0.11.2 lib/deliver/ipa_file_analyser.rb
deliver-0.11.1 lib/deliver/ipa_file_analyser.rb
deliver-0.11.1.beta lib/deliver/ipa_file_analyser.rb
deliver-0.11.0 lib/deliver/ipa_file_analyser.rb
deliver-0.10.0 lib/deliver/ipa_file_analyser.rb
deliver-0.9.4 lib/deliver/ipa_file_analyser.rb
deliver-0.9.3 lib/deliver/ipa_file_analyser.rb
deliver-0.9.2 lib/deliver/ipa_file_analyser.rb
deliver-0.9.1 lib/deliver/ipa_file_analyser.rb