11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/bolognese/readers/codemeta_reader.rb', line 11
def read_codemeta(string: nil)
errors = jsonlint(string)
return { "errors" => errors } if errors.present?
meta = string.present? ? Maremma.from_json(string) : {}
identifier = meta.fetch("identifier", nil)
id = normalize_id(meta.fetch("@id", nil) || identifier)
type = meta.fetch("@type", nil)
author = get_authors(from_schema_org(Array.wrap(meta.fetch("agents", nil))))
editor = get_authors(from_schema_org(Array.wrap(meta.fetch("editor", nil))))
date_published = meta.fetch("datePublished", nil)
publisher = meta.fetch("publisher", nil)
{ "id" => id,
"type" => type,
"additional_type" => meta.fetch("additionalType", nil),
"citeproc_type" => Bolognese::Utils::SO_TO_CP_TRANSLATIONS[type] || "article-journal",
"bibtex_type" => Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[type] || "misc",
"ris_type" => Bolognese::Utils::SO_TO_RIS_TRANSLATIONS[type] || "GEN",
"resource_type_general" => Bolognese::Utils::SO_TO_DC_TRANSLATIONS[type],
"identifier" => identifier,
"doi" => validate_doi(id),
"url" => normalize_id(meta.fetch("codeRepository", nil)),
"title" => meta.fetch("title", nil),
"alternate_name" => meta.fetch("alternateName", nil),
"author" => author,
"editor" => editor,
"publisher" => publisher,
"date_created" => meta.fetch("dateCreated", nil),
"date_published" => date_published,
"date_modified" => meta.fetch("dateModified", nil),
"description" => meta.fetch("description", nil).present? ? { "text" => sanitize(meta.fetch("description")) } : nil,
"license" => { "id" => meta.fetch("license", nil) },
"version" => meta.fetch("version", nil),
"keywords" => meta.fetch("tags", nil)
}
end
|