Sha256: 01646c28420976008fbca471f323454d566adc08517515bf4ee1bb3a9f89f9bf

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require "plist"

module Playgroundbook
  class ContentsManifestGenerator
    def initialize(ui = Cork::Board.new)
      @ui = ui
    end

    def generate(book_metadata)
      @ui.puts "Generating main manifest file."
      write_manifest_file(book_metadata)
      @ui.puts "Manifest file generated."
    end

    def write_manifest_file(book_metadata)
      File.open(ManifestFileName, "w") do |file|
        file.write(manifest_contents(book_metadata).to_plist)
      end
    end

    def manifest_contents(book_metadata)
      chapters = book_metadata["chapters"].map { |c| "#{c}.playgroundchapter" }
      manifest_contents = {
        "Name" => book_metadata["name"],
        "ContentIdentifier" => book_metadata["identifier"],
        "DeploymentTarget" => book_metadata["deployment_target"] || "ios10.0",
        "Chapters" => chapters,
        "Version" => "1.0",
        "ContentVersion" => "1.0"
      }
      manifest_contents["ImageReference"] = book_metadata["cover"] unless book_metadata["cover"].nil?
      manifest_contents
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
playgroundbook-0.4.0 lib/renderer/contents_manifest_generator.rb