bolognese 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/bolognese/codemeta.rb +1 -1
- data/lib/bolognese/crossref.rb +1 -1
- data/lib/bolognese/datacite_utils.rb +8 -25
- data/lib/bolognese/metadata.rb +22 -1
- data/lib/bolognese/schema_org.rb +4 -2
- data/lib/bolognese/utils.rb +7 -6
- data/lib/bolognese/version.rb +1 -1
- data/spec/crossref_spec.rb +7 -5
- data/spec/schema_org_spec.rb +16 -7
- data/spec/utils_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 347331c05f3f9fcf8370202734e301b5147ab529
|
4
|
+
data.tar.gz: 9cdde1c401c80afc37c5caef0c21b7b43ccce10b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc95897ac4cb7c133a523e0ccf96c1be564a1e3ebe8c17349579d389953947a580329db91222720af96851fb392c2b3406c0825630a29c744b1363d4ff72fff6
|
7
|
+
data.tar.gz: 487ad70193f3e026691f57ce73a5a99ba1ee023235be1ef1a65698ae0bdba3c0d99c43265f1dbaf64c42374828b247d508379683023d13853999d92c03214bf9
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bolognese (0.8.
|
4
|
+
bolognese (0.8.2)
|
5
5
|
activesupport (~> 4.2, >= 4.2.5)
|
6
6
|
bibtex-ruby (~> 4.1)
|
7
7
|
builder (~> 3.2, >= 3.2.2)
|
@@ -64,7 +64,7 @@ GEM
|
|
64
64
|
namae (0.10.2)
|
65
65
|
nokogiri (1.6.8.1)
|
66
66
|
mini_portile2 (~> 2.1.0)
|
67
|
-
oj (2.18.
|
67
|
+
oj (2.18.2)
|
68
68
|
postrank-uri (1.0.18)
|
69
69
|
addressable (~> 2.3.0)
|
70
70
|
nokogiri (~> 1.6.1)
|
data/lib/bolognese/codemeta.rb
CHANGED
data/lib/bolognese/crossref.rb
CHANGED
@@ -157,7 +157,7 @@ module Bolognese
|
|
157
157
|
def license
|
158
158
|
access_indicator = Array.wrap(program_metadata).find { |m| m["name"] == "AccessIndicators" }
|
159
159
|
if access_indicator.present?
|
160
|
-
parse_attributes(access_indicator["license_ref"])
|
160
|
+
{ "url" => parse_attributes(access_indicator["license_ref"]) }
|
161
161
|
else
|
162
162
|
nil
|
163
163
|
end
|
@@ -1,27 +1,5 @@
|
|
1
1
|
module Bolognese
|
2
2
|
module DataciteUtils
|
3
|
-
|
4
|
-
SO_TO_DC_TRANSLATIONS = {
|
5
|
-
"Article" => "Text",
|
6
|
-
"AudioObject" => "Sound",
|
7
|
-
"Blog" => "Text",
|
8
|
-
"BlogPosting" => "Text",
|
9
|
-
"Collection" => "Collection",
|
10
|
-
"CreativeWork" => "Other",
|
11
|
-
"DataCatalog" => "Dataset",
|
12
|
-
"Dataset" => "Dataset",
|
13
|
-
"Event" => "Event",
|
14
|
-
"ImageObject" => "Image",
|
15
|
-
"Movie" => "Audiovisual",
|
16
|
-
"PublicationIssue" => "Text",
|
17
|
-
"ScholarlyArticle" => "Text",
|
18
|
-
"Service" => "Service",
|
19
|
-
"SoftwareSourceCode" => "Software",
|
20
|
-
"VideoObject" => "Audiovisual",
|
21
|
-
"WebPage" => "Text",
|
22
|
-
"WebSite" => "Text"
|
23
|
-
}
|
24
|
-
|
25
3
|
SCHEMA = File.expand_path("../../../resources/kernel-4.0/metadata.xsd", __FILE__)
|
26
4
|
|
27
5
|
def schema
|
@@ -116,7 +94,7 @@ module Bolognese
|
|
116
94
|
end
|
117
95
|
|
118
96
|
def resource_type
|
119
|
-
{ "resource_type_general" => SO_TO_DC_TRANSLATIONS[type] || "Other",
|
97
|
+
{ "resource_type_general" => Metadata::SO_TO_DC_TRANSLATIONS[type] || "Other",
|
120
98
|
"__content__" => additional_type || type }
|
121
99
|
end
|
122
100
|
|
@@ -186,7 +164,8 @@ module Bolognese
|
|
186
164
|
Array.wrap(related_identifier).map do |r|
|
187
165
|
{ "__content__" => r["id"],
|
188
166
|
"related_identifier_type" => validate_url(r["id"]),
|
189
|
-
"relation_type" => r["relationType"]
|
167
|
+
"relation_type" => r["relationType"],
|
168
|
+
"resource_type_general" => r["resourceTypeGeneral"] }
|
190
169
|
end
|
191
170
|
end
|
192
171
|
|
@@ -195,7 +174,11 @@ module Bolognese
|
|
195
174
|
|
196
175
|
xml.relatedIdentifiers do
|
197
176
|
rel_identifier.each do |related_identifier|
|
198
|
-
|
177
|
+
attributes = {
|
178
|
+
'relatedIdentifierType' => related_identifier["related_identifier_type"],
|
179
|
+
'relationType' => related_identifier["relation_type"],
|
180
|
+
'resourceTypeGeneral' => related_identifier["resource_type_general"] }.compact
|
181
|
+
xml.relatedIdentifier(related_identifier["__content__"], attributes)
|
199
182
|
end
|
200
183
|
end
|
201
184
|
end
|
data/lib/bolognese/metadata.rb
CHANGED
@@ -29,6 +29,27 @@ module Bolognese
|
|
29
29
|
"Other" => "CreativeWork"
|
30
30
|
}
|
31
31
|
|
32
|
+
SO_TO_DC_TRANSLATIONS = {
|
33
|
+
"Article" => "Text",
|
34
|
+
"AudioObject" => "Sound",
|
35
|
+
"Blog" => "Text",
|
36
|
+
"BlogPosting" => "Text",
|
37
|
+
"Collection" => "Collection",
|
38
|
+
"CreativeWork" => "Other",
|
39
|
+
"DataCatalog" => "Dataset",
|
40
|
+
"Dataset" => "Dataset",
|
41
|
+
"Event" => "Event",
|
42
|
+
"ImageObject" => "Image",
|
43
|
+
"Movie" => "Audiovisual",
|
44
|
+
"PublicationIssue" => "Text",
|
45
|
+
"ScholarlyArticle" => "Text",
|
46
|
+
"Service" => "Service",
|
47
|
+
"SoftwareSourceCode" => "Software",
|
48
|
+
"VideoObject" => "Audiovisual",
|
49
|
+
"WebPage" => "Text",
|
50
|
+
"WebSite" => "Text"
|
51
|
+
}
|
52
|
+
|
32
53
|
attr_reader :id, :raw, :provider, :schema_version, :license, :citation,
|
33
54
|
:additional_type, :alternate_name, :url, :version, :keywords, :editor,
|
34
55
|
:page_start, :page_end, :date_modified, :language, :spatial_coverage,
|
@@ -88,7 +109,7 @@ module Bolognese
|
|
88
109
|
"hasPart" => has_part,
|
89
110
|
"predecessor_of" => is_previous_version_of,
|
90
111
|
"successor_of" => is_new_version_of,
|
91
|
-
"citation" => references,
|
112
|
+
"citation" => Array.wrap(references).map { |r| r.except("relationType").merge("@type" => "CreativeWork") }.unwrap,
|
92
113
|
"@reverse" => reverse,
|
93
114
|
"schemaVersion" => schema_version,
|
94
115
|
"publisher" => { "@type" => "Organization", "name" => publisher },
|
data/lib/bolognese/schema_org.rb
CHANGED
@@ -119,11 +119,13 @@ module Bolognese
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def get_related_identifier(relation_type: nil)
|
122
|
-
normalize_ids(metadata.fetch(relation_type, nil),
|
122
|
+
normalize_ids(ids: metadata.fetch(relation_type, nil),
|
123
|
+
relation_type: SO_TO_DC_RELATION_TYPES[relation_type])
|
123
124
|
end
|
124
125
|
|
125
126
|
def get_reverse_related_identifier(relation_type: nil)
|
126
|
-
normalize_ids(metadata.dig("@reverse", relation_type),
|
127
|
+
normalize_ids(ids: metadata.dig("@reverse", relation_type),
|
128
|
+
relation_type: SO_TO_DC_RELATION_TYPES[relation_type])
|
127
129
|
end
|
128
130
|
|
129
131
|
def is_identical_to
|
data/lib/bolognese/utils.rb
CHANGED
@@ -114,12 +114,13 @@ module Bolognese
|
|
114
114
|
"http://orcid.org/" + Addressable::URI.encode(orcid)
|
115
115
|
end
|
116
116
|
|
117
|
-
def normalize_ids(
|
118
|
-
Array.wrap(
|
119
|
-
{ "id" => normalize_id(
|
120
|
-
"type" =>
|
121
|
-
"name" =>
|
122
|
-
"relationType" => relation_type
|
117
|
+
def normalize_ids(ids: nil, relation_type: "References")
|
118
|
+
Array.wrap(ids).map do |id|
|
119
|
+
{ "id" => normalize_id(id["@id"]),
|
120
|
+
"type" => id["@type"],
|
121
|
+
"name" => id["name"],
|
122
|
+
"relationType" => relation_type,
|
123
|
+
"resourceTypeGeneral" => id["resourceTypeGeneral"] || Metadata::SO_TO_DC_TRANSLATIONS[id["@type"]] }.compact
|
123
124
|
end.unwrap
|
124
125
|
end
|
125
126
|
|
data/lib/bolognese/version.rb
CHANGED
data/spec/crossref_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe Bolognese::Crossref, vcr: true do
|
|
14
14
|
expect(subject.resource_type_general).to eq("Text")
|
15
15
|
expect(subject.author.length).to eq(5)
|
16
16
|
expect(subject.author.first).to eq("type"=>"Person", "name"=>"Martial Sankar", "givenName"=>"Martial", "familyName"=>"Sankar")
|
17
|
-
expect(subject.license).to eq("http://creativecommons.org/licenses/by/3.0/")
|
17
|
+
expect(subject.license).to eq("url"=>"http://creativecommons.org/licenses/by/3.0/")
|
18
18
|
expect(subject.title).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
|
19
19
|
expect(subject.date_published).to eq("2014-02-11")
|
20
20
|
expect(subject.date_modified).to eq("2015-08-11T05:35:02Z")
|
@@ -43,7 +43,7 @@ describe Bolognese::Crossref, vcr: true do
|
|
43
43
|
expect(subject.author.first).to eq("type"=>"Person", "name"=>"Markus Ralser", "givenName"=>"Markus", "familyName"=>"Ralser")
|
44
44
|
expect(subject.editor).to eq("type"=>"Person", "name"=>"Guilhem Janbon", "givenName"=>"Guilhem", "familyName"=>"Janbon")
|
45
45
|
expect(subject.title).to eq("Triose Phosphate Isomerase Deficiency Is Caused by Altered Dimerization–Not Catalytic Inactivity–of the Mutant Enzymes")
|
46
|
-
expect(subject.license).to eq("http://creativecommons.org/licenses/by/4.0/")
|
46
|
+
expect(subject.license).to eq("url"=>"http://creativecommons.org/licenses/by/4.0/")
|
47
47
|
expect(subject.date_published).to eq("2006-12-20")
|
48
48
|
expect(subject.date_modified).to eq("2016-12-31T21:37:08Z")
|
49
49
|
expect(subject.page_start).to eq("e30")
|
@@ -79,7 +79,7 @@ describe Bolognese::Crossref, vcr: true do
|
|
79
79
|
expect(subject.additional_type).to eq("JournalArticle")
|
80
80
|
expect(subject.resource_type_general).to eq("Text")
|
81
81
|
expect(subject.author).to eq([{"type"=>"Person", "name"=>"A. Fenton", "givenName"=>"A.", "familyName"=>"Fenton"}, {"type"=>"Person", "name"=>"S. A. Rands", "givenName"=>"S. A.", "familyName"=>"Rands"}])
|
82
|
-
expect(subject.license).to eq("http://doi.wiley.com/10.1002/tdm_license_1")
|
82
|
+
expect(subject.license).to eq("url"=>"http://doi.wiley.com/10.1002/tdm_license_1")
|
83
83
|
expect(subject.title).to eq("THE IMPACT OF PARASITE MANIPULATION AND PREDATOR FORAGING BEHAVIOR ON PREDATOR–PREY COMMUNITIES")
|
84
84
|
expect(subject.date_published).to eq("2006-11")
|
85
85
|
expect(subject.date_modified).to eq("2016-10-04T17:20:17Z")
|
@@ -99,7 +99,7 @@ describe Bolognese::Crossref, vcr: true do
|
|
99
99
|
expect(subject.resource_type_general).to eq("Text")
|
100
100
|
expect(subject.author.length).to eq(7)
|
101
101
|
expect(subject.author[2]).to eq("type"=>"Person", "id"=>"http://orcid.org/0000-0003-2043-4925", "name"=>"Beatriz Hernandez", "givenName"=>"Beatriz", "familyName"=>"Hernandez")
|
102
|
-
expect(subject.license).to eq("http://creativecommons.org/licenses/by/3.0/")
|
102
|
+
expect(subject.license).to eq("url"=>"http://creativecommons.org/licenses/by/3.0/")
|
103
103
|
expect(subject.title).to eq("Delineating a Retesting Zone Using Receiver Operating Characteristic Analysis on Serial QuantiFERON Tuberculosis Test Results in US Healthcare Workers")
|
104
104
|
expect(subject.date_published).to eq("2012")
|
105
105
|
expect(subject.date_modified).to eq("2016-08-02T12:42:41Z")
|
@@ -152,7 +152,7 @@ describe Bolognese::Crossref, vcr: true do
|
|
152
152
|
expect(subject.resource_type_general).to eq("Text")
|
153
153
|
expect(subject.author.length).to eq(5)
|
154
154
|
expect(subject.author.last).to eq("type"=>"Person", "name"=>"Christian S Hardtke", "givenName"=>"Christian S", "familyName"=>"Hardtke")
|
155
|
-
expect(subject.license).to eq("http://creativecommons.org/licenses/by/3.0/")
|
155
|
+
expect(subject.license).to eq("url"=>"http://creativecommons.org/licenses/by/3.0/")
|
156
156
|
expect(subject.title).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
|
157
157
|
expect(subject.date_published).to eq("2014-02-11")
|
158
158
|
expect(subject.date_modified).to eq("2015-08-11T05:35:02Z")
|
@@ -169,6 +169,8 @@ describe Bolognese::Crossref, vcr: true do
|
|
169
169
|
expect(datacite.dig("resourceType", "resourceTypeGeneral")).to eq("Text")
|
170
170
|
expect(datacite.dig("titles", "title")).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
|
171
171
|
expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").count).to eq(27)
|
172
|
+
expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").first).to eq("relatedIdentifierType"=>"DOI", "relationType"=>"Cites", "__content__"=>"https://doi.org/10.1038/nature02100")
|
173
|
+
expect(datacite.dig("rightsList")).to eq("rights"=>{"rightsURI"=>"http://creativecommons.org/licenses/by/3.0/"})
|
172
174
|
expect(datacite.dig("fundingReferences", "fundingReference").count).to eq(4)
|
173
175
|
expect(datacite.dig("fundingReferences", "fundingReference").last).to eq("funderName"=>"University of Lausanne", "funderIdentifier"=>{"funderIdentifierType"=>"Crossref Funder ID", "__content__"=>"https://doi.org/10.13039/501100006390"})
|
174
176
|
end
|
data/spec/schema_org_spec.rb
CHANGED
@@ -18,8 +18,15 @@ describe Bolognese::SchemaOrg, vcr: true do
|
|
18
18
|
expect(subject.keywords).to eq("datacite, doi, metadata, featured")
|
19
19
|
expect(subject.date_published).to eq("2016-12-20")
|
20
20
|
expect(subject.date_modified).to eq("2016-12-20")
|
21
|
-
expect(subject.is_part_of).to eq("id"=>"https://doi.org/10.5438/0000-00ss", "type"=>"Blog", "name"=>"DataCite Blog", "relationType"=>"IsPartOf")
|
22
|
-
expect(subject.references).to eq([{"id"=>"https://doi.org/10.5438/0012",
|
21
|
+
expect(subject.is_part_of).to eq("id"=>"https://doi.org/10.5438/0000-00ss", "type"=>"Blog", "name"=>"DataCite Blog", "relationType"=>"IsPartOf", "resourceTypeGeneral" => "Text")
|
22
|
+
expect(subject.references).to eq([{"id"=>"https://doi.org/10.5438/0012",
|
23
|
+
"type"=>"CreativeWork",
|
24
|
+
"relationType"=>"References",
|
25
|
+
"resourceTypeGeneral"=>"Other"},
|
26
|
+
{"id"=>"https://doi.org/10.5438/55e5-t5c0",
|
27
|
+
"type"=>"CreativeWork",
|
28
|
+
"relationType"=>"References",
|
29
|
+
"resourceTypeGeneral"=>"Other"}])
|
23
30
|
expect(subject.publisher).to eq("DataCite")
|
24
31
|
end
|
25
32
|
|
@@ -51,13 +58,15 @@ describe Bolognese::SchemaOrg, vcr: true do
|
|
51
58
|
expect(subject.keywords).to eq("datacite, doi, metadata, featured")
|
52
59
|
expect(subject.date_published).to eq("2016-12-20")
|
53
60
|
expect(subject.date_modified).to eq("2016-12-20")
|
54
|
-
expect(subject.is_part_of).to eq("id"=>"https://doi.org/10.5438/0000-00ss", "type"=>"Blog", "name"=>"DataCite Blog", "relationType"=>"IsPartOf")
|
61
|
+
expect(subject.is_part_of).to eq("id"=>"https://doi.org/10.5438/0000-00ss", "type"=>"Blog", "name"=>"DataCite Blog", "relationType"=>"IsPartOf", "resourceTypeGeneral"=>"Text")
|
55
62
|
expect(subject.references).to eq([{"id"=>"https://doi.org/10.5438/0012",
|
56
63
|
"type"=>"CreativeWork",
|
57
|
-
"relationType"=>"References"
|
64
|
+
"relationType"=>"References",
|
65
|
+
"resourceTypeGeneral"=>"Other"},
|
58
66
|
{"id"=>"https://doi.org/10.5438/55e5-t5c0",
|
59
|
-
|
60
|
-
|
67
|
+
"type"=>"CreativeWork",
|
68
|
+
"relationType"=>"References",
|
69
|
+
"resourceTypeGeneral"=>"Other"}])
|
61
70
|
expect(subject.publisher).to eq("DataCite")
|
62
71
|
end
|
63
72
|
end
|
@@ -67,7 +76,7 @@ describe Bolognese::SchemaOrg, vcr: true do
|
|
67
76
|
datacite = Maremma.from_xml(subject.datacite).fetch("resource", {})
|
68
77
|
expect(datacite.dig("titles", "title")).to eq("Eating your own Dog Food")
|
69
78
|
expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").count).to eq(3)
|
70
|
-
expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").first).to eq("relatedIdentifierType"=>"DOI", "relationType"=>"IsPartOf", "__content__"=>"https://doi.org/10.5438/0000-00ss")
|
79
|
+
expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").first).to eq("relatedIdentifierType"=>"DOI", "relationType"=>"IsPartOf", "resourceTypeGeneral"=>"Text", "__content__"=>"https://doi.org/10.5438/0000-00ss")
|
71
80
|
end
|
72
81
|
end
|
73
82
|
|
data/spec/utils_spec.rb
CHANGED
@@ -68,14 +68,14 @@ describe Bolognese::Crossref, vcr: true do
|
|
68
68
|
context "normalize ids" do
|
69
69
|
it "doi" do
|
70
70
|
ids = [{"@type"=>"CreativeWork", "@id"=>"https://doi.org/10.5438/0012"}, {"@type"=>"CreativeWork", "@id"=>"https://doi.org/10.5438/55E5-T5C0"}]
|
71
|
-
response = subject.normalize_ids(ids)
|
72
|
-
expect(response).to eq([{"id"=>"https://doi.org/10.5438/0012", "type"=>"CreativeWork", "relationType"=>"References"}, {"id"=>"https://doi.org/10.5438/55e5-t5c0", "type"=>"CreativeWork", "relationType"=>"References"}])
|
71
|
+
response = subject.normalize_ids(ids: ids)
|
72
|
+
expect(response).to eq([{"id"=>"https://doi.org/10.5438/0012", "type"=>"CreativeWork", "relationType"=>"References", "resourceTypeGeneral" => "Other"}, {"id"=>"https://doi.org/10.5438/55e5-t5c0", "type"=>"CreativeWork", "relationType"=>"References", "resourceTypeGeneral" => "Other"}])
|
73
73
|
end
|
74
74
|
|
75
75
|
it "url" do
|
76
76
|
ids = [{"@type"=>"CreativeWork", "@id"=>"https://blog.datacite.org/eating-your-own-dog-food/"}]
|
77
|
-
response = subject.normalize_ids(ids)
|
78
|
-
expect(response).to eq("id"=>"https://blog.datacite.org/eating-your-own-dog-food", "type"=>"CreativeWork", "relationType"=>"References")
|
77
|
+
response = subject.normalize_ids(ids: ids)
|
78
|
+
expect(response).to eq("id"=>"https://blog.datacite.org/eating-your-own-dog-food", "resourceTypeGeneral" => "Other", "type"=>"CreativeWork", "relationType"=>"References")
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bolognese
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Fenner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: maremma
|