bolognese 0.7.2 → 0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -1
- data/README.md +25 -16
- data/bolognese.gemspec +2 -1
- data/codemeta.json +39 -0
- data/lib/bolognese.rb +4 -0
- data/lib/bolognese/array.rb +11 -0
- data/lib/bolognese/author_utils.rb +35 -21
- data/lib/bolognese/bibtex.rb +4 -4
- data/lib/bolognese/codemeta.rb +8 -13
- data/lib/bolognese/crossref.rb +22 -20
- data/lib/bolognese/datacite.rb +61 -61
- data/lib/bolognese/datacite_json.rb +208 -0
- data/lib/bolognese/datacite_utils.rb +17 -48
- data/lib/bolognese/metadata.rb +83 -22
- data/lib/bolognese/schema_org.rb +42 -16
- data/lib/bolognese/utils.rb +79 -13
- data/lib/bolognese/version.rb +1 -1
- data/lib/bolognese/whitelist_scrubber.rb +45 -0
- data/spec/array_spec.rb +20 -0
- data/spec/author_utils_spec.rb +93 -9
- data/spec/bibtex_spec.rb +4 -4
- data/spec/cli_spec.rb +5 -0
- data/spec/codemeta_spec.rb +41 -31
- data/spec/crossref_spec.rb +47 -72
- data/spec/datacite_json_spec.rb +65 -0
- data/spec/datacite_spec.rb +67 -83
- data/spec/datacite_utils_spec.rb +9 -14
- data/spec/fixtures/datacite.json +49 -0
- data/spec/fixtures/datacite_software.json +18 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_CLI/convert_from_id/datacite/to_datacite_json.yml +214 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/author_from_schema_org/with_id.yml +930 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/author_to_schema_org/with_id.yml +930 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/authors_as_string/author.yml +137 -860
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/authors_as_string/no_author.yml +137 -860
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/authors_as_string/single_author.yml +137 -860
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/authors_as_string/with_organization.yml +137 -860
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/from_schema_org/with_id.yml +930 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_name_identifier/has_ORCID.yml +155 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_name_identifier/has_no_ORCID.yml +134 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/has_familyName.yml +155 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/has_name_in_display-order.yml +186 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/has_name_in_display-order_with_ORCID.yml +177 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/has_name_in_sort-order.yml +173 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/get_one_author/is_organization.yml +207 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/is_personal_name_/has_comma.yml +207 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/is_personal_name_/has_family_name.yml +207 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/is_personal_name_/has_id.yml +207 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/is_personal_name_/has_no_info.yml +207 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/is_personal_name_/has_type_organization.yml +207 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/is_personal_name_/has_type_person.yml +207 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/sanitize/should_only_keep_specific_tags.yml +930 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/sanitize/should_remove_a_tags.yml +930 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Crossref/to_schema_org/with_id.yml +930 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_Datacite/insert_related_identifiers/related_identifier.yml +173 -0
- data/spec/fixtures/vcr_cassettes/Bolognese_DataciteJson/get_metadata_as_bibtex/BlogPosting.yml +155 -0
- data/spec/schema_org_spec.rb +17 -14
- data/spec/utils_spec.rb +32 -2
- metadata +54 -4
data/lib/bolognese/datacite.rb
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
module Bolognese
|
|
2
2
|
class Datacite < Metadata
|
|
3
3
|
|
|
4
|
-
DC_TO_SO_TRANSLATIONS = {
|
|
5
|
-
"Audiovisual" => "VideoObject",
|
|
6
|
-
"Collection" => "Collection",
|
|
7
|
-
"Dataset" => "Dataset",
|
|
8
|
-
"Event" => "Event",
|
|
9
|
-
"Image" => "ImageObject",
|
|
10
|
-
"InteractiveResource" => nil,
|
|
11
|
-
"Model" => nil,
|
|
12
|
-
"PhysicalObject" => nil,
|
|
13
|
-
"Service" => "Service",
|
|
14
|
-
"Software" => "SoftwareSourceCode",
|
|
15
|
-
"Sound" => "AudioObject",
|
|
16
|
-
"Text" => "ScholarlyArticle",
|
|
17
|
-
"Workflow" => nil,
|
|
18
|
-
"Other" => "CreativeWork"
|
|
19
|
-
}
|
|
20
|
-
|
|
21
4
|
SCHEMA = File.expand_path("../../../resources/kernel-4.0/metadata.xsd", __FILE__)
|
|
22
5
|
|
|
23
6
|
def initialize(id: nil, string: nil, regenerate: false)
|
|
@@ -28,6 +11,7 @@ module Bolognese
|
|
|
28
11
|
elsif id.present?
|
|
29
12
|
response = Maremma.get(id, accept: "application/vnd.datacite.datacite+xml", raw: true)
|
|
30
13
|
@raw = response.body.fetch("data", nil)
|
|
14
|
+
@raw = Nokogiri::XML(@raw, &:noblanks).to_s if @raw.present?
|
|
31
15
|
end
|
|
32
16
|
|
|
33
17
|
@should_passthru = !regenerate
|
|
@@ -51,8 +35,7 @@ module Bolognese
|
|
|
51
35
|
end
|
|
52
36
|
|
|
53
37
|
def errors
|
|
54
|
-
|
|
55
|
-
array_unwrap(arr)
|
|
38
|
+
schema.validate(Nokogiri::XML(raw)).map { |error| error.to_s }.unwrap
|
|
56
39
|
end
|
|
57
40
|
|
|
58
41
|
def schema_version
|
|
@@ -90,24 +73,26 @@ module Bolognese
|
|
|
90
73
|
Bolognese::Bibtex::SO_TO_BIB_TRANSLATIONS[type] || "misc"
|
|
91
74
|
end
|
|
92
75
|
|
|
93
|
-
def
|
|
76
|
+
def title
|
|
94
77
|
metadata.dig("titles", "title")
|
|
95
78
|
end
|
|
96
79
|
|
|
97
80
|
def alternate_name
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
def descriptions
|
|
102
|
-
Array.wrap(metadata.dig("descriptions", "description"))
|
|
81
|
+
Array.wrap(metadata.dig("alternateIdentifiers", "alternateIdentifier")).map do |r|
|
|
82
|
+
{ "type" => r["alternateIdentifierType"], "name" => r["__content__"] }.compact
|
|
83
|
+
end.unwrap
|
|
103
84
|
end
|
|
104
85
|
|
|
105
86
|
def description
|
|
106
|
-
|
|
87
|
+
Array.wrap(metadata.dig("descriptions", "description")).map do |r|
|
|
88
|
+
{ "type" => r["descriptionType"], "text" => sanitize(r["__content__"]) }.compact
|
|
89
|
+
end.unwrap
|
|
107
90
|
end
|
|
108
91
|
|
|
109
92
|
def license
|
|
110
|
-
|
|
93
|
+
Array.wrap(metadata.dig("rightsList", "rights")).map do |r|
|
|
94
|
+
{ "url" => r["rightsURI"], "name" => r["__content__"] }.compact
|
|
95
|
+
end.unwrap
|
|
111
96
|
end
|
|
112
97
|
|
|
113
98
|
def keywords
|
|
@@ -115,15 +100,12 @@ module Bolognese
|
|
|
115
100
|
end
|
|
116
101
|
|
|
117
102
|
def author
|
|
118
|
-
|
|
119
|
-
authors = [authors] if authors.is_a?(Hash)
|
|
120
|
-
array_unwrap(get_authors(authors))
|
|
103
|
+
get_authors(metadata.dig("creators", "creator"))
|
|
121
104
|
end
|
|
122
105
|
|
|
123
106
|
def editor
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
array_unwrap(get_authors(editors))
|
|
107
|
+
get_authors(Array.wrap(metadata.dig("contributors", "contributor"))
|
|
108
|
+
.select { |r| r["contributorType"] == "Editor" })
|
|
127
109
|
end
|
|
128
110
|
|
|
129
111
|
def funder
|
|
@@ -134,7 +116,7 @@ module Bolognese
|
|
|
134
116
|
def funder_contributor
|
|
135
117
|
Array.wrap(metadata.dig("contributors", "contributor")).reduce([]) do |sum, f|
|
|
136
118
|
if f["contributorType"] == "Funder"
|
|
137
|
-
sum << { "
|
|
119
|
+
sum << { "name" => f["contributorName"] }
|
|
138
120
|
else
|
|
139
121
|
sum
|
|
140
122
|
end
|
|
@@ -144,8 +126,7 @@ module Bolognese
|
|
|
144
126
|
def funding_reference
|
|
145
127
|
Array.wrap(metadata.dig("fundingReferences", "fundingReference")).map do |f|
|
|
146
128
|
funder_id = parse_attributes(f["funderIdentifier"])
|
|
147
|
-
{ "
|
|
148
|
-
"@id" => normalize_id(funder_id),
|
|
129
|
+
{ "identifier" => normalize_id(funder_id),
|
|
149
130
|
"name" => f["funderName"] }.compact
|
|
150
131
|
end.uniq
|
|
151
132
|
end
|
|
@@ -165,18 +146,44 @@ module Bolognese
|
|
|
165
146
|
dd.fetch("__content__", nil)
|
|
166
147
|
end
|
|
167
148
|
|
|
149
|
+
def date_accepted
|
|
150
|
+
date("Accepted")
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def date_available
|
|
154
|
+
date("Available")
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def date_copyrighted
|
|
158
|
+
date("Copyrighted")
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def date_collected
|
|
162
|
+
date("Collected")
|
|
163
|
+
end
|
|
164
|
+
|
|
168
165
|
def date_created
|
|
169
166
|
date("Created")
|
|
170
167
|
end
|
|
171
168
|
|
|
169
|
+
# use datePublished for date issued
|
|
172
170
|
def date_published
|
|
173
171
|
date("Issued") || publication_year
|
|
174
172
|
end
|
|
175
173
|
|
|
174
|
+
def date_submitted
|
|
175
|
+
date("Submitted")
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# use dateModified for date updated
|
|
176
179
|
def date_modified
|
|
177
180
|
date("Updated")
|
|
178
181
|
end
|
|
179
182
|
|
|
183
|
+
def date_valid
|
|
184
|
+
date("Valid")
|
|
185
|
+
end
|
|
186
|
+
|
|
180
187
|
def publication_year
|
|
181
188
|
metadata.fetch("publicationYear")
|
|
182
189
|
end
|
|
@@ -193,52 +200,45 @@ module Bolognese
|
|
|
193
200
|
metadata.fetch("size", nil)
|
|
194
201
|
end
|
|
195
202
|
|
|
196
|
-
def
|
|
197
|
-
arr = Array.wrap(metadata.dig("relatedIdentifiers", "relatedIdentifier"))
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
"@id" => normalize_id(work["__content__"]) }
|
|
202
|
-
end
|
|
203
|
-
array_unwrap(arr)
|
|
203
|
+
def related_identifier(relation_type: nil)
|
|
204
|
+
arr = Array.wrap(metadata.dig("relatedIdentifiers", "relatedIdentifier")).select { |r| %w(DOI URL).include?(r["relatedIdentifierType"]) }
|
|
205
|
+
arr = arr.select { |r| relation_type.split(" ").include?(r["relationType"]) } if relation_type.present?
|
|
206
|
+
|
|
207
|
+
arr.map { |work| { "id" => normalize_id(work["__content__"]), "relationType" => work["relationType"] } }.unwrap
|
|
204
208
|
end
|
|
205
209
|
|
|
206
|
-
def
|
|
207
|
-
|
|
210
|
+
def is_identical_to
|
|
211
|
+
related_identifier(relation_type: "IsIdenticalTo")
|
|
208
212
|
end
|
|
209
213
|
|
|
210
214
|
def is_part_of
|
|
211
|
-
|
|
215
|
+
related_identifier(relation_type: "IsPartOf")
|
|
212
216
|
end
|
|
213
217
|
|
|
214
218
|
def has_part
|
|
215
|
-
|
|
219
|
+
related_identifier(relation_type: "HasPart")
|
|
216
220
|
end
|
|
217
221
|
|
|
218
|
-
def
|
|
219
|
-
|
|
222
|
+
def is_previous_version_of
|
|
223
|
+
related_identifier(relation_type: "IsPreviousVersionOf")
|
|
220
224
|
end
|
|
221
225
|
|
|
222
|
-
def
|
|
223
|
-
|
|
226
|
+
def is_new_version_of
|
|
227
|
+
related_identifier(relation_type: "IsNewVersionOf")
|
|
224
228
|
end
|
|
225
229
|
|
|
226
|
-
def
|
|
227
|
-
|
|
230
|
+
def references
|
|
231
|
+
related_identifier(relation_type: "Cites IsCitedBy Supplements IsSupplementTo References IsReferencedBy").presence
|
|
228
232
|
end
|
|
229
233
|
|
|
230
234
|
def publisher
|
|
231
|
-
|
|
232
|
-
"name" => metadata.fetch("publisher") }
|
|
235
|
+
metadata.fetch("publisher")
|
|
233
236
|
end
|
|
234
237
|
|
|
235
|
-
|
|
236
|
-
publisher.fetch("name", nil)
|
|
237
|
-
end
|
|
238
|
+
alias_method :container_title, :publisher
|
|
238
239
|
|
|
239
240
|
def provider
|
|
240
|
-
|
|
241
|
-
"name" => "DataCite" }
|
|
241
|
+
"DataCite"
|
|
242
242
|
end
|
|
243
243
|
end
|
|
244
244
|
end
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
module Bolognese
|
|
2
|
+
class DataciteJson < Metadata
|
|
3
|
+
|
|
4
|
+
def initialize(string: nil, regenerate: false)
|
|
5
|
+
if string.present?
|
|
6
|
+
@raw = string
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def metadata
|
|
11
|
+
@metadata ||= raw.present? ? Maremma.from_json(raw) : {}
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def valid?
|
|
15
|
+
true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def datacite
|
|
19
|
+
datacite_xml
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def doi
|
|
23
|
+
metadata.fetch("doi", nil)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def id
|
|
27
|
+
metadata.fetch("id", nil)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def resource_type_general
|
|
31
|
+
metadata.fetch("resource-type-general", nil)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def type
|
|
35
|
+
DC_TO_SO_TRANSLATIONS[resource_type_general.to_s.dasherize] || "CreativeWork"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def additional_type
|
|
39
|
+
metadata.fetch("resource-type", nil)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def bibtex_type
|
|
43
|
+
Bolognese::Bibtex::SO_TO_BIB_TRANSLATIONS[type] || "misc"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def title
|
|
47
|
+
metadata.fetch("title", nil)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def alternate_name
|
|
51
|
+
metadata.fetch("alternate-identifier", nil)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def description
|
|
55
|
+
metadata.fetch("description", nil)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def license
|
|
59
|
+
metadata.fetch("license", nil)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def keywords
|
|
63
|
+
metadata.fetch("subject", nil)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def author
|
|
67
|
+
metadata.fetch("creator", nil)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def editor
|
|
71
|
+
metadata.fetch("contributor", nil)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# def funder
|
|
75
|
+
# f = funder_contributor + funding_reference
|
|
76
|
+
# f.length > 1 ? f : f.first
|
|
77
|
+
# end
|
|
78
|
+
#
|
|
79
|
+
# def funder_contributor
|
|
80
|
+
# Array.wrap(metadata.dig("contributors", "contributor")).reduce([]) do |sum, f|
|
|
81
|
+
# if f["contributorType"] == "Funder"
|
|
82
|
+
# sum << { "name" => f["contributorName"] }
|
|
83
|
+
# else
|
|
84
|
+
# sum
|
|
85
|
+
# end
|
|
86
|
+
# end
|
|
87
|
+
# end
|
|
88
|
+
#
|
|
89
|
+
# def funding_reference
|
|
90
|
+
# Array.wrap(metadata.dig("fundingReferences", "fundingReference")).map do |f|
|
|
91
|
+
# funder_id = parse_attributes(f["funderIdentifier"])
|
|
92
|
+
# { "identifier" => normalize_id(funder_id),
|
|
93
|
+
# "name" => f["funderName"] }.compact
|
|
94
|
+
# end.uniq
|
|
95
|
+
# end
|
|
96
|
+
|
|
97
|
+
def version
|
|
98
|
+
metadata.fetch("version", nil)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# def dates
|
|
102
|
+
# Array.wrap(metadata.dig("dates", "date"))
|
|
103
|
+
# end
|
|
104
|
+
#
|
|
105
|
+
# #Accepted Available Copyrighted Collected Created Issued Submitted Updated Valid
|
|
106
|
+
#
|
|
107
|
+
# def date(date_type)
|
|
108
|
+
# dd = dates.find { |d| d["dateType"] == date_type } || {}
|
|
109
|
+
# dd.fetch("__content__", nil)
|
|
110
|
+
# end
|
|
111
|
+
|
|
112
|
+
def date_accepted
|
|
113
|
+
metadata.fetch("date-accepted", nil)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def date_available
|
|
117
|
+
metadata.fetch("date-available", nil)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def date_copyrighted
|
|
121
|
+
metadata.fetch("date-copyrighted", nil)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def date_collected
|
|
125
|
+
metadata.fetch("date-collected", nil)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def date_created
|
|
129
|
+
metadata.fetch("date-created", nil)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# use datePublished for date issued
|
|
133
|
+
def date_published
|
|
134
|
+
metadata.fetch("date-published", nil)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def date_submitted
|
|
138
|
+
metadata.fetch("date-submitted", nil)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# use dateModified for date updated
|
|
142
|
+
def date_modified
|
|
143
|
+
metadata.fetch("date-modified", nil)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def date_valid
|
|
147
|
+
metadata.fetch("date-valid", nil)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def publication_year
|
|
151
|
+
metadata.fetch("publication-year")
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def language
|
|
155
|
+
metadata.fetch("language", nil)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def spatial_coverage
|
|
159
|
+
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def content_size
|
|
163
|
+
metadata.fetch("size", nil)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def related_identifier
|
|
167
|
+
metadata.fetch("related_identifier", nil)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def get_related_identifier(relation_type: nil)
|
|
171
|
+
Array.wrap(related_identifier).select { |r| relation_type.split(" ").include?(r["relationType"]) }.unwrap
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def is_identical_to
|
|
175
|
+
get_related_identifier(relation_type: "IsIdenticalTo")
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def is_part_of
|
|
179
|
+
get_related_identifier(relation_type: "IsPartOf")
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def has_part
|
|
183
|
+
get_related_identifier(relation_type: "HasPart")
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def is_previous_version_of
|
|
187
|
+
get_related_identifier(relation_type: "IsPreviousVersionOf")
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def is_new_version_of
|
|
191
|
+
get_related_identifier(relation_type: "IsNewVersionOf")
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def references
|
|
195
|
+
get_related_identifier(relation_type: "Cites IsCitedBy Supplements IsSupplementTo References IsReferencedBy").presence
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def publisher
|
|
199
|
+
metadata.fetch("publisher")
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
alias_method :container_title, :publisher
|
|
203
|
+
|
|
204
|
+
def provider
|
|
205
|
+
"DataCite"
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
end
|
|
@@ -22,15 +22,6 @@ module Bolognese
|
|
|
22
22
|
"WebSite" => "Text"
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
LICENSE_NAMES = {
|
|
26
|
-
"http://creativecommons.org/publicdomain/zero/1.0/" => "Public Domain (CC0 1.0)",
|
|
27
|
-
"http://creativecommons.org/licenses/by/3.0/" => "Creative Commons Attribution 3.0 (CC-BY 3.0)",
|
|
28
|
-
"http://creativecommons.org/licenses/by/4.0/" => "Creative Commons Attribution 4.0 (CC-BY 4.0)",
|
|
29
|
-
"http://creativecommons.org/licenses/by-nc/4.0/" => "Creative Commons Attribution Noncommercial 4.0 (CC-BY-NC 4.0)",
|
|
30
|
-
"http://creativecommons.org/licenses/by-sa/4.0/" => "Creative Commons Attribution Share Alike 4.0 (CC-BY-SA 4.0)",
|
|
31
|
-
"http://creativecommons.org/licenses/by-nc-nd/4.0/" => "Creative Commons Attribution Noncommercial No Derivatives 4.0 (CC-BY-NC-ND 4.0)"
|
|
32
|
-
}
|
|
33
|
-
|
|
34
25
|
SCHEMA = File.expand_path("../../../resources/kernel-4.0/metadata.xsd", __FILE__)
|
|
35
26
|
|
|
36
27
|
def schema
|
|
@@ -103,7 +94,7 @@ module Bolognese
|
|
|
103
94
|
xml.send(type + "Name", person_name)
|
|
104
95
|
xml.givenName(person["givenName"]) if person["givenName"].present?
|
|
105
96
|
xml.familyName(person["familyName"]) if person["familyName"].present?
|
|
106
|
-
xml.nameIdentifier(person["
|
|
97
|
+
xml.nameIdentifier(person["id"], 'schemeURI' => 'http://orcid.org/', 'nameIdentifierScheme' => 'ORCID') if person["id"].present?
|
|
107
98
|
end
|
|
108
99
|
|
|
109
100
|
def insert_titles(xml)
|
|
@@ -113,7 +104,7 @@ module Bolognese
|
|
|
113
104
|
end
|
|
114
105
|
|
|
115
106
|
def insert_title(xml)
|
|
116
|
-
xml.title(
|
|
107
|
+
xml.title(title)
|
|
117
108
|
end
|
|
118
109
|
|
|
119
110
|
def insert_publisher(xml)
|
|
@@ -140,7 +131,9 @@ module Bolognese
|
|
|
140
131
|
return xml unless alternate_name.present?
|
|
141
132
|
|
|
142
133
|
xml.alternateIdentifiers do
|
|
143
|
-
|
|
134
|
+
Array.wrap(alternate_name).each do |alt|
|
|
135
|
+
xml.alternateIdentifier(alt["name"], 'alternateIdentifierType' => alt["type"])
|
|
136
|
+
end
|
|
144
137
|
end
|
|
145
138
|
end
|
|
146
139
|
|
|
@@ -170,7 +163,7 @@ module Bolognese
|
|
|
170
163
|
|
|
171
164
|
def insert_funding_reference(xml, funding_reference)
|
|
172
165
|
xml.funderName(funding_reference["name"]) if funding_reference["name"].present?
|
|
173
|
-
xml.funderIdentifier(funding_reference["
|
|
166
|
+
xml.funderIdentifier(funding_reference["id"], "funderIdentifierType" => "Crossref Funder ID") if funding_reference["id"].present?
|
|
174
167
|
end
|
|
175
168
|
|
|
176
169
|
def insert_subjects(xml)
|
|
@@ -189,25 +182,19 @@ module Bolognese
|
|
|
189
182
|
xml.version(version)
|
|
190
183
|
end
|
|
191
184
|
|
|
192
|
-
def
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
def rel_identifier(rel_ids: nil, relation_type: nil)
|
|
199
|
-
Array.wrap(rel_ids).map do |i|
|
|
200
|
-
{ "__content__" => i["@id"],
|
|
201
|
-
"related_identifier_type" => validate_url(i["@id"]),
|
|
202
|
-
"relation_type" => relation_type }
|
|
203
|
-
end.select { |i| i["related_identifier_type"].present? }
|
|
185
|
+
def rel_identifier
|
|
186
|
+
Array.wrap(related_identifier).map do |r|
|
|
187
|
+
{ "__content__" => r["id"],
|
|
188
|
+
"related_identifier_type" => validate_url(r["id"]),
|
|
189
|
+
"relation_type" => r["relationType"] }
|
|
190
|
+
end
|
|
204
191
|
end
|
|
205
192
|
|
|
206
193
|
def insert_related_identifiers(xml)
|
|
207
|
-
return xml unless
|
|
194
|
+
return xml unless rel_identifier.present?
|
|
208
195
|
|
|
209
196
|
xml.relatedIdentifiers do
|
|
210
|
-
|
|
197
|
+
rel_identifier.each do |related_identifier|
|
|
211
198
|
xml.relatedIdentifier(related_identifier["__content__"], 'relatedIdentifierType' => related_identifier["related_identifier_type"], 'relationType' => related_identifier["relation_type"])
|
|
212
199
|
end
|
|
213
200
|
end
|
|
@@ -218,37 +205,19 @@ module Bolognese
|
|
|
218
205
|
|
|
219
206
|
xml.rightsList do
|
|
220
207
|
Array.wrap(license).each do |lic|
|
|
221
|
-
xml.rights(
|
|
208
|
+
xml.rights(lic["name"], 'rightsURI' => lic["url"])
|
|
222
209
|
end
|
|
223
210
|
end
|
|
224
211
|
end
|
|
225
212
|
|
|
226
213
|
def insert_descriptions(xml)
|
|
227
|
-
return xml unless
|
|
214
|
+
return xml unless description.present?
|
|
228
215
|
|
|
229
216
|
xml.descriptions do
|
|
230
217
|
Array.wrap(description).each do |des|
|
|
231
|
-
|
|
232
|
-
end
|
|
233
|
-
end
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
def insert_description(xml, des)
|
|
237
|
-
if des.is_a?(String)
|
|
238
|
-
xml.description(des.strip, 'descriptionType' => "Abstract")
|
|
239
|
-
elsif des.is_a?(Hash)
|
|
240
|
-
xml.description(des["__content__"].strip, 'descriptionType' => des["descriptionType"],)
|
|
241
|
-
end
|
|
242
|
-
end
|
|
243
|
-
|
|
244
|
-
def without_control(s)
|
|
245
|
-
r = ''
|
|
246
|
-
s.each_codepoint do |c|
|
|
247
|
-
if c >= 32
|
|
248
|
-
r << c
|
|
218
|
+
xml.description(des["text"], 'descriptionType' => des["type"] || "Abstract")
|
|
249
219
|
end
|
|
250
220
|
end
|
|
251
|
-
r
|
|
252
221
|
end
|
|
253
222
|
|
|
254
223
|
def root_attributes
|