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
|
# File 'lib/commonmeta/writers/cff_writer.rb', line 6
def cff
return nil unless %w[Software Collection].include?(type)
title = parse_attributes(titles, content: 'title', first: true)
authors = Array.wrap(contributors).select { |c| c['contributorRoles'] == ['Author'] }
hsh = {
'cff-version' => '1.2.0',
'message' => "If you use #{title} in your research, please cite it using the following metadata",
'doi' => normalize_doi(id),
'repository-code' => url,
'title' => title,
'authors' => write_cff_contributors(authors),
'abstract' => parse_attributes(descriptions, content: 'description', first: true),
'version' => version,
'keywords' => if subjects.present?
Array.wrap(subjects).map do |k|
parse_attributes(k, content: 'subject', first: true)
end
end,
'date-released' => date['published'],
'license' => license.to_h['id'],
'references' => { 'identifiers' => Array.wrap(references).map do |r|
write_cff_reference(r)
end }
}.compact
hsh.to_yaml
end
|