bolognese 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/bolognese/datacite_utils.rb +8 -9
- data/lib/bolognese/metadata.rb +7 -44
- data/lib/bolognese/metadata_utils.rb +2 -2
- data/lib/bolognese/readers/bibtex_reader.rb +18 -7
- data/lib/bolognese/readers/citeproc_reader.rb +26 -11
- data/lib/bolognese/readers/codemeta_reader.rb +17 -16
- data/lib/bolognese/readers/crossref_reader.rb +23 -15
- data/lib/bolognese/readers/datacite_json_reader.rb +19 -11
- data/lib/bolognese/readers/datacite_reader.rb +15 -15
- data/lib/bolognese/readers/ris_reader.rb +14 -8
- data/lib/bolognese/readers/schema_org_reader.rb +17 -11
- data/lib/bolognese/utils.rb +22 -5
- data/lib/bolognese/version.rb +1 -1
- data/lib/bolognese/writers/bibtex_writer.rb +1 -1
- data/lib/bolognese/writers/codemeta_writer.rb +3 -3
- data/lib/bolognese/writers/crosscite_writer.rb +3 -10
- data/lib/bolognese/writers/datacite_json_writer.rb +5 -8
- data/lib/bolognese/writers/jats_writer.rb +3 -3
- data/lib/bolognese/writers/ris_writer.rb +1 -1
- data/lib/bolognese/writers/schema_org_writer.rb +7 -7
- data/spec/datacite_utils_spec.rb +8 -7
- data/spec/fixtures/crosscite.json +13 -8
- data/spec/fixtures/datacite.json +8 -4
- data/spec/fixtures/datacite_software.json +0 -1
- data/spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_date/publication_date.yml +37 -0
- data/spec/readers/bibtex_reader_spec.rb +6 -10
- data/spec/readers/citeproc_reader_spec.rb +3 -3
- data/spec/readers/codemeta_reader_spec.rb +12 -16
- data/spec/readers/crosscite_reader_spec.rb +9 -8
- data/spec/readers/crossref_reader_spec.rb +27 -63
- data/spec/readers/datacite_json_reader_spec.rb +3 -4
- data/spec/readers/datacite_reader_spec.rb +156 -142
- data/spec/readers/ris_reader_spec.rb +6 -7
- data/spec/readers/schema_org_reader_spec.rb +26 -25
- data/spec/utils_spec.rb +8 -0
- data/spec/writers/bibtex_writer_spec.rb +1 -1
- data/spec/writers/citeproc_writer_spec.rb +1 -1
- data/spec/writers/crosscite_writer_spec.rb +6 -5
- data/spec/writers/datacite_writer_spec.rb +14 -17
- metadata +3 -2
@@ -71,9 +71,19 @@ module Bolognese
|
|
71
71
|
end
|
72
72
|
|
73
73
|
doi = doi_from_url(id)
|
74
|
+
|
74
75
|
resource_type_general = meta.dig("resourceType", "resourceTypeGeneral")
|
75
|
-
|
76
|
-
type = Bolognese::Utils::CR_TO_SO_TRANSLATIONS[
|
76
|
+
resource_type = meta.dig("resourceType", "__content__")
|
77
|
+
type = Bolognese::Utils::CR_TO_SO_TRANSLATIONS[resource_type.to_s.underscore.camelcase] || Bolognese::Utils::DC_TO_SO_TRANSLATIONS[resource_type_general.to_s.dasherize] || "CreativeWork"
|
78
|
+
types = {
|
79
|
+
"type" => type,
|
80
|
+
"resource_type_general" => resource_type_general,
|
81
|
+
"resource_type" => resource_type,
|
82
|
+
"citeproc" => Bolognese::Utils::CR_TO_CP_TRANSLATIONS[resource_type.to_s.underscore.camelcase] || Bolognese::Utils::SO_TO_CP_TRANSLATIONS[type] || "article",
|
83
|
+
"bibtex" => Bolognese::Utils::CR_TO_BIB_TRANSLATIONS[resource_type.to_s.underscore.camelcase] || Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[type] || "misc",
|
84
|
+
"ris" => Bolognese::Utils::CR_TO_RIS_TRANSLATIONS[resource_type.to_s.underscore.camelcase] || Bolognese::Utils::DC_TO_RIS_TRANSLATIONS[resource_type_general.to_s.dasherize] || "GEN"
|
85
|
+
}.compact
|
86
|
+
|
77
87
|
title = Array.wrap(meta.dig("titles", "title")).map do |r|
|
78
88
|
if r.is_a?(String)
|
79
89
|
sanitize(r)
|
@@ -106,6 +116,7 @@ module Bolognese
|
|
106
116
|
"date_type" => parse_attributes(d, content: "dateType")
|
107
117
|
}
|
108
118
|
end
|
119
|
+
dates << { "date" => meta.fetch("publicationYear", nil), "date_type" => "Issued" } if meta.fetch("publicationYear", nil).present? && get_date(dates, "Issued").blank?
|
109
120
|
sizes = Array.wrap(meta.dig("sizes", "size")).unwrap
|
110
121
|
formats = Array.wrap(meta.dig("formats", "format")).unwrap
|
111
122
|
funding_references = Array.wrap(meta.dig("fundingReferences", "fundingReference")).compact.map do |fr|
|
@@ -154,12 +165,7 @@ module Bolognese
|
|
154
165
|
state = doi.present? ? "findable" : "not_found"
|
155
166
|
|
156
167
|
{ "id" => id,
|
157
|
-
"
|
158
|
-
"additional_type" => additional_type,
|
159
|
-
"citeproc_type" => Bolognese::Utils::CR_TO_CP_TRANSLATIONS[additional_type.to_s.underscore.camelcase] || Bolognese::Utils::SO_TO_CP_TRANSLATIONS[type] || "article",
|
160
|
-
"bibtex_type" => Bolognese::Utils::CR_TO_BIB_TRANSLATIONS[additional_type.to_s.underscore.camelcase] || Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[type] || "misc",
|
161
|
-
"ris_type" => Bolognese::Utils::CR_TO_RIS_TRANSLATIONS[additional_type.to_s.underscore.camelcase] || Bolognese::Utils::DC_TO_RIS_TRANSLATIONS[resource_type_general.to_s.dasherize] || "GEN",
|
162
|
-
"resource_type_general" => resource_type_general,
|
168
|
+
"types" => types,
|
163
169
|
"doi" => doi,
|
164
170
|
"alternate_identifiers" => alternate_identifiers,
|
165
171
|
"url" => options.fetch(:url, nil),
|
@@ -170,8 +176,7 @@ module Bolognese
|
|
170
176
|
"service_provider" => "DataCite",
|
171
177
|
"funding_references" => funding_references,
|
172
178
|
"dates" => dates,
|
173
|
-
"
|
174
|
-
"date_modified" => datacite_date(dates, "Updated"),
|
179
|
+
"publication_year" => meta.fetch("publicationYear", nil),
|
175
180
|
"description" => description,
|
176
181
|
"rights" => rights,
|
177
182
|
"version" => meta.fetch("version", nil),
|
@@ -200,11 +205,6 @@ module Bolognese
|
|
200
205
|
end
|
201
206
|
end
|
202
207
|
|
203
|
-
def datacite_date(dates, date_type)
|
204
|
-
dd = dates.find { |d| d["date_type"] == date_type } || {}
|
205
|
-
dd.fetch("date", nil)
|
206
|
-
end
|
207
|
-
|
208
208
|
def datacite_funding_reference(meta)
|
209
209
|
Array.wrap(meta.dig("fundingReferences", "fundingReference")).compact.map do |f|
|
210
210
|
funder_id = parse_attributes(f["funderIdentifier"])
|
@@ -38,11 +38,21 @@ module Bolognese
|
|
38
38
|
|
39
39
|
ris_type = meta.fetch("TY", nil) || "GEN"
|
40
40
|
type = RIS_TO_SO_TRANSLATIONS[ris_type] || "CreativeWork"
|
41
|
+
types = {
|
42
|
+
"type" => type,
|
43
|
+
"resource_type_general" => Metadata::SO_TO_DC_TRANSLATIONS[type],
|
44
|
+
"citeproc" => RIS_TO_CP_TRANSLATIONS[type] || "misc",
|
45
|
+
"ris" => ris_type
|
46
|
+
}.compact
|
41
47
|
|
42
48
|
doi = validate_doi(meta.fetch("DO", nil))
|
43
49
|
author = Array.wrap(meta.fetch("AU", nil)).map { |a| { "name" => a } }
|
44
50
|
date_parts = meta.fetch("PY", nil).to_s.split("/")
|
45
|
-
|
51
|
+
created_date_parts = meta.fetch("Y1", nil).to_s.split("/")
|
52
|
+
dates = []
|
53
|
+
dates << { "date" => get_date_from_parts(*date_parts), "date_type" => "Issued" } if meta.fetch("PY", nil).present?
|
54
|
+
dates << { "date" => get_date_from_parts(*created_date_parts), "date_type" => "Created" } if meta.fetch("Y1", nil).present?
|
55
|
+
publication_year = get_date_from_parts(*date_parts).to_s[0..3]
|
46
56
|
related_identifiers = if meta.fetch("T2", nil).present? && meta.fetch("SN", nil).present?
|
47
57
|
[{ "type" => "Periodical",
|
48
58
|
"id" => meta.fetch("SN", nil),
|
@@ -62,10 +72,7 @@ module Bolognese
|
|
62
72
|
state = doi.present? ? "findable" : "not_found"
|
63
73
|
|
64
74
|
{ "id" => normalize_doi(doi),
|
65
|
-
"
|
66
|
-
"citeproc_type" => RIS_TO_CP_TRANSLATIONS[type] || "misc",
|
67
|
-
"ris_type" => ris_type,
|
68
|
-
"resource_type_general" => Metadata::SO_TO_DC_TRANSLATIONS[type],
|
75
|
+
"types" => types,
|
69
76
|
"doi" => doi,
|
70
77
|
"url" => meta.fetch("UR", nil),
|
71
78
|
"title" => meta.fetch("T1", nil),
|
@@ -73,9 +80,8 @@ module Bolognese
|
|
73
80
|
"publisher" => meta.fetch("PB", "(:unav)"),
|
74
81
|
"periodical" => periodical,
|
75
82
|
"related_identifiers" => related_identifiers,
|
76
|
-
"
|
77
|
-
"
|
78
|
-
"date_accessed" => meta.fetch("Y2", nil),
|
83
|
+
"dates" => dates,
|
84
|
+
"publication_year" => publication_year,
|
79
85
|
"description" => meta.fetch("AB", nil).present? ? { "text" => sanitize(meta.fetch("AB")) } : nil,
|
80
86
|
"volume" => meta.fetch("VL", nil),
|
81
87
|
"issue" => meta.fetch("IS", nil),
|
@@ -52,6 +52,14 @@ module Bolognese
|
|
52
52
|
id = normalize_id(meta.fetch("@id", nil) || meta.fetch("identifier", nil))
|
53
53
|
type = meta.fetch("@type", nil) && meta.fetch("@type").camelcase
|
54
54
|
resource_type_general = Bolognese::Utils::SO_TO_DC_TRANSLATIONS[type]
|
55
|
+
types = {
|
56
|
+
"type" => type,
|
57
|
+
"resource_type_general" => resource_type_general,
|
58
|
+
"resource_type" => meta.fetch("additionalType", nil),
|
59
|
+
"citeproc" => Bolognese::Utils::SO_TO_CP_TRANSLATIONS[type] || "article-journal",
|
60
|
+
"bibtex" => Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[type] || "misc",
|
61
|
+
"ris" => Bolognese::Utils::SO_TO_RIS_TRANSLATIONS[resource_type_general.to_s.dasherize] || "GEN"
|
62
|
+
}.compact
|
55
63
|
authors = meta.fetch("author", nil) || meta.fetch("creator", nil)
|
56
64
|
author = get_authors(from_schema_org(Array.wrap(authors)))
|
57
65
|
editor = get_authors(from_schema_org(Array.wrap(meta.fetch("editor", nil))))
|
@@ -83,14 +91,18 @@ module Bolognese
|
|
83
91
|
"name" => parse_attributes(meta.fetch("license", nil), content: "name", first: true)
|
84
92
|
}
|
85
93
|
|
86
|
-
funding_references = from_schema_org(Array.wrap(meta.fetch("funder", nil)))
|
87
94
|
funding_references = Array.wrap(meta.fetch("funder", nil)).compact.map do |fr|
|
88
95
|
{
|
89
96
|
"funder_name" => fr["name"],
|
90
97
|
"funder_identifier" => fr["@id"],
|
91
98
|
"funder_identifier_type" => fr["@id"].to_s.start_with?("https://doi.org/10.13039") ? "Crossref Funder ID" : nil }.compact
|
92
99
|
end
|
93
|
-
|
100
|
+
dates = []
|
101
|
+
dates << { "date" => meta.fetch("datePublished"), "date_type" => "Issued" } if meta.fetch("datePublished", nil).present?
|
102
|
+
dates << { "date" => meta.fetch("dateCreated"), "date_type" => "Created" } if meta.fetch("dateCreated", nil).present?
|
103
|
+
dates << { "date" => meta.fetch("dateModified"), "date_type" => "Updated" } if meta.fetch("dateModified", nil).present?
|
104
|
+
publication_year = meta.fetch("datePublished")[0..3] if meta.fetch("datePublished", nil).present?
|
105
|
+
|
94
106
|
state = meta.present? ? "findable" : "not_found"
|
95
107
|
geo_location = Array.wrap(meta.fetch("spatialCoverage", nil)).map do |gl|
|
96
108
|
if gl.dig("geo", "box")
|
@@ -114,12 +126,7 @@ module Bolognese
|
|
114
126
|
end
|
115
127
|
|
116
128
|
{ "id" => id,
|
117
|
-
"
|
118
|
-
"additional_type" => meta.fetch("additionalType", nil),
|
119
|
-
"citeproc_type" => Bolognese::Utils::SO_TO_CP_TRANSLATIONS[type] || "article-journal",
|
120
|
-
"bibtex_type" => Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[type] || "misc",
|
121
|
-
"ris_type" => Bolognese::Utils::SO_TO_RIS_TRANSLATIONS[resource_type_general.to_s.dasherize] || "GEN",
|
122
|
-
"resource_type_general" => resource_type_general,
|
129
|
+
"types" => types,
|
123
130
|
"doi" => validate_doi(id),
|
124
131
|
"identifier" => identifier,
|
125
132
|
"alternate_identifiers" => alternate_identifiers,
|
@@ -134,9 +141,8 @@ module Bolognese
|
|
134
141
|
"service_provider" => parse_attributes(meta.fetch("provider", nil), content: "name", first: true),
|
135
142
|
"periodical" => periodical,
|
136
143
|
"related_identifiers" => related_identifiers,
|
137
|
-
"
|
138
|
-
"
|
139
|
-
"date_modified" => meta.fetch("dateModified", nil),
|
144
|
+
"publication_year" => publication_year,
|
145
|
+
"dates" => dates,
|
140
146
|
"description" => meta.fetch("description", nil).present? ? { "text" => sanitize(meta.fetch("description")) } : nil,
|
141
147
|
"rights" => rights,
|
142
148
|
"version" => meta.fetch("version", nil),
|
data/lib/bolognese/utils.rb
CHANGED
@@ -362,10 +362,10 @@ module Bolognese
|
|
362
362
|
"schema_org"
|
363
363
|
elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("@context") == ("https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld")
|
364
364
|
"codemeta"
|
365
|
-
elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("ris_type")
|
366
|
-
"crosscite"
|
367
365
|
elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("schema-version").to_s.start_with?("http://datacite.org/schema/kernel")
|
368
366
|
"datacite_json"
|
367
|
+
elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("types")
|
368
|
+
"crosscite"
|
369
369
|
elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("issued", "date-parts").present?
|
370
370
|
"citeproc"
|
371
371
|
end
|
@@ -376,14 +376,14 @@ module Bolognese
|
|
376
376
|
"crossref"
|
377
377
|
elsif Nokogiri::XML(string, nil, 'UTF-8', &:noblanks).collect_namespaces.find { |k, v| v.start_with?("http://datacite.org/schema/kernel") }
|
378
378
|
"datacite"
|
379
|
-
elsif Maremma.from_json(string).to_h.dig("ris_type").present?
|
380
|
-
"crosscite"
|
381
379
|
elsif Maremma.from_json(string).to_h.dig("@context").to_s.start_with?("http://schema.org", "https://schema.org")
|
382
380
|
"schema_org"
|
383
381
|
elsif Maremma.from_json(string).to_h.dig("@context") == ("https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld")
|
384
382
|
"codemeta"
|
385
|
-
elsif Maremma.from_json(string).to_h.dig("
|
383
|
+
elsif Maremma.from_json(string).to_h.dig("schema-version").to_s.start_with?("http://datacite.org/schema/kernel")
|
386
384
|
"datacite_json"
|
385
|
+
elsif Maremma.from_json(string).to_h.dig("types").present?
|
386
|
+
"crosscite"
|
387
387
|
elsif Maremma.from_json(string).to_h.dig("issued", "date-parts").present?
|
388
388
|
"citeproc"
|
389
389
|
elsif string.start_with?("TY - ")
|
@@ -524,6 +524,18 @@ module Bolognese
|
|
524
524
|
nil
|
525
525
|
end
|
526
526
|
|
527
|
+
def to_datacite_json(element)
|
528
|
+
Array.wrap(element).each do |e|
|
529
|
+
e.inject({}) {|h, (k,v)| h[k.dasherize] = v; h }
|
530
|
+
end.unwrap
|
531
|
+
end
|
532
|
+
|
533
|
+
def from_datacite_json(element)
|
534
|
+
Array.wrap(element).each do |e|
|
535
|
+
e.inject({}) {|h, (k,v)| h[k.underscore] = v; h }
|
536
|
+
end.unwrap
|
537
|
+
end
|
538
|
+
|
527
539
|
def to_schema_org(element)
|
528
540
|
mapping = { "type" => "@type", "id" => "@id", "title" => "name" }
|
529
541
|
|
@@ -799,6 +811,11 @@ module Bolognese
|
|
799
811
|
nil
|
800
812
|
end
|
801
813
|
|
814
|
+
def get_date(dates, date_type)
|
815
|
+
dd = dates.find { |d| d["date_type"] == date_type } || {}
|
816
|
+
dd.fetch("date", nil)
|
817
|
+
end
|
818
|
+
|
802
819
|
def jsonlint(json)
|
803
820
|
return ["No JSON provided"] unless json.present?
|
804
821
|
|
data/lib/bolognese/version.rb
CHANGED
@@ -8,7 +8,7 @@ module Bolognese
|
|
8
8
|
|
9
9
|
hsh = {
|
10
10
|
"@context" => id.present? ? "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld" : nil,
|
11
|
-
"@type" => type,
|
11
|
+
"@type" => types["type"],
|
12
12
|
"@id" => identifier,
|
13
13
|
"identifier" => identifier,
|
14
14
|
"codeRepository" => url,
|
@@ -17,8 +17,8 @@ module Bolognese
|
|
17
17
|
"description" => parse_attributes(description, content: "text", first: true),
|
18
18
|
"version" => version,
|
19
19
|
"tags" => keywords.to_s.split(", ").presence,
|
20
|
-
"datePublished" =>
|
21
|
-
"dateModified" =>
|
20
|
+
"datePublished" => get_date(dates, "Issued"),
|
21
|
+
"dateModified" => get_date(dates, "Updated"),
|
22
22
|
"publisher" => publisher
|
23
23
|
}.compact
|
24
24
|
JSON.pretty_generate hsh.presence
|
@@ -8,22 +8,15 @@ module Bolognese
|
|
8
8
|
"id" => identifier,
|
9
9
|
"doi" => doi,
|
10
10
|
"url" => url,
|
11
|
-
"
|
12
|
-
"additional_type" => additional_type,
|
13
|
-
"citeproc_type" => citeproc_type,
|
14
|
-
"bibtex_type" => bibtex_type,
|
15
|
-
"ris_type" => ris_type,
|
16
|
-
"resource_type_general" => resource_type_general,
|
17
|
-
"resource_type" => additional_type,
|
11
|
+
"types" => types,
|
18
12
|
"creator" => creator,
|
19
13
|
"title" => title,
|
20
14
|
"publisher" => publisher,
|
21
|
-
"
|
15
|
+
"periodical" => periodical,
|
22
16
|
"keywords" => keywords,
|
23
17
|
"contributor" => contributor,
|
24
18
|
"dates" => dates,
|
25
|
-
"
|
26
|
-
"date_modified" => date_modified,
|
19
|
+
"publication_year" => publication_year,
|
27
20
|
"language" => language,
|
28
21
|
"alternate_identifiers" => alternate_identifiers,
|
29
22
|
"size" => size,
|
@@ -11,25 +11,22 @@ module Bolognese
|
|
11
11
|
"creator" => creator,
|
12
12
|
"title" => title,
|
13
13
|
"publisher" => publisher,
|
14
|
-
"
|
15
|
-
"resource-type
|
16
|
-
"resource-type" => additional_type,
|
14
|
+
"resource-type-general" => types["resource_type_general"],
|
15
|
+
"resource-type" => types["resource_type"],
|
17
16
|
"subject" => keywords.present? ? keywords.split(", ") : nil,
|
18
17
|
"contributor" => contributor,
|
19
|
-
"
|
20
|
-
"date-modified" => date_modified,
|
21
|
-
"dates" => dates,
|
18
|
+
"dates" => to_datacite_json(dates),
|
22
19
|
"publication-year" => publication_year,
|
23
20
|
"language" => language,
|
24
21
|
"alternate-identifiers" => alternate_identifiers,
|
25
|
-
"related-identifiers" => related_identifiers,
|
22
|
+
"related-identifiers" => to_datacite_json(related_identifiers),
|
26
23
|
"size" => size,
|
27
24
|
"formats" => formats,
|
28
25
|
"version" => version,
|
29
26
|
"rights" => rights,
|
30
27
|
"description" => description,
|
31
28
|
"geo-location" => geo_location,
|
32
|
-
"funding-references" => funding_references,
|
29
|
+
"funding-references" => to_datacite_json(funding_references),
|
33
30
|
"schema-version" => schema_version,
|
34
31
|
"provider-id" => provider_id,
|
35
32
|
"client-id" => client_id,
|
@@ -88,9 +88,9 @@ module Bolognese
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def insert_publication_date(xml)
|
91
|
-
year, month, day = get_date_parts(
|
91
|
+
year, month, day = get_date_parts(get_date(dates, "Issued")).to_h.fetch("date-parts", []).first
|
92
92
|
|
93
|
-
xml.year(year, "iso-8601-date" =>
|
93
|
+
xml.year(year, "iso-8601-date" => get_date(dates, "Issued"))
|
94
94
|
xml.month(month.to_s.rjust(2, '0')) if month.present?
|
95
95
|
xml.day(day.to_s.rjust(2, '0')) if day.present?
|
96
96
|
end
|
@@ -125,7 +125,7 @@ module Bolognese
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def publication_type
|
128
|
-
{ 'publication-type' => Bolognese::Utils::CR_TO_JATS_TRANSLATIONS[
|
128
|
+
{ 'publication-type' => Bolognese::Utils::CR_TO_JATS_TRANSLATIONS[types["resource_type"]] || Bolognese::Utils::SO_TO_JATS_TRANSLATIONS[types["type"]] }.compact
|
129
129
|
end
|
130
130
|
end
|
131
131
|
end
|
@@ -5,11 +5,11 @@ module Bolognese
|
|
5
5
|
module SchemaOrgWriter
|
6
6
|
def schema_hsh
|
7
7
|
{ "@context" => identifier.present? ? "http://schema.org" : nil,
|
8
|
-
"@type" => type,
|
8
|
+
"@type" => types["type"],
|
9
9
|
"@id" => identifier,
|
10
10
|
"identifier" => to_schema_org_identifier(identifier, alternate_identifiers: alternate_identifiers),
|
11
11
|
"url" => url,
|
12
|
-
"additionalType" =>
|
12
|
+
"additionalType" => types["resource_type"],
|
13
13
|
"name" => parse_attributes(title, content: "text", first: true),
|
14
14
|
"author" => to_schema_org(creator),
|
15
15
|
"editor" => to_schema_org(editor),
|
@@ -20,9 +20,9 @@ module Bolognese
|
|
20
20
|
"inLanguage" => language,
|
21
21
|
"contentSize" => size,
|
22
22
|
"encodingFormat" => formats,
|
23
|
-
"dateCreated" =>
|
24
|
-
"datePublished" =>
|
25
|
-
"dateModified" =>
|
23
|
+
"dateCreated" => get_date(dates, "Created"),
|
24
|
+
"datePublished" => get_date(dates, "Issued"),
|
25
|
+
"dateModified" => get_date(dates, "Updated"),
|
26
26
|
"pageStart" => first_page,
|
27
27
|
"pageEnd" => last_page,
|
28
28
|
"spatialCoverage" => to_schema_org_spatial_coverage(geo_location),
|
@@ -35,8 +35,8 @@ module Bolognese
|
|
35
35
|
"@reverse" => reverse.presence,
|
36
36
|
"contentUrl" => content_url,
|
37
37
|
"schemaVersion" => schema_version,
|
38
|
-
"periodical" => (type != "Dataset") && periodical ? to_schema_org(periodical) : nil,
|
39
|
-
"includedInDataCatalog" => (type == "Dataset") && periodical ? to_schema_org(periodical) : nil,
|
38
|
+
"periodical" => (types["type"] != "Dataset") && periodical ? to_schema_org(periodical) : nil,
|
39
|
+
"includedInDataCatalog" => (types["type"] == "Dataset") && periodical ? to_schema_org(periodical) : nil,
|
40
40
|
"publisher" => publisher.present? ? { "@type" => "Organization", "name" => publisher } : nil,
|
41
41
|
"funder" => to_schema_org_funder(funding_references),
|
42
42
|
"provider" => service_provider.present? ? { "@type" => "Organization", "name" => service_provider } : nil
|
data/spec/datacite_utils_spec.rb
CHANGED
@@ -89,13 +89,14 @@ describe Bolognese::Metadata, vcr: true do
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
context "insert_dates" do
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
end
|
92
|
+
# context "insert_dates" do
|
93
|
+
# it "insert" do
|
94
|
+
# puts subject.dates.inspect
|
95
|
+
# xml = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') { |xml| subject.insert_dates(xml) }.to_xml
|
96
|
+
# response = Maremma.from_xml(xml)
|
97
|
+
# expect(response.dig("dates", "date")).to eq("dateType"=>"Issued", "__content__"=>"2011")
|
98
|
+
# end
|
99
|
+
# end
|
99
100
|
|
100
101
|
context "insert_subjects" do
|
101
102
|
it "insert" do
|
@@ -1,13 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"id": "https://doi.org/10.5281/zenodo.48440",
|
3
3
|
"doi": "10.5281/zenodo.48440",
|
4
|
-
"
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
"types":{
|
5
|
+
"type": "SoftwareSourceCode",
|
6
|
+
"resource_type_general": "Software",
|
7
|
+
"resource_type": "Software",
|
8
|
+
"citeproc": "other",
|
9
|
+
"bibtex": "misc",
|
10
|
+
"ris": "COMP"
|
11
|
+
},
|
11
12
|
"creator": {
|
12
13
|
"type": "Person",
|
13
14
|
"name": "Kristian Garza",
|
@@ -17,7 +18,11 @@
|
|
17
18
|
"title": "Analysis Tools for Crossover Experiment of UI using Choice Architecture",
|
18
19
|
"publisher": "Zenodo",
|
19
20
|
"keywords": ["choice architecture", "crossover experiment", "hci"],
|
20
|
-
"
|
21
|
+
"dates": {
|
22
|
+
"date": "2016-03-27",
|
23
|
+
"date-type": "Issued"
|
24
|
+
},
|
25
|
+
"publication_year": "2016",
|
21
26
|
"alternate_identifiers": {
|
22
27
|
"type": "URL",
|
23
28
|
"name": "http://zenodo.org/record/48440"
|