class Caracal::Renderers::ContentTypesRenderer

Public Instance Methods

to_xml() click to toggle source

This method produces the xml required for the `_.xml` sub-document.

# File lib/caracal/renderers/content_types_renderer.rb, line 17
def to_xml
  builder = ::Nokogiri::XML::Builder.with(declaration_xml) do |xml|
    xml.send 'Types', root_options do
      xml.send 'Default', { 'Extension' => 'gif',  'ContentType' => 'image/gif' }
      xml.send 'Default', { 'Extension' => 'jpeg', 'ContentType' => 'image/jpeg' }
      xml.send 'Default', { 'Extension' => 'jpg',  'ContentType' => 'image/jpeg' }
      xml.send 'Default', { 'Extension' => 'png',  'ContentType' => 'image/png' }
      xml.send 'Default', { 'Extension' => 'rels', 'ContentType' => 'application/vnd.openxmlformats-package.relationships+xml' }
      xml.send 'Default', { 'Extension' => 'xml',  'ContentType' => 'application/xml' }
      xml.send 'Override', { 'PartName' => '/docProps/app.xml',    'ContentType' => 'application/vnd.openxmlformats-officedocument.extended-properties+xml' }
      xml.send 'Override', { 'PartName' => '/docProps/core.xml',   'ContentType' => 'application/vnd.openxmlformats-package.core-properties+xml' }
      xml.send 'Override', { 'PartName' => '/docProps/custom.xml', 'ContentType' => 'application/vnd.openxmlformats-officedocument.custom-properties+xml' }
      xml.send 'Override', { 'PartName' => '/word/document.xml',   'ContentType' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml' }
      xml.send 'Override', { 'PartName' => '/word/footer1.xml',    'ContentType' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml' }
      xml.send 'Override', { 'PartName' => '/word/fontTable.xml',  'ContentType' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml' }
      xml.send 'Override', { 'PartName' => '/word/numbering.xml',  'ContentType' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml' }
      xml.send 'Override', { 'PartName' => '/word/settings.xml',   'ContentType' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml' }
      xml.send 'Override', { 'PartName' => '/word/styles.xml',     'ContentType' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml' }
    end
  end
  builder.to_xml(save_options)
end

Private Instance Methods

root_options() click to toggle source
# File lib/caracal/renderers/content_types_renderer.rb, line 46
def root_options
  {
    'xmlns' => 'http://schemas.openxmlformats.org/package/2006/content-types'
  }
end