bolognese 0.9.14 → 0.9.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f212a65dde0f61b06563dba2fea86f553d31b2af
4
- data.tar.gz: 360a495bd4dcab4250199e9e55f71e52d6cfa29a
3
+ metadata.gz: cd64adf0b946033b548a03ccde85d5d9c554bd01
4
+ data.tar.gz: 442baadbc2f9f39f3c8d8bef4fc0d985f6388fd7
5
5
  SHA512:
6
- metadata.gz: 7fc398df17eb6b6ca4255eeaf386beb5d62141dbabc5b4c7b78ce9337be4dbb140af3ec693059cc7b3eaf5c36757399829bccf16f586a967773a5e9ce9013568
7
- data.tar.gz: 3839163d457f89cafe74e4fcb6570ee8c71a7045d9bc1fa92a144f570554548ed99016605ede37971d151e14a35d7766abfcffd4c608d6c93b45a89ef22efda7
6
+ metadata.gz: d993bd5e533833f8405ab4b76611d84c06ea4d700783ce65bca967148a7dd7fb3b69dae3b5c562e7603c89f0e0834d991c5cdbaa3c402e521daba7c58b00d07b
7
+ data.tar.gz: 69c755064916c60c16afc187c55bf29c2b24128ee8074e9439bc6ddc31d276dce50b9763a0f22716b4a5a104c4106adb73eb39273120429b75c083cfd23cd65f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bolognese (0.9.14)
4
+ bolognese (0.9.15)
5
5
  activesupport (>= 4.2.5, < 6)
6
6
  benchmark_methods (~> 0.7)
7
7
  bibtex-ruby (~> 4.1)
@@ -34,11 +34,20 @@ module Bolognese
34
34
  names = Namae.parse(name)
35
35
  parsed_name = names.first
36
36
 
37
+ if parsed_name.present?
38
+ given_name = parsed_name.given
39
+ family_name = parsed_name.family
40
+ name = [given_name, family_name].join(" ")
41
+ else
42
+ given_name = nil
43
+ family_name = nil
44
+ end
45
+
37
46
  { "type" => "Person",
38
47
  "id" => id,
39
- "name" => [parsed_name.given, parsed_name.family].join(" "),
40
- "givenName" => parsed_name.given,
41
- "familyName" => parsed_name.family }.compact
48
+ "name" => name,
49
+ "givenName" => given_name,
50
+ "familyName" => family_name }.compact
42
51
  else
43
52
  { "type" => type, "name" => name }.compact
44
53
  end
@@ -166,9 +166,7 @@ module Bolognese
166
166
  Array.wrap(related_identifier).map do |r|
167
167
  { "__content__" => r["id"] || r["issn"],
168
168
  "related_identifier_type" => r["issn"].present? ? "ISSN" : validate_url(r["id"]),
169
- "relation_type" => r["relationType"],
170
- "resource_type_general" => r["resourceTypeGeneral"] || "Other",
171
- "title" => r["title"] }.compact
169
+ "relation_type" => r["relationType"] }.compact
172
170
  end
173
171
  end
174
172
 
@@ -179,9 +177,7 @@ module Bolognese
179
177
  rel_identifier.each do |related_identifier|
180
178
  attributes = {
181
179
  'relatedIdentifierType' => related_identifier["related_identifier_type"],
182
- 'relationType' => related_identifier["relation_type"],
183
- 'resourceTypeGeneral' => related_identifier["resource_type_general"],
184
- 'title' => related_identifier["title"] }.compact
180
+ 'relationType' => related_identifier["relation_type"] }.compact
185
181
  xml.relatedIdentifier(related_identifier["__content__"], attributes)
186
182
  end
187
183
  end
@@ -386,7 +386,8 @@ module Bolognese
386
386
  Array.wrap(element).map do |a|
387
387
  a["@type"] = a["type"]
388
388
  a["@id"] = a["id"]
389
- a.except("type", "id").compact
389
+ a["name"] = a["title"] if a["title"].present?
390
+ a.except("type", "id", "title").compact
390
391
  end.unwrap
391
392
  end
392
393
 
@@ -1,3 +1,3 @@
1
1
  module Bolognese
2
- VERSION = "0.9.14"
2
+ VERSION = "0.9.15"
3
3
  end
@@ -11,7 +11,7 @@ module Bolognese
11
11
  "name" => name,
12
12
  "alternateName" => alternate_name,
13
13
  "author" => to_schema_org(author),
14
- "editor" => editor,
14
+ "editor" => to_schema_org(editor),
15
15
  "description" => Array.wrap(description).map { |d| d["text"] }.compact.unwrap,
16
16
  "license" => Array.wrap(license).map { |l| l["id"] }.compact.unwrap,
17
17
  "version" => version,
@@ -24,7 +24,7 @@ module Bolognese
24
24
  "pagination" => pagination,
25
25
  "spatialCoverage" => spatial_coverage,
26
26
  "sameAs" => same_as,
27
- "isPartOf" => is_part_of.present? ? is_part_of.merge("name" => is_part_of["title"]) : nil,
27
+ "isPartOf" => is_part_of.present? ? to_schema_org(is_part_of) : nil,
28
28
  "hasPart" => has_part,
29
29
  "predecessor_of" => is_previous_version_of,
30
30
  "successor_of" => is_new_version_of,
@@ -128,6 +128,15 @@ describe Bolognese::Metadata, vcr: true do
128
128
  response = subject.get_one_author(author)
129
129
  expect(response).to eq("type"=>"Organization", "name"=>"University Of California, Santa Barbara")
130
130
  end
131
+
132
+ it "name with affiliation" do
133
+ input = "10.11588/DIGLIT.6130"
134
+ subject = Bolognese::Metadata.new(input: input, from: "datacite")
135
+ string = subject.get_datacite(id: input)
136
+ meta = Maremma.from_xml(string).fetch("resource", {})
137
+ response = subject.get_one_author(meta.dig("creators", "creator"))
138
+ expect(response).to eq("type"=>"Person", "name"=>"Dr. Störi, Kunstsalon")
139
+ end
131
140
  end
132
141
 
133
142
  context "get_name_identifier" do
@@ -123,15 +123,12 @@ describe Bolognese::Metadata, vcr: true do
123
123
  response = Maremma.from_xml(xml)
124
124
  expect(response.dig("relatedIdentifiers", "relatedIdentifier")).to eq([{"relatedIdentifierType"=>"DOI",
125
125
  "relationType"=>"HasPart",
126
- "resourceTypeGeneral"=>"Other",
127
126
  "__content__"=>"https://doi.org/10.5061/dryad.8515/1"},
128
127
  {"relatedIdentifierType"=>"DOI",
129
128
  "relationType"=>"HasPart",
130
- "resourceTypeGeneral"=>"Other",
131
129
  "__content__"=>"https://doi.org/10.5061/dryad.8515/2"},
132
130
  {"relatedIdentifierType"=>"DOI",
133
131
  "relationType"=>"IsReferencedBy",
134
- "resourceTypeGeneral"=>"Other",
135
132
  "__content__"=>"https://doi.org/10.1371/journal.ppat.1000446"}])
136
133
  end
137
134
  end
@@ -0,0 +1,77 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://search.datacite.org/api?fl=doi,xml,media,minted,updated&q=doi:10.11588/diglit.6130&wt=json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Maremma - https://github.com/datacite/maremma
12
+ Accept:
13
+ - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: ''
18
+ headers:
19
+ Access-Control-Allow-Methods:
20
+ - GET, POST, OPTIONS
21
+ Access-Control-Allow-Origin:
22
+ - "*"
23
+ Content-Type:
24
+ - application/json;charset=UTF-8
25
+ Date:
26
+ - Sun, 07 May 2017 19:45:43 GMT
27
+ Server:
28
+ - openresty/1.11.2.2
29
+ Content-Length:
30
+ - '1792'
31
+ Connection:
32
+ - keep-alive
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"responseHeader":{"status":0,"QTime":1},"response":{"numFound":1,"start":0,"docs":[{"xml":"PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4KPHJlc291cmNlIHhtbG5zPSdodHRwOi8vZGF0YWNpdGUub3JnL3NjaGVtYS9rZXJuZWwtNCcgeG1sbnM6eHNpPSdodHRwOi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYS1pbnN0YW5jZScgeHNpOnNjaGVtYUxvY2F0aW9uPSdodHRwOi8vZGF0YWNpdGUub3JnL3NjaGVtYS9rZXJuZWwtNCBodHRwOi8vc2NoZW1hLmRhdGFjaXRlLm9yZy9tZXRhL2tlcm5lbC00L21ldGFkYXRhLnhzZCc+CiAgPGlkZW50aWZpZXIgaWRlbnRpZmllclR5cGU9J0RPSSc+MTAuMTE1ODgvZGlnbGl0LjYxMzA8L2lkZW50aWZpZXI+CiAgPGNyZWF0b3JzPgogICAgPGNyZWF0b3I+CiAgICAgIDxjcmVhdG9yTmFtZT5Eci4g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z4KICA8L3JpZ2h0c0xpc3Q+CjwvcmVzb3VyY2U+","minted":"2016-12-09T12:00:39Z","updated":"2017-02-21T14:52:20Z","doi":"10.11588/DIGLIT.6130"}]}}
36
+
37
+ '
38
+ http_version:
39
+ recorded_at: Sun, 07 May 2017 19:45:43 GMT
40
+ - request:
41
+ method: get
42
+ uri: https://search.datacite.org/api?fl=doi,xml,media,minted,updated&q=doi:10.11588/diglit.6130&wt=json
43
+ body:
44
+ encoding: US-ASCII
45
+ string: ''
46
+ headers:
47
+ User-Agent:
48
+ - Maremma - https://github.com/datacite/maremma
49
+ Accept:
50
+ - text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5
51
+ response:
52
+ status:
53
+ code: 200
54
+ message: ''
55
+ headers:
56
+ Access-Control-Allow-Methods:
57
+ - GET, POST, OPTIONS
58
+ Access-Control-Allow-Origin:
59
+ - "*"
60
+ Content-Type:
61
+ - application/json;charset=UTF-8
62
+ Date:
63
+ - Sun, 07 May 2017 19:45:43 GMT
64
+ Server:
65
+ - openresty/1.11.2.2
66
+ Content-Length:
67
+ - '1792'
68
+ Connection:
69
+ - keep-alive
70
+ body:
71
+ encoding: UTF-8
72
+ string: '{"responseHeader":{"status":0,"QTime":0},"response":{"numFound":1,"start":0,"docs":[{"xml":"PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4KPHJlc291cmNlIHhtbG5zPSdodHRwOi8vZGF0YWNpdGUub3JnL3NjaGVtYS9rZXJuZWwtNCcgeG1sbnM6eHNpPSdodHRwOi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYS1pbnN0YW5jZScgeHNpOnNjaGVtYUxvY2F0aW9uPSdodHRwOi8vZGF0YWNpdGUub3JnL3NjaGVtYS9rZXJuZWwtNCBodHRwOi8vc2NoZW1hLmRhdGFjaXRlLm9yZy9tZXRhL2tlcm5lbC00L21ldGFkYXRhLnhzZCc+CiAgPGlkZW50aWZpZXIgaWRl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GVyIGdsZWljaGVuIEJlZGluZ3VuZ2VuKSAtIGh0dHA6Ly93d3cudWIudW5pLWhlaWRlbGJlcmcuZGUvaGVsaW9zL2RpZ2kvbnV0enVuZy9XZWxjb21lLmh0bWw8L3JpZ2h0cz4KICA8L3JpZ2h0c0xpc3Q+CjwvcmVzb3VyY2U+","minted":"2016-12-09T12:00:39Z","updated":"2017-02-21T14:52:20Z","doi":"10.11588/DIGLIT.6130"}]}}
73
+
74
+ '
75
+ http_version:
76
+ recorded_at: Sun, 07 May 2017 19:45:44 GMT
77
+ recorded_with: VCR 3.0.3
@@ -9,8 +9,8 @@ describe Bolognese::Metadata, vcr: true do
9
9
  expect(datacite.dig("resourceType", "resourceTypeGeneral")).to eq("Text")
10
10
  expect(datacite.dig("titles", "title")).to eq("Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth")
11
11
  expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").length).to eq(26)
12
- expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").first).to eq("relatedIdentifierType"=>"ISSN", "relationType"=>"IsPartOf", "resourceTypeGeneral" => "Other", "title"=>"eLife", "__content__"=>"2050-084X")
13
- expect(datacite.dig("relatedIdentifiers", "relatedIdentifier")[1]).to eq("relatedIdentifierType"=>"DOI", "relationType"=>"References", "resourceTypeGeneral" => "Other", "__content__"=>"https://doi.org/10.1038/nature02100")
12
+ expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").first).to eq("relatedIdentifierType"=>"ISSN", "relationType"=>"IsPartOf", "__content__"=>"2050-084X")
13
+ expect(datacite.dig("relatedIdentifiers", "relatedIdentifier")[1]).to eq("relatedIdentifierType"=>"DOI", "relationType"=>"References", "__content__"=>"https://doi.org/10.1038/nature02100")
14
14
  expect(datacite.dig("rightsList")).to eq("rights"=>{"rightsURI"=>"http://creativecommons.org/licenses/by/3.0"})
15
15
  expect(datacite.dig("fundingReferences", "fundingReference").count).to eq(4)
16
16
  expect(datacite.dig("fundingReferences", "fundingReference").last).to eq("funderName"=>"University of Lausanne", "funderIdentifier"=>{"funderIdentifierType"=>"Crossref Funder ID", "__content__"=>"https://doi.org/10.13039/501100006390"})
@@ -119,7 +119,7 @@ describe Bolognese::Metadata, vcr: true do
119
119
  datacite = Maremma.from_xml(subject.datacite).fetch("resource", {})
120
120
  expect(datacite.dig("titles", "title")).to eq("Eating your own Dog Food")
121
121
  expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").count).to eq(3)
122
- expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").first).to eq("relatedIdentifierType"=>"DOI", "relationType"=>"IsPartOf", "title" => "DataCite Blog", "resourceTypeGeneral" => "Other", "__content__"=>"https://doi.org/10.5438/0000-00ss")
122
+ expect(datacite.dig("relatedIdentifiers", "relatedIdentifier").first).to eq("relatedIdentifierType"=>"DOI", "relationType"=>"IsPartOf", "__content__"=>"https://doi.org/10.5438/0000-00ss")
123
123
  end
124
124
  end
125
125
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bolognese
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.14
4
+ version: 0.9.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
@@ -616,6 +616,7 @@ files:
616
616
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/hyper-authorship.yml
617
617
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/is_organization.yml
618
618
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/multiple_author_names_in_one_field.yml
619
+ - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_one_author/name_with_affiliation.yml
619
620
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_schema_org_metadata/BlogPosting.yml
620
621
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/get_schema_org_metadata/not_found_error.yml
621
622
  - spec/fixtures/vcr_cassettes/Bolognese_Metadata/insert_alternate_identifiers/insert.yml