bolognese 0.5 → 0.5.1
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/author_utils.rb +6 -8
- data/lib/bolognese/crossref.rb +14 -10
- data/lib/bolognese/datacite.rb +15 -2
- data/lib/bolognese/datacite_utils.rb +1 -2
- data/lib/bolognese/metadata.rb +14 -0
- data/lib/bolognese/schema_org.rb +4 -0
- data/lib/bolognese/version.rb +1 -1
- data/spec/crossref_spec.rb +10 -1
- data/spec/datacite_spec.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: deb650206d9feee61ce70231a6e0d847dd7cb624
|
4
|
+
data.tar.gz: 129088964177fa28dd209875529bf3d502163bac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28d10eae1a9a8adc8c4e53f191d2f1cf8218327e6e144103d73cf9d4e38f2dff371d2f8a40ae6db9b40437ecc873fcce5054df05b155d297457dae2d2c4fe236
|
7
|
+
data.tar.gz: 6eb9ce2ba440d28822a4df0dccf9ade48d4bdee95d43dd034f1b2134e3ad8289b8998a49dd2a29189648e649e6d87894263e7a36377e256159a04811781a8db9
|
data/Gemfile.lock
CHANGED
@@ -12,7 +12,7 @@ module Bolognese
|
|
12
12
|
author = cleanup_author(author)
|
13
13
|
names = Namae.parse(author)
|
14
14
|
|
15
|
-
if names.blank? || is_personal_name?(author)
|
15
|
+
if names.blank? || !is_personal_name?(author)
|
16
16
|
{ "@type" => "Agent",
|
17
17
|
"@id" => orcid,
|
18
18
|
"Name" => author }.compact
|
@@ -48,17 +48,15 @@ module Bolognese
|
|
48
48
|
Array(authors).map { |author| get_one_author(author) }
|
49
49
|
end
|
50
50
|
|
51
|
-
#
|
51
|
+
# parse nameIdentifier from DataCite
|
52
52
|
def get_name_identifier(author)
|
53
53
|
name_identifier = author.dig("nameIdentifier", "text")
|
54
54
|
name_identifier = validate_orcid(name_identifier)
|
55
|
-
|
56
55
|
name_identifier_scheme = author.dig("nameIdentifier", "nameIdentifierScheme") || "ORCID"
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
56
|
+
|
57
|
+
return nil if name_identifier.blank? || name_identifier_scheme.upcase != "ORCID"
|
58
|
+
|
59
|
+
"http://orcid.org/" + name_identifier
|
62
60
|
end
|
63
61
|
end
|
64
62
|
end
|
data/lib/bolognese/crossref.rb
CHANGED
@@ -4,10 +4,10 @@ module Bolognese
|
|
4
4
|
# CrossRef types from https://api.crossref.org/types
|
5
5
|
CR_TO_SO_TRANSLATIONS = {
|
6
6
|
"Proceedings" => nil,
|
7
|
-
"ReferenceBook" =>
|
8
|
-
"JournalIssue" =>
|
7
|
+
"ReferenceBook" => "Book",
|
8
|
+
"JournalIssue" => "PublicationIssue",
|
9
9
|
"ProceedingsArticle" => nil,
|
10
|
-
"Other" =>
|
10
|
+
"Other" => "CreativeWork",
|
11
11
|
"Dissertation" => "Thesis",
|
12
12
|
"Dataset" => "Dataset",
|
13
13
|
"EditedBook" => "Book",
|
@@ -24,11 +24,11 @@ module Bolognese
|
|
24
24
|
"BookChapter" => "Chapter",
|
25
25
|
"StandardSeries" => nil,
|
26
26
|
"Monograph" => "Book",
|
27
|
-
"Component" =>
|
27
|
+
"Component" => "CreativeWork",
|
28
28
|
"ReferenceEntry" => nil,
|
29
|
-
"JournalVolume" =>
|
29
|
+
"JournalVolume" => "PublicationVolume",
|
30
30
|
"BookSet" => nil,
|
31
|
-
"PostedContent" =>
|
31
|
+
"PostedContent" => "ScholarlyArticle"
|
32
32
|
}
|
33
33
|
|
34
34
|
def initialize(id: nil, string: nil)
|
@@ -80,6 +80,14 @@ module Bolognese
|
|
80
80
|
bibliographic_metadata.dig("crossmark", "custom_metadata", "program") || {}
|
81
81
|
end
|
82
82
|
|
83
|
+
def resource_type_general
|
84
|
+
SO_TO_DC_TRANSLATIONS[type]
|
85
|
+
end
|
86
|
+
|
87
|
+
def type
|
88
|
+
CR_TO_SO_TRANSLATIONS[additional_type] || "ScholarlyArticle"
|
89
|
+
end
|
90
|
+
|
83
91
|
def additional_type
|
84
92
|
if metadata.dig("crossref", "journal").present?
|
85
93
|
metadata.dig("crossref", "journal").keys.last.camelize
|
@@ -88,10 +96,6 @@ module Bolognese
|
|
88
96
|
end
|
89
97
|
end
|
90
98
|
|
91
|
-
def type
|
92
|
-
CR_TO_SO_TRANSLATIONS[additional_type] || "CreativeWork"
|
93
|
-
end
|
94
|
-
|
95
99
|
def name
|
96
100
|
parse_attribute(bibliographic_metadata.dig("titles", "title"))
|
97
101
|
end
|
data/lib/bolognese/datacite.rb
CHANGED
@@ -48,9 +48,12 @@ module Bolognese
|
|
48
48
|
normalize_doi(doi)
|
49
49
|
end
|
50
50
|
|
51
|
+
def resource_type_general
|
52
|
+
metadata.dig("resourceType", "resourceTypeGeneral")
|
53
|
+
end
|
54
|
+
|
51
55
|
def type
|
52
|
-
|
53
|
-
DC_TO_SO_TRANSLATIONS[k.to_s.dasherize] || "CreativeWork"
|
56
|
+
DC_TO_SO_TRANSLATIONS[resource_type_general.to_s.dasherize] || "CreativeWork"
|
54
57
|
end
|
55
58
|
|
56
59
|
def additional_type
|
@@ -103,6 +106,8 @@ module Bolognese
|
|
103
106
|
Array.wrap(metadata.dig("dates", "date"))
|
104
107
|
end
|
105
108
|
|
109
|
+
#Accepted Available Copyrighted Collected Created Issued Submitted Updated Valid
|
110
|
+
|
106
111
|
def date(date_type)
|
107
112
|
dd = dates.find { |d| d["dateType"] == date_type } || {}
|
108
113
|
dd.fetch("text", nil)
|
@@ -120,6 +125,14 @@ module Bolognese
|
|
120
125
|
date("Updated")
|
121
126
|
end
|
122
127
|
|
128
|
+
def language
|
129
|
+
metadata.fetch("language", nil)
|
130
|
+
end
|
131
|
+
|
132
|
+
def spatial_coverage
|
133
|
+
|
134
|
+
end
|
135
|
+
|
123
136
|
def related_identifiers(relation_type)
|
124
137
|
Array(metadata.dig("relatedIdentifiers", "relatedIdentifier"))
|
125
138
|
.select { |r| relation_type.split(" ").include?(r["relationType"]) && %w(DOI URL).include?(r["relatedIdentifierType"]) }
|
@@ -28,7 +28,7 @@ module Bolognese
|
|
28
28
|
"http://creativecommons.org/licenses/by/4.0/" => "Creative Commons Attribution 4.0 (CC-BY 4.0)",
|
29
29
|
"http://creativecommons.org/licenses/by-nc/4.0/" => "Creative Commons Attribution Noncommercial 4.0 (CC-BY-NC 4.0)",
|
30
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
|
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
32
|
}
|
33
33
|
|
34
34
|
SCHEMA = File.expand_path("../../../resources/kernel-4.0/metadata.xsd", __FILE__)
|
@@ -230,4 +230,3 @@ module Bolognese
|
|
230
230
|
end
|
231
231
|
end
|
232
232
|
end
|
233
|
-
|
data/lib/bolognese/metadata.rb
CHANGED
@@ -48,6 +48,18 @@ module Bolognese
|
|
48
48
|
|
49
49
|
end
|
50
50
|
|
51
|
+
def contributor
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
def language
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
def spatial_coverage
|
60
|
+
|
61
|
+
end
|
62
|
+
|
51
63
|
def as_schema_org
|
52
64
|
{ "@context" => "http://schema.org",
|
53
65
|
"@type" => type,
|
@@ -62,11 +74,13 @@ module Bolognese
|
|
62
74
|
"license" => license,
|
63
75
|
"version" => version,
|
64
76
|
"keywords" => keywords,
|
77
|
+
"language" => language,
|
65
78
|
"dateCreated" => date_created,
|
66
79
|
"datePublished" => date_published,
|
67
80
|
"dateModified" => date_modified,
|
68
81
|
"pageStart" => page_start,
|
69
82
|
"pageEnd" => page_end,
|
83
|
+
"spatialCoverage" => spatial_coverage,
|
70
84
|
"isPartOf" => is_part_of,
|
71
85
|
"hasPart" => has_part,
|
72
86
|
"citation" => citation,
|
data/lib/bolognese/schema_org.rb
CHANGED
data/lib/bolognese/version.rb
CHANGED
data/spec/crossref_spec.rb
CHANGED
@@ -10,6 +10,7 @@ describe Bolognese::Crossref, vcr: true do
|
|
10
10
|
expect(subject.id).to eq("https://doi.org/10.7554/elife.01567")
|
11
11
|
expect(subject.type).to eq("ScholarlyArticle")
|
12
12
|
expect(subject.additional_type).to eq("JournalArticle")
|
13
|
+
expect(subject.resource_type_general).to eq("Text")
|
13
14
|
expect(subject.author).to eq([{"@type"=>"Person", "givenName"=>"Martial", "familyName"=>"Sankar"},
|
14
15
|
{"@type"=>"Person", "givenName"=>"Kaisa", "familyName"=>"Nieminen"},
|
15
16
|
{"@type"=>"Person", "givenName"=>"Laura", "familyName"=>"Ragni"},
|
@@ -31,6 +32,7 @@ describe Bolognese::Crossref, vcr: true do
|
|
31
32
|
expect(subject.id).to eq(id)
|
32
33
|
expect(subject.type).to eq("ScholarlyArticle")
|
33
34
|
expect(subject.additional_type).to eq("JournalArticle")
|
35
|
+
expect(subject.resource_type_general).to eq("Text")
|
34
36
|
expect(subject.author).to eq([{"@type"=>"Person", "givenName"=>"Markus", "familyName"=>"Ralser"},
|
35
37
|
{"@type"=>"Person", "givenName"=>"Gino", "familyName"=>"Heeren"},
|
36
38
|
{"@type"=>"Person", "givenName"=>"Michael", "familyName"=>"Breitenbach"},
|
@@ -50,8 +52,9 @@ describe Bolognese::Crossref, vcr: true do
|
|
50
52
|
id = "https://doi.org/10.1101/097196"
|
51
53
|
subject = Bolognese::Crossref.new(id: id)
|
52
54
|
expect(subject.id).to eq(id)
|
53
|
-
expect(subject.type).to eq("
|
55
|
+
expect(subject.type).to eq("ScholarlyArticle")
|
54
56
|
expect(subject.additional_type).to eq("PostedContent")
|
57
|
+
expect(subject.resource_type_general).to eq("Text")
|
55
58
|
expect(subject.author.count).to eq(10)
|
56
59
|
expect(subject.author.last).to eq("@type"=>"Person", "@id"=>"http://orcid.org/0000-0003-4060-7360", "givenName"=>"Timothy", "familyName"=>"Clark")
|
57
60
|
expect(subject.name).to eq("A Data Citation Roadmap for Scholarly Data Repositories")
|
@@ -69,6 +72,7 @@ describe Bolognese::Crossref, vcr: true do
|
|
69
72
|
expect(subject.id).to eq("https://doi.org/10.1890/0012-9658(2006)87%5B2832:tiopma%5D2.0.co;2")
|
70
73
|
expect(subject.type).to eq("ScholarlyArticle")
|
71
74
|
expect(subject.additional_type).to eq("JournalArticle")
|
75
|
+
expect(subject.resource_type_general).to eq("Text")
|
72
76
|
expect(subject.author).to eq([{"@type"=>"Person", "givenName"=>"A.", "familyName"=>"Fenton"}, {"@type"=>"Person", "givenName"=>"S. A.", "familyName"=>"Rands"}])
|
73
77
|
expect(subject.license).to eq("http://doi.wiley.com/10.1002/tdm_license_1")
|
74
78
|
expect(subject.name).to eq("THE IMPACT OF PARASITE MANIPULATION AND PREDATOR FORAGING BEHAVIOR ON PREDATOR–PREY COMMUNITIES")
|
@@ -86,6 +90,7 @@ describe Bolognese::Crossref, vcr: true do
|
|
86
90
|
expect(subject.id).to eq("https://doi.org/10.1155/2012/291294")
|
87
91
|
expect(subject.type).to eq("ScholarlyArticle")
|
88
92
|
expect(subject.additional_type).to eq("JournalArticle")
|
93
|
+
expect(subject.resource_type_general).to eq("Text")
|
89
94
|
expect(subject.author).to eq([{"@type"=>"Person", "givenName"=>"Wendy", "familyName"=>"Thanassi"},
|
90
95
|
{"@type"=>"Person", "givenName"=>"Art", "familyName"=>"Noda"},
|
91
96
|
{"@type"=>"Person",
|
@@ -112,6 +117,7 @@ describe Bolognese::Crossref, vcr: true do
|
|
112
117
|
expect(subject.id).to eq(id)
|
113
118
|
expect(subject.type).to eq("ScholarlyArticle")
|
114
119
|
expect(subject.additional_type).to eq("JournalArticle")
|
120
|
+
expect(subject.resource_type_general).to eq("Text")
|
115
121
|
expect(subject.author).to eq([{"@type"=>"Person", "givenName"=>"Sarah E.", "familyName"=>"Beck"},
|
116
122
|
{"@type"=>"Person", "givenName"=>"Suzanne E.", "familyName"=>"Queen"},
|
117
123
|
{"@type"=>"Person", "givenName"=>"Kenneth W.", "familyName"=>"Witwer"},
|
@@ -151,6 +157,7 @@ describe Bolognese::Crossref, vcr: true do
|
|
151
157
|
expect(subject.id).to eq("https://doi.org/10.7554/elife.01567")
|
152
158
|
expect(subject.type).to eq("ScholarlyArticle")
|
153
159
|
expect(subject.additional_type).to eq("JournalArticle")
|
160
|
+
expect(subject.resource_type_general).to eq("Text")
|
154
161
|
expect(subject.author).to eq([{"@type"=>"Person", "givenName"=>"Martial", "familyName"=>"Sankar"},
|
155
162
|
{"@type"=>"Person", "givenName"=>"Kaisa", "familyName"=>"Nieminen"},
|
156
163
|
{"@type"=>"Person", "givenName"=>"Laura", "familyName"=>"Ragni"},
|
@@ -171,6 +178,7 @@ describe Bolognese::Crossref, vcr: true do
|
|
171
178
|
it "with data citation" do
|
172
179
|
expect(subject.validation_errors).to be_empty
|
173
180
|
datacite = Maremma.from_xml(subject.as_datacite).fetch("resource", {})
|
181
|
+
expect(datacite.dig("resourceType", "resourceTypeGeneral")).to eq("Text")
|
174
182
|
expect(datacite.dig("titles", "title")).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
|
175
183
|
expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").count).to eq(25)
|
176
184
|
end
|
@@ -180,6 +188,7 @@ describe Bolognese::Crossref, vcr: true do
|
|
180
188
|
subject = Bolognese::Crossref.new(id: id)
|
181
189
|
expect(subject.validation_errors).to be_empty
|
182
190
|
datacite = Maremma.from_xml(subject.as_datacite).fetch("resource", {})
|
191
|
+
expect(datacite.dig("resourceType", "resourceTypeGeneral")).to eq("Text")
|
183
192
|
expect(datacite.dig("creators", "creator").count).to eq(7)
|
184
193
|
expect(datacite.dig("creators", "creator").first).to eq("creatorName"=>"Thanassi, Wendy", "givenName"=>"Wendy", "familyName"=>"Thanassi")
|
185
194
|
end
|
data/spec/datacite_spec.rb
CHANGED
@@ -10,6 +10,7 @@ describe Bolognese::Datacite, vcr: true do
|
|
10
10
|
expect(subject.id).to eq("https://doi.org/10.5061/dryad.8515")
|
11
11
|
expect(subject.type).to eq("Dataset")
|
12
12
|
expect(subject.additional_type).to eq("DataPackage")
|
13
|
+
expect(subject.resource_type_general).to eq("Dataset")
|
13
14
|
expect(subject.author).to eq([{"@type"=>"Person", "givenName"=>"Benjamin", "familyName"=>"Ollomo"},
|
14
15
|
{"@type"=>"Person", "givenName"=>"Patrick", "familyName"=>"Durand"},
|
15
16
|
{"@type"=>"Person", "givenName"=>"Franck", "familyName"=>"Prugnolle"},
|
@@ -35,6 +36,7 @@ describe Bolognese::Datacite, vcr: true do
|
|
35
36
|
expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
|
36
37
|
expect(subject.type).to eq("ScholarlyArticle")
|
37
38
|
expect(subject.additional_type).to eq("BlogPosting")
|
39
|
+
expect(subject.resource_type_general).to eq("Text")
|
38
40
|
expect(subject.author).to eq([{"@type"=>"Person", "@id"=>"http://orcid.org/0000-0003-1419-2405", "givenName"=>"Martin", "familyName"=>"Fenner"}])
|
39
41
|
expect(subject.name).to eq("Eating your own Dog Food")
|
40
42
|
expect(subject.alternate_name).to eq("MS-49-3632-5083")
|
@@ -54,6 +56,7 @@ describe Bolognese::Datacite, vcr: true do
|
|
54
56
|
expect(subject.id).to eq("https://doi.org/10.4230/lipics.tqc.2013.93")
|
55
57
|
expect(subject.type).to eq("ScholarlyArticle")
|
56
58
|
expect(subject.additional_type).to eq("ConferencePaper")
|
59
|
+
expect(subject.resource_type_general).to eq("Text")
|
57
60
|
expect(subject.author).to eq([{"@type"=>"Person", "givenName"=>"Nathaniel", "familyName"=>"Johnston"}])
|
58
61
|
expect(subject.name).to eq("The Minimum Size of Qubit Unextendible Product Bases")
|
59
62
|
expect(subject.description).to start_with("We investigate the problem of constructing unextendible product bases in the qubit case")
|
@@ -77,6 +80,7 @@ describe Bolognese::Datacite, vcr: true do
|
|
77
80
|
expect(subject.id).to eq("https://doi.org/10.5061/dryad.8515")
|
78
81
|
expect(subject.type).to eq("Dataset")
|
79
82
|
expect(subject.additional_type).to eq("DataPackage")
|
83
|
+
expect(subject.resource_type_general).to eq("Dataset")
|
80
84
|
expect(subject.author).to eq([{"@type"=>"Person", "givenName"=>"Benjamin", "familyName"=>"Ollomo"},
|
81
85
|
{"@type"=>"Person", "givenName"=>"Patrick", "familyName"=>"Durand"},
|
82
86
|
{"@type"=>"Person", "givenName"=>"Franck", "familyName"=>"Prugnolle"},
|