Sha256: cc89a5523b8dc4506eebfce353f9060cb4f5b012d42e7ee943124a88dede33cc

Contents?: true

Size: 1023 Bytes

Versions: 3

Compression:

Stored size: 1023 Bytes

Contents

require 'cfpropertylist'
require 'uri'

module BlastOff
  class Template
    def initialize(ipa_file)
      @ipa = ipa_file
    end

    def manifest_plist(ipa_file_url)
      {
        items: [
          assets: [
            {
              kind: 'software-package',
              url: ipa_file_url
            }
          ],
          metadata: {
            'bundle-identifier' => @ipa.bundle_identifier,
            'bundle-version' => @ipa.version,
            kind: 'software',
            title: @ipa.name
          }
        ]
      }.to_plist(plist_format: CFPropertyList::List::FORMAT_XML)
    end

    def html(manifest_plist_url)
      opts = OpenStruct.new({
        ipa: @ipa,
        install_url: URI.escape(
          "itms-services://?action=download-manifest&url=#{manifest_plist_url}"
        )
      })
      template_file = File.join(File.dirname(File.expand_path(__FILE__)), 'template/index.html.erb')

      ::ERB.new(File.read(template_file)).result(opts.instance_eval {binding})
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blast_off-0.5.0 lib/blast_off/template.rb
blast_off-0.4.0 lib/blast_off/template.rb
blast_off-0.3.0 lib/blast_off/template.rb