lib/bolognese/utils.rb in bolognese-2.2.0 vs lib/bolognese/utils.rb in bolognese-2.3.0

- old
+ new

@@ -76,11 +76,13 @@ "Text" => "ScholarlyArticle", "Workflow" => nil, "Other" => "CreativeWork", # not part of DataCite schema, but used internally "Periodical" => "Periodical", - "DataCatalog" => "DataCatalog" + "DataCatalog" => "DataCatalog", + "Award" => "Grant", + "Project" => "Project" } DC_TO_CP_TRANSLATIONS = { "Audiovisual" => "motion_picture", "Book" => "book", @@ -823,11 +825,12 @@ end.unwrap end def to_schema_org_contributors(element) element = Array.wrap(element).map do |c| - c["affiliation"] = Array.wrap(c["affiliation"]).map do |a| + transformed_c = c.dup + transformed_c["affiliation"] = Array.wrap(c["affiliation"]).map do |a| if a.is_a?(String) name = a affiliation_identifier = nil else name = a["name"] @@ -837,14 +840,14 @@ { "@type" => "Organization", "@id" => affiliation_identifier, "name" => name }.compact end.unwrap - c["@type"] = c["nameType"].present? ? c["nameType"][0..-3] : nil - c["@id"] = Array.wrap(c["nameIdentifiers"]).first.to_h.fetch("nameIdentifier", nil) - c["name"] = c["familyName"].present? ? [c["givenName"], c["familyName"]].join(" ") : c["name"] - c.except("nameIdentifiers", "nameType").compact + transformed_c["@type"] = c["nameType"].present? ? c["nameType"][0..-3] : nil + transformed_c["@id"] = Array.wrap(c["nameIdentifiers"]).first.to_h.fetch("nameIdentifier", nil) + transformed_c["name"] = c["familyName"].present? ? [c["givenName"], c["familyName"]].join(" ") : c["name"] + transformed_c.except("nameIdentifiers", "nameType").compact end.unwrap end def to_schema_org_container(element, options={}) return nil unless (element.is_a?(Hash) || (element.nil? && options[:container_title].present?)) @@ -1232,10 +1235,12 @@ "upc" => "UPC", "url" => "URL", "urn" => "URN", "md5" => "md5", "minid" => "minid", - "dataguid" => "dataguid" + "dataguid" => "dataguid", + "cstr" => "CSTR", + "rrid" => "RRID" } identifierTypes[identifier_type.downcase] || identifier_type end