bolognese 0.11.3 → 0.11.4

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: 3a474fc02c5cd6efde7e3281b2b028893ba95762eb76db7ea6292ca262104493
4
- data.tar.gz: 2ddb4c167ce6fdf718ad17bb5802465291d500e8f660232b5649635191ced1e0
3
+ metadata.gz: 30348e9164a584a0cdd9bb4a80ab50907e78f10e56a8213d736c03052dbc81b9
4
+ data.tar.gz: 026581048dea86848ef44e43b04dc891b901f39cb554d24cce95c614b8a5f3d4
5
5
  SHA512:
6
- metadata.gz: 180c4a1b2d5b68bde9f40b0e4b6e3710e5d698e06ce8c9d95b3b1e881992dced59b509b5dd50ca281de976b93ce7160ecd67b9f1b7c235e3d4bff7fc59018c0b
7
- data.tar.gz: 5e7345b954368e38a3f168343f565ab6ecc92ca0fe69726c92416550644094ede0e201aff89bef492eac232b63a966f757aecf3d52ed45acf686115de798ca49
6
+ metadata.gz: cbb748a13ce8b8ea3daf1ee0f57458c9e2904b39c639a4959a5a48bfbde7f5c5c26e421f815a5a997cdba2465bc7a096f47abd8175f0d1b4f00325900d9c5185
7
+ data.tar.gz: e71415a8a4e291a6e87150f88d4e976a1f00d94b7b67d7bc7faa7b3ce97e08208e7aaa6c9283b07cbad86465c0b82ebd9ec85155e8f2567f1fb7d5c34c93a29b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bolognese (0.11.3)
4
+ bolognese (0.11.4)
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
  loofah (2.2.2)
79
79
  crass (~> 1.0.2)
80
80
  nokogiri (>= 1.5.9)
81
- maremma (4.0.12)
81
+ maremma (4.1)
82
82
  activesupport (>= 4.2.5, < 6)
83
83
  addressable (>= 2.3.6)
84
84
  builder (~> 3.2, >= 3.2.2)
@@ -45,8 +45,13 @@ module Bolognese
45
45
  end
46
46
 
47
47
  def read_datacite(string: nil, **options)
48
+ doc = Nokogiri::XML(string, nil, 'UTF-8', &:noblanks)
49
+ ns = doc.collect_namespaces.find { |k, v| v.start_with?("http://datacite.org/schema/kernel") }
50
+ schema_version = Array.wrap(ns).last || "http://datacite.org/schema/kernel-4"
51
+ doc.remove_namespaces!
52
+ string = doc.to_xml(:indent => 2)
53
+
48
54
  meta = Maremma.from_xml(string).to_h.fetch("resource", {})
49
- schema_version = meta.fetch("xmlns", nil)
50
55
 
51
56
  # validate only when option is set, as this step is expensive and
52
57
  # not needed if XML comes from DataCite MDS
@@ -69,7 +74,7 @@ module Bolognese
69
74
  if r.is_a?(String)
70
75
  sanitize(r)
71
76
  else
72
- { "title_type" => r["titleType"], "lang" => r["xml:lang"], "text" => sanitize(r["__content__"]) }.compact
77
+ { "title_type" => r["titleType"], "lang" => r["lang"], "text" => sanitize(r["__content__"]) }.compact
73
78
  end
74
79
  end.unwrap
75
80
 
@@ -354,7 +354,7 @@ module Bolognese
354
354
  "ris"
355
355
  elsif options[:ext] == ".xml" && Maremma.from_xml(string).to_h.dig("doi_records", "doi_record", "crossref")
356
356
  "crossref"
357
- elsif options[:ext] == ".xml" && Maremma.from_xml(string).to_h.dig("resource", "xmlns").to_s.start_with?("http://datacite.org/schema/kernel")
357
+ elsif options[:ext] == ".xml" && Nokogiri::XML(string, nil, 'UTF-8', &:noblanks).collect_namespaces.find { |k, v| v.start_with?("http://datacite.org/schema/kernel") }
358
358
  "datacite"
359
359
  elsif options[:ext] == ".json" && Maremma.from_json(string).to_h.dig("ris_type")
360
360
  "crosscite"
@@ -1,3 +1,3 @@
1
1
  module Bolognese
2
- VERSION = "0.11.3"
2
+ VERSION = "0.11.4"
3
3
  end
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <ns0:resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://datacite.org/schema/kernel-2.2" xsi:schemaLocation="http://datacite.org/schema/kernel-2.2 http://schema.datacite.org/meta/kernel-2.2/metadata.xsd"><ns0:identifier identifierType="DOI">10.4231/D38G8FK8B</ns0:identifier><ns0:creators><ns0:creator> <ns0:creatorName>Patiño, Carlos</ns0:creatorName></ns0:creator><ns0:creator> <ns0:creatorName>Alzate-Vargas, Lorena</ns0:creatorName></ns0:creator><ns0:creator> <ns0:creatorName>Li, Chunyu</ns0:creatorName></ns0:creator><ns0:creator> <ns0:creatorName>Haley, Benjamin</ns0:creatorName></ns0:creator><ns0:creator> <ns0:creatorName>Strachan, Alejandro</ns0:creatorName></ns0:creator></ns0:creators><ns0:titles> <ns0:title>LAMMPS Data-File Generator</ns0:title></ns0:titles><ns0:publisher>nanoHUB</ns0:publisher><ns0:publicationYear>2018</ns0:publicationYear><ns0:dates> <ns0:date dateType="Valid">2018-07-18</ns0:date> <ns0:date dateType="Accepted">2018-07-18</ns0:date></ns0:dates><ns0:language>en</ns0:language><ns0:resourceType resourceTypeGeneral="Software">Simulation Tool</ns0:resourceType><ns0:version>1.5.2</ns0:version><ns0:descriptions> <ns0:description descriptionType="Other">This tool generates all necessary input files for LAMMPS simulations of molecular systems starting with an atomistic structure.</ns0:description></ns0:descriptions></ns0:resource>
@@ -354,6 +354,24 @@ describe Bolognese::Metadata, vcr: true do
354
354
  expect(subject.service_provider).to eq("DataCite")
355
355
  end
356
356
 
357
+ it "namespaced xml from string" do
358
+ input = fixture_path + "ns0.xml"
359
+ subject = Bolognese::Metadata.new(input: input)
360
+ expect(subject.valid?).to be true
361
+ expect(subject.identifier).to eq("https://doi.org/10.4231/d38g8fk8b")
362
+ expect(subject.type).to eq("SoftwareSourceCode")
363
+ expect(subject.additional_type).to eq("Simulation Tool")
364
+ expect(subject.resource_type_general).to eq("Software")
365
+ expect(subject.author.length).to eq(5)
366
+ expect(subject.author.first).to eq("type"=>"Person", "name"=>"Carlos PatiñO", "givenName"=>"Carlos", "familyName"=>"PatiñO")
367
+ expect(subject.title).to eq("LAMMPS Data-File Generator")
368
+ expect(subject.date_published).to eq("2018")
369
+ expect(subject.publication_year).to eq(2018)
370
+ expect(subject.publisher).to eq("nanoHUB")
371
+ expect(subject.service_provider).to eq("DataCite")
372
+ expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-2.2")
373
+ end
374
+
357
375
  it "doi with + sign" do
358
376
  input = "10.5067/terra+aqua/ceres/cldtyphist_l3.004"
359
377
  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: 0.11.3
4
+ version: 0.11.4
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-07-23 00:00:00.000000000 Z
11
+ date: 2018-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maremma
@@ -606,6 +606,7 @@ files:
606
606
  - spec/fixtures/datacite_software_overlapping_keys.json
607
607
  - spec/fixtures/gtex.xml
608
608
  - spec/fixtures/maremma/codemeta.json
609
+ - spec/fixtures/ns0.xml
609
610
  - spec/fixtures/pure.bib
610
611
  - spec/fixtures/pure.ris
611
612
  - spec/fixtures/schema_org.json