Sha256: b638a30c6071340ff004072965fa2fe19000d79b308d0131bec2c89232663958

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

module EPUB
  module Publication
    class Package
      CONTENT_MODELS = [:metadata, :manifest, :spine, :guide, :bindings]
      RESERVED_VOCABULARY_PREFIXES = {
        ''        => 'http://idpf.org/epub/vocab/package/#',
        'dcterms' => 'http://purl.org/dc/terms/',
        'marc'    => 'http://id.loc.gov/vocabulary/',
        'media'   => 'http://www.idpf.org/epub/vocab/overlays/#',
        'onix'    => 'http://www.editeur.org/ONIX/book/codelists/current.html#',
        'xsd'     => 'http://www.w3.org/2001/XMLSchema#'
      }


      class << self
        def define_content_model(model_name)
          define_method "#{model_name}=" do |model|
            current_model = __send__(model_name)
            current_model.package = nil if current_model
            model.package = self
            instance_variable_set "@#{model_name}", model
          end
        end
      end

      attr_accessor :book,
                    :version, :prefix, :xml_lang, :dir, :id
      attr_reader *CONTENT_MODELS
      alias lang  xml_lang
      alias lang= xml_lang=

      CONTENT_MODELS.each do |model|
        define_content_model model
      end

      def unique_identifier
        @metadata.unique_identifier
      end
    end
  end
end

EPUB::Publication::Package::CONTENT_MODELS.each do |f|
  require_relative "package/#{f}"
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
epub-parser-0.1.3 lib/epub/publication/package.rb
epub-parser-0.1.2 lib/epub/publication/package.rb
epub-parser-0.1.1 lib/epub/publication/package.rb