Class: Stash::Merritt::SubmissionPackage::MerrittOAIDCBuilder

Inherits:
Repo::FileBuilder
  • Object
show all
Defined in:
lib/stash/merritt/submission_package/merritt_oaidc_builder.rb

Constant Summary collapse

ROOT_ATTRIBUTES =
{
  'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
  'xsi:noNamespaceSchemaLocation' => 'http://dublincore.org/schemas/xmls/qdc/2008/02/11/qualifieddc.xsd',
  'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
  'xmlns:dcterms' => 'http://purl.org/dc/terms/'
}.freeze
DC_RELATION_TYPES =
{
  'cites' => 'references',
  'iscitedby' => 'isReferencedBy',
  'isnewversionof' => 'isVersionOf',
  'ispreviousversionof' => 'hasVersion',
  'ispartof' => 'isPartOf',
  'haspart' => 'hasPart'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_id:) ⇒ MerrittOAIDCBuilder

Returns a new instance of MerrittOAIDCBuilder.



25
26
27
28
# File 'lib/stash/merritt/submission_package/merritt_oaidc_builder.rb', line 25

def initialize(resource_id:)
  super(file_name: 'mrt-oaidc.xml')
  @resource_id = resource_id
end

Instance Attribute Details

#resource_idObject (readonly)

Returns the value of attribute resource_id.



23
24
25
# File 'lib/stash/merritt/submission_package/merritt_oaidc_builder.rb', line 23

def resource_id
  @resource_id
end

Instance Method Details

#contentsObject

rubocop:disable Metrics/MethodLength



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/stash/merritt/submission_package/merritt_oaidc_builder.rb', line 30

def contents # rubocop:disable Metrics/MethodLength
  Nokogiri::XML::Builder.new do |xml|
    xml.qualifieddc(ROOT_ATTRIBUTES) do
      add_creators(xml)
      add_contributors(xml)
      add_title(xml)
      add_publisher(xml)
      add_pub_year(xml)
      add_subjects(xml)
      add_resource_type(xml)
      add_rights(xml)
      add_descriptions(xml)
      add_related_identifiers(xml)
    end
  end.to_xml.to_s
end