bolognese 1.0.31 → 1.0.32

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
  SHA256:
3
- metadata.gz: db57de7769dfb3d60d3650db32bb4da33cb688437605edd09f342c2dc8c4eea0
4
- data.tar.gz: 289506a053d20125d2e2da026b29d2a70b6407fcc5f236d09391a58ddbf4d92d
3
+ metadata.gz: 586317f27774c61bb3e76f1ce1f7eb29ed20d9b723b74acb588b955d3a41f00a
4
+ data.tar.gz: b5fb12de049828f2d8423030d0979d1f22a68b7c7f387459f698afd98cd05740
5
5
  SHA512:
6
- metadata.gz: d96bd487af44a8aaf7e2a7a4a02ab4a33a9facc7f3624f9e9bc63b3a7bda882c0e6b4fe196e87ad8d05238564e01fc4983e658b5c8359193f51ef81cea8449d4
7
- data.tar.gz: 53d8ce4bff425a7d550b1c2c7700700a1bdbd1f87c4061588194779f01fc0f4c3eaf2cfaa1ceb8d1e796ff9ce0f472bf4454bfcc713ef0b25630c88d12df62f0
6
+ metadata.gz: 13efb91c0d652dda3596b018bbac50d3d4676930bdbeffbcd831c49560be3330bcb7ec4e1f8a18c93de4e6189a70c0d608e47cb4830aa72e9b2550983c14235e
7
+ data.tar.gz: 285804b9d1bc9cf4359c52fceb0c627bbf523455d0238e6cfb9e9ef19c4409894aa4d40e9270036430011009da12e129c17af1d8f1dc6269195068f2fc9cb0dd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bolognese (1.0.31)
4
+ bolognese (1.0.32)
5
5
  activesupport (>= 4.2.5, < 6)
6
6
  benchmark_methods (~> 0.7)
7
7
  bibtex-ruby (~> 4.1)
@@ -78,7 +78,7 @@ GEM
78
78
  concurrent-ruby (~> 1.0)
79
79
  hashdiff (0.3.7)
80
80
  htmlentities (4.3.4)
81
- i18n (1.1.1)
81
+ i18n (1.2.0)
82
82
  concurrent-ruby (~> 1.0)
83
83
  iso8601 (0.9.1)
84
84
  json (2.1.0)
@@ -60,8 +60,8 @@ module Bolognese
60
60
  end
61
61
 
62
62
  container = if meta.try(:journal).present?
63
- first_page = meta.try(:pages).present? ? meta.try(:pages).split("-").map(&:strip).first : nil
64
- last_page = meta.try(:pages).present? ? meta.try(:pages).split("-").map(&:strip).last : nil
63
+ first_page = meta.try(:pages).present? ? meta.try(:pages).split("-").map(&:strip)[0] : nil
64
+ last_page = meta.try(:pages).present? ? meta.try(:pages).split("-").map(&:strip)[1] : nil
65
65
 
66
66
  { "type" => "Journal",
67
67
  "title" => meta.journal.to_s,
@@ -70,8 +70,8 @@ module Bolognese
70
70
  nil
71
71
  end
72
72
  container = if meta.fetch("container-title", nil).present?
73
- first_page = meta.fetch("page", nil).present? ? meta.fetch("page").split("-").map(&:strip).first : nil
74
- last_page = meta.fetch("page", nil).present? ? meta.fetch("page").split("-").map(&:strip).last : nil
73
+ first_page = meta.fetch("page", nil).present? ? meta.fetch("page").split("-").map(&:strip)[0] : nil
74
+ last_page = meta.fetch("page", nil).present? ? meta.fetch("page").split("-").map(&:strip)[1] : nil
75
75
 
76
76
  { "type" => "Periodical",
77
77
  "title" => meta.fetch("container-title", nil),
@@ -77,7 +77,9 @@ module Bolognese
77
77
  end
78
78
 
79
79
  identifiers = [{ "identifierType" => "DOI", "identifier" => id }] + Array.wrap(meta.dig("alternateIdentifiers", "alternateIdentifier")).map do |r|
80
- { "identifierType" => get_identifier_type(r["alternateIdentifierType"]), "identifier" => r["__content__"].presence }.compact
80
+ if r["__content__"].present?
81
+ { "identifierType" => get_identifier_type(r["alternateIdentifierType"]), "identifier" => r["__content__"] }
82
+ end
81
83
  end.compact
82
84
 
83
85
  doi = Array.wrap(identifiers).find { |r| r["identifierType"] == "DOI" }.to_h.fetch("identifier", nil)
@@ -876,6 +876,8 @@ module Bolognese
876
876
  end
877
877
 
878
878
  def get_identifier_type(identifier_type)
879
+ return nil unless identifier_type.present?
880
+
879
881
  identifierTypes = {
880
882
  "ark" => "ARK",
881
883
  "arxiv" => "arXiv",
@@ -913,8 +915,8 @@ module Bolognese
913
915
  volume = volume_issue.present? ? volume_issue[0].presence || volume_issue[2].presence : nil
914
916
  issue = volume_issue.present? ? volume_issue[1][1...-1].presence : nil
915
917
  pages = str.length > 1 ? str.last : nil
916
- first_page = pages.present? ? pages.split("-").map(&:strip).first : nil
917
- last_page = pages.present? ? pages.split("-").map(&:strip).last : nil
918
+ first_page = pages.present? ? pages.split("-").map(&:strip)[0] : nil
919
+ last_page = pages.present? ? pages.split("-").map(&:strip)[1] : nil
918
920
 
919
921
  {
920
922
  "title" => title,
@@ -1,3 +1,3 @@
1
1
  module Bolognese
2
- VERSION = "1.0.31"
2
+ VERSION = "1.0.32"
3
3
  end
@@ -0,0 +1,35 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <resource xmlns="http://datacite.org/schema/kernel-3"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datacite.org/schema/kernel-3 http://schema.datacite.org/meta/kernel-3/metadata.xsd">
4
+ <identifier identifierType="DOI">https://doi.org/10.5072/M32163</identifier>
5
+ <creators>
6
+ <creator>
7
+ <creatorName nameType="personal">William Turner</creatorName>
8
+ <givenName>William</givenName>
9
+ <familyName>Turner</familyName>
10
+ <affiliation>National Institute of Standards and Technology</affiliation>
11
+ </creator>
12
+ </creators>
13
+ <titles>
14
+ <title>Peter Auto Dataset 501</title>
15
+ </titles>
16
+ <publisher>National Institute of Standards and Technology</publisher>
17
+ <publicationYear>2018</publicationYear>
18
+ <subjects>
19
+ <subject>Einstein</subject>
20
+ </subjects>
21
+ <dates>
22
+ <date dateType="Updated">2018-10-30</date>
23
+ </dates>
24
+ <language>en</language>
25
+ <resourceType resourceTypeGeneral="Dataset">Dataset</resourceType>
26
+ <rightsList>
27
+ <rights rightsURI="https://www.nist.gov/director/licensing">NIST Licensing</rights>
28
+ </rightsList>
29
+ <descriptions>
30
+ <description descriptionType="Abstract">This is to overturn Einstein's Relativity Theory.</description>
31
+ </descriptions>
32
+ <alternateIdentifiers alternateIdentifierType="text">
33
+ <alternateIdentifier>7CE9D6400C0A30C9E053B357068182C92163</alternateIdentifier>
34
+ </alternateIdentifiers>
35
+ </resource>
@@ -246,6 +246,17 @@ describe Bolognese::Metadata, vcr: true do
246
246
  expect(subject.geo_locations).to eq([{"geoLocationBox"=>{"eastBoundLongitude"=>"70.0", "northBoundLatitude"=>"70.0", "southBoundLatitude"=>"-70.0", "westBoundLongitude"=>"-70.0"}}, {"geoLocationPlace"=>"Regional"}])
247
247
  end
248
248
 
249
+ it "wrong attributes" do
250
+ input = fixture_path + 'nist.xml'
251
+ subject = Bolognese::Metadata.new(input: input)
252
+ expect(subject.identifiers).to eq([{"identifier"=>"https://doi.org/10.5072/m32163", "identifierType"=>"DOI"}])
253
+ expect(subject.titles).to eq([{"title"=>"Peter Auto Dataset 501"}])
254
+ expect(subject.descriptions).to eq([{"description"=>"This is to overturn Einstein's Relativity Theory.", "descriptionType"=>"Abstract"}])
255
+ expect(subject.valid?).to be false
256
+ expect(subject.errors.length).to eq(4)
257
+ expect(subject.errors.last).to eq("32:0: ERROR: Element '{http://datacite.org/schema/kernel-3}alternateIdentifier': The attribute 'alternateIdentifierType' is required but missing.")
258
+ end
259
+
249
260
  it "schema 4.0" do
250
261
  input = fixture_path + 'schema_4.0.xml'
251
262
  subject = Bolognese::Metadata.new(input: input)
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: 1.0.31
4
+ version: 1.0.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-10 00:00:00.000000000 Z
11
+ date: 2018-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maremma
@@ -691,6 +691,7 @@ files:
691
691
  - spec/fixtures/funding_reference.xml
692
692
  - spec/fixtures/gtex.xml
693
693
  - spec/fixtures/maremma/codemeta.json
694
+ - spec/fixtures/nist.xml
694
695
  - spec/fixtures/ns0.xml
695
696
  - spec/fixtures/pure.bib
696
697
  - spec/fixtures/pure.ris