6
7
8
9
10
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
49
50
51
52
|
# File 'lib/commonmeta/writers/datacite_writer.rb', line 6
def datacite
resource_type_general = Commonmeta::Utils::CM_TO_DC_TRANSLATIONS.fetch(type, 'Other')
types = { 'resourceTypeGeneral' => resource_type_general,
'resourceType' => type == resource_type_general ? nil : type,
'bibtex' => Commonmeta::Utils::CM_TO_BIB_TRANSLATIONS.fetch(type, 'misc'),
'citeproc' => Commonmeta::Utils::CM_TO_CSL_TRANSLATIONS.fetch(type, 'article'),
'ris' => Commonmeta::Utils::CM_TO_RIS_TRANSLATIONS.fetch(type, 'GEN'),
'schemaOrg' => Commonmeta::Utils::CM_TO_SO_TRANSLATIONS.fetch(type,
'CreativeWork') }.compact
dates = get_dates_from_date(date)
rights_list = spdx_to_hsh(license)
related_identifiers = Array.wrap(references).map { |r| datacite_reference(r) }
hsh = {
'id' => id,
'doi' => doi_from_url(id),
'url' => url,
'types' => types,
'creators' => Array.wrap(contributors).map { |c| datacite_contributor(c) },
'titles' => titles,
'publisher' => publisher.to_h['name'],
'container' => container,
'subjects' => subjects,
'contributors' => Array.wrap(contributors).map { |c| datacite_contributor(c) },
'dates' => dates,
'language' => language,
'alternate_identifiers' => alternate_identifiers,
'sizes' => sizes,
'formats' => formats,
'version' => version,
'rights_list' => rights_list,
'descriptions' => descriptions,
'geo_locations' => geo_locations,
'funding_references' => funding_references,
'related_identifiers' => related_identifiers,
'schema_version' => schema_version,
'provider_id' => provider_id,
'client_id' => client_id,
'agency' => provider,
'state' => state
}.compact
JSON.pretty_generate hsh.transform_keys! { |key|
key.camelcase(uppercase_first_letter = :lower)
}
end
|