bolognese 2.0.3 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc718876c65857d9b07af2752b4ce8ed8bda05b5e3f7dae983530a414262b9e6
4
- data.tar.gz: 997f406aa28447acf4507aad0c2ffb0f4e4e42da4028dbe2210d027b438dea09
3
+ metadata.gz: b97f37a5ebcbedcb33b6937353b9afe721084c52591033d04657c8ef1e3fa4b7
4
+ data.tar.gz: 119f596d499c6465304b91eb2ea4733a6d83be967d564bf0bc895e69312133d0
5
5
  SHA512:
6
- metadata.gz: e5692d0fa4a116b0c3f32ae2be26f916f282860a69daed4564fa7b8e91823d8648eddf958fc1fdd9c9c86ab2fcf81f108b334da57b8b9c6ce7fd79b94c009262
7
- data.tar.gz: d1a74bd310e4ad4a7e8f34c218685cf3d76183d063feffab36c926e4d449e46a0792b2d279d4aeb6540ad74c441cabda0d242053eb96a01f5c6598112a1848e2
6
+ metadata.gz: 77194ea5ab5fac3555fad930a642081f4cb146dc804baed87b35be72f9c91cf88a72e44a1b2a8ab760f15ce5d49843dd65f2c41b24aa3ce840a940093705d715
7
+ data.tar.gz: 504322b19079059e7946043c087408237e48e1266f76cc4cb9bbfaf980d47d0f628dda1e1b35d20d79a27b07e18fb220b5a22234ee572b82020a31d98f52c196
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bolognese (2.0.3)
4
+ bolognese (2.1.0)
5
5
  activesupport (>= 4.2.5)
6
6
  benchmark_methods (~> 0.7)
7
7
  bibtex-ruby (>= 5.1.0)
@@ -235,4 +235,4 @@ DEPENDENCIES
235
235
  webmock (~> 3.0, >= 3.0.1)
236
236
 
237
237
  BUNDLED WITH
238
- 2.4.20
238
+ 2.4.22
@@ -74,8 +74,11 @@ module Bolognese
74
74
  creators = get_authors(from_schema_org_creators(Array.wrap(authors)))
75
75
  end
76
76
  contributors = get_authors(from_schema_org_contributors(Array.wrap(meta.fetch("editor", nil))))
77
- publisher_name = parse_attributes(meta.fetch("publisher", nil), content: "name", first: true)
78
- publisher = { "name" => publisher_name } if publisher_name.present?
77
+
78
+ publisher = {
79
+ "name" => parse_attributes(meta.fetch("publisher", nil), content: "name", first: true),
80
+ "publisherIdentifier" => parse_attributes(meta.fetch("publisher", nil), content: "@id", first: true),
81
+ }.compact if meta.fetch("publisher", nil).present?
79
82
 
80
83
  ct = (schema_org == "Dataset") ? "includedInDataCatalog" : "Periodical"
81
84
  container = if meta.fetch(ct, nil).present?
@@ -1,3 +1,3 @@
1
1
  module Bolognese
2
- VERSION = "2.0.3"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -86,7 +86,10 @@ module Bolognese
86
86
  end
87
87
 
88
88
  def insert_publisher_name(xml)
89
- xml.send("publisher-name", publisher["name"])
89
+ attributes = {
90
+ "xml:lang" => publisher["lang"]
91
+ }.compact
92
+ xml.send("publisher-name", attributes, publisher["name"])
90
93
  end
91
94
 
92
95
  def insert_publication_date(xml)
@@ -37,7 +37,7 @@ module Bolognese
37
37
  "schemaVersion" => schema_version,
38
38
  "periodical" => types.present? ? ((types["schemaOrg"] != "Dataset") && container.present? ? to_schema_org(container) : nil) : nil,
39
39
  "includedInDataCatalog" => types.present? ? ((types["schemaOrg"] == "Dataset") && container.present? ? to_schema_org_container(container, type: "Dataset") : nil) : nil,
40
- "publisher" => publisher.present? ? { "@type" => "Organization", "name" => publisher["name"] } : nil,
40
+ "publisher" => publisher.present? ? { "@type" => "Organization", "@id" => publisher["publisherIdentifier"], "name" => publisher["name"] }.compact : nil,
41
41
  "funder" => to_schema_org_funder(funding_references),
42
42
  "provider" => agency.present? ? { "@type" => "Organization", "name" => agency } : nil
43
43
  }.compact.presence
@@ -15,7 +15,7 @@
15
15
  <title xml:lang="en">DOI Test 2 title content</title>
16
16
  <title xml:lang="en">AAPP</title>
17
17
  </titles>
18
- <publisher>OSI SAF</publisher>
18
+ <publisher xml:lang="en">OSI SAF</publisher>
19
19
  <publicationYear>2004</publicationYear>
20
20
  <resourceType resourceTypeGeneral="Collection">Climate Data Record</resourceType>
21
21
  <dates>
@@ -14,6 +14,7 @@
14
14
  }],
15
15
  "publisher": {
16
16
  "@type": "Organization",
17
+ "@id": "https://ror.org/04wxnsj81",
17
18
  "name": "DataCite"
18
19
  },
19
20
  "dateCreated": "2016-12-20",
@@ -169,7 +169,7 @@ describe Bolognese::Metadata, vcr: true do
169
169
  expect(subject.publication_year).to eq("2016")
170
170
  expect(subject.related_identifiers.length).to eq(3)
171
171
  expect(subject.related_identifiers.last).to eq("relatedIdentifier"=>"10.5438/55e5-t5c0", "relatedIdentifierType"=>"DOI", "relationType"=>"References")
172
- expect(subject.publisher).to eq({"name"=>"DataCite"})
172
+ expect(subject.publisher).to eq({"name"=>"DataCite", "publisherIdentifier"=>"https://ror.org/04wxnsj81"})
173
173
  end
174
174
 
175
175
  it "GTEx dataset" do
@@ -179,6 +179,13 @@ describe Bolognese::Metadata, vcr: true do
179
179
  expect(jats.dig("day")).to be_nil
180
180
  expect(jats.dig("pub_id")).to eq("pub_id_type"=>"doi", "__content__"=>"10.34747/g6yb-3412")
181
181
  end
182
+
183
+ it "with publisher with language" do
184
+ input = fixture_path + 'datacite-xml-lang.xml'
185
+ subject = Bolognese::Metadata.new(input: input)
186
+ jats = Maremma.from_xml(subject.jats).fetch("element_citation", {})
187
+ expect(jats.dig("publisher_name")).to eq({"xml:lang"=>"en", "__content__"=>"OSI SAF"})
188
+ end
182
189
  end
183
190
 
184
191
  context "change metadata as datacite xml" do
@@ -365,5 +365,18 @@ describe Bolognese::Metadata, vcr: true do
365
365
  expect(json["@type"]).to eq("CreativeWork")
366
366
  expect(json["datePublished"]).to eq("2019")
367
367
  end
368
+
369
+ it "from Schema 4.5 with publisher attributes" do
370
+ input = fixture_path + 'datacite-example-full-v4.5.xml'
371
+ subject = Bolognese::Metadata.new(input: input)
372
+ json = JSON.parse(subject.schema_org)
373
+ expect(json["publisher"]).to eq(
374
+ {
375
+ "@type" => "Organization",
376
+ "@id" => "https://ror.org/04z8jg394",
377
+ "name" => "Example Publisher"
378
+ }
379
+ )
380
+ end
368
381
  end
369
382
  end
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: 2.0.3
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-11 00:00:00.000000000 Z
11
+ date: 2024-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maremma