Sha256: fe8caa596b66dd0f06dca2f5d7dac71818e647098ad167c6a914ed68ebb1ce4c

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

require 'nokogiri'

require 'caracal/renderers/xml_renderer'


module Caracal
  module Renderers
    class CoreRenderer < XmlRenderer
      
      #-------------------------------------------------------------
      # Public Methods
      #-------------------------------------------------------------
      
      # This method produces the xml required for the `docProps/core.xml` 
      # sub-document.
      #
      def to_xml
        builder = ::Nokogiri::XML::Builder.with(declaration_xml) do |xml|
          xml['cp'].coreProperties root_options do
            xml['dc'].title document.name
          end
        end
        builder.to_xml(save_options)
      end
      
      
      #-------------------------------------------------------------
      # Private Methods
      #------------------------------------------------------------- 
      private
      
      def root_options
        {
          'xmlns:cp'        => 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties',
          'xmlns:dc'        => 'http://purl.org/dc/elements/1.1/',
          'xmlns:dcterms'   => 'http://purl.org/dc/terms/',
          'xmlns:dcmitype'  => 'http://purl.org/dc/dcmitype/',
          'xmlns:xsi'       => 'http://www.w3.org/2001/XMLSchema-instance'
        }
      end
   
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
caracal-1.2.0 lib/caracal/renderers/core_renderer.rb
caracal-1.1.2 lib/caracal/renderers/core_renderer.rb
caracal-1.1.1 lib/caracal/renderers/core_renderer.rb
caracal-1.1.0 lib/caracal/renderers/core_renderer.rb