lib/bolognese/datacite_utils.rb in bolognese-0.12.2 vs lib/bolognese/datacite_utils.rb in bolognese-0.12.3

- old
+ new

@@ -9,11 +9,11 @@ end end.to_xml end def datacite_errors(xml: nil, schema_version: nil) - schema_version ||= "http://datacite.org/schema/kernel-4" + schema_version = schema_version.to_s.start_with?("http://datacite.org/schema/kernel") ? schema_version : "http://datacite.org/schema/kernel-4" kernel = schema_version.to_s.split("/").last filepath = File.expand_path("../../../resources/#{kernel}/metadata.xsd", __FILE__) schema = Nokogiri::XML::Schema(open(filepath)) schema.validate(Nokogiri::XML(xml, nil, 'UTF-8')).map { |error| error.to_s }.unwrap @@ -208,12 +208,16 @@ end end end def insert_descriptions(xml) - return xml unless description.present? + return xml unless description.present? || container_title.present? xml.descriptions do + if container_title.present? + xml.description(container_title, 'descriptionType' => "SeriesInformation") + end + Array.wrap(description).each do |des| if des.is_a?(Hash) d = des else d = {}