Class: Labimotion::BuildTemplateDoiXml
- Inherits:
-
Object
- Object
- Labimotion::BuildTemplateDoiXml
- Includes:
- DataCitePublisher
- Defined in:
- lib/labimotion/usecases/build_template_doi_xml.rb
Overview
Builds the DataCite (kernel-4) metadata XML for a LabIMotion template DOI. The same XML is uploaded to DataCite at release time and shown in the UI preview, so what users see is exactly what gets sent. A template has a single DOI; the ERB template binds to this instance, so the methods below are its accessors.
Constant Summary collapse
- TEMPLATE_PATH =
Rails.root.join('app/publish/datacite_metadata_labimotion_template.html.erb')
- RESOURCE_LABEL =
{ 'element' => 'LabIMotion Element Template', 'segment' => 'LabIMotion Segment Template', 'dataset' => 'LabIMotion Dataset Template' }.freeze
Instance Method Summary collapse
-
#call ⇒ Object
Returns the XML string, or nil when no DOI has been reserved yet.
-
#initialize(record, doi = nil, current_user = nil) ⇒ BuildTemplateDoiXml
constructor
A new instance of BuildTemplateDoiXml.
Constructor Details
#initialize(record, doi = nil, current_user = nil) ⇒ BuildTemplateDoiXml
Returns a new instance of BuildTemplateDoiXml.
22 23 24 25 26 |
# File 'lib/labimotion/usecases/build_template_doi_xml.rb', line 22 def initialize(record, doi = nil, current_user = nil) @record = record @doi = doi || ::Doi.labimotion_latest_doi(record) @current_user = current_user end |
Instance Method Details
#call ⇒ Object
Returns the XML string, or nil when no DOI has been reserved yet.
29 30 31 32 33 |
# File 'lib/labimotion/usecases/build_template_doi_xml.rb', line 29 def call return nil if @doi.nil? ERB.new(File.read(TEMPLATE_PATH), trim_mode: '-').result(binding) end |