bolognese 1.0.20 → 1.0.21

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: cdd3b249d4bb2a0126342f0fe581953de3bad55a6da02eda97129752b7caf5f0
4
- data.tar.gz: b54781d9c4c6fdce604e2f4c12cb4a009a67f7c9e72b0034fa3a18829bd10d7c
3
+ metadata.gz: 8f0e15fffb108ad3df33fbc6e975cbefe42a2c60baf7f2d5514607dcb2547951
4
+ data.tar.gz: c936de8f51aa9d5c0070f284fbada6fe713da4f2e827021a0b663c22f7742688
5
5
  SHA512:
6
- metadata.gz: 3e587b91a50c7617c450b373fcae22f97f5455c0566bbe33b1fab806b2a426f821e49692dc2a865f8a286b4d5c63f22caf92263c9fb2b576bf1bc5d480e183f5
7
- data.tar.gz: 2d4d9c4629aa9787c04b2d5933fe269353de0f95e4f6038fed2ceb7663c113dcbdb010642f1229cfb762b3332a842895b937df7bc9b1edc127c0778a41d4d38c
6
+ metadata.gz: 3f0c1a6adaacdfb4fb2155dea5215f351633efced879408f07f4bb9cb2cb28edc4c9dad890817547cab7ae2d375d713477fd8765f05d32d877d6d9a6001cb83b
7
+ data.tar.gz: 002b0ba55541605373b07591d717359688a032b087a76fc7f5e6c31ba2f9bc7ab49f3a633d4f87ea1315d65764bcf4835993d802ec75e45b0c8d8804f74a90b4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bolognese (1.0.20)
4
+ bolognese (1.0.21)
5
5
  activesupport (>= 4.2.5, < 6)
6
6
  benchmark_methods (~> 0.7)
7
7
  bibtex-ruby (~> 4.1)
@@ -100,7 +100,7 @@ module Bolognese
100
100
  end
101
101
 
102
102
  def insert_resource_type(xml)
103
- return xml unless types["schemaOrg"].present?
103
+ return xml unless types.is_a?(Hash) && (types["schemaOrg"].present? || types["resourceTypeGeneral"])
104
104
 
105
105
  xml.resourceType(types["resourceType"] || types["schemaOrg"],
106
106
  'resourceTypeGeneral' => types["resourceTypeGeneral"] || Metadata::SO_TO_DC_TRANSLATIONS[types["schemaOrg"]] || "Other")
@@ -34,7 +34,7 @@ module Bolognese
34
34
  schema_org = BIB_TO_SO_TRANSLATIONS[meta.try(:type).to_s] || "ScholarlyArticle"
35
35
  types = {
36
36
  "resourceTypeGeneral" => Metadata::SO_TO_DC_TRANSLATIONS[schema_org],
37
- "resource_type" => Bolognese::Utils::BIB_TO_CR_TRANSLATIONS[meta.try(:type).to_s] || meta.try(:type).to_s,
37
+ "resourceType" => Bolognese::Utils::BIB_TO_CR_TRANSLATIONS[meta.try(:type).to_s] || meta.try(:type).to_s,
38
38
  "schemaOrg" => schema_org,
39
39
  "bibtex" => meta.type.to_s,
40
40
  "citeproc" => BIB_TO_CP_TRANSLATIONS[meta.try(:type).to_s] || "misc",
@@ -52,8 +52,12 @@ module Bolognese
52
52
  read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:string, :sandbox))
53
53
 
54
54
  doc = Nokogiri::XML(string, nil, 'UTF-8', &:noblanks)
55
- ns = doc.collect_namespaces.find { |k, v| v.start_with?("http://datacite.org/schema/kernel") }
56
- schema_version = Array.wrap(ns).last || "http://datacite.org/schema/kernel-4"
55
+ if read_options.present?
56
+ schema_version = "http://datacite.org/schema/kernel-4"
57
+ else
58
+ ns = doc.collect_namespaces.find { |k, v| v.start_with?("http://datacite.org/schema/kernel") }
59
+ schema_version = Array.wrap(ns).last || "http://datacite.org/schema/kernel-4"
60
+ end
57
61
  doc.remove_namespaces!
58
62
  string = doc.to_xml(:indent => 2)
59
63
 
@@ -1,3 +1,3 @@
1
1
  module Bolognese
2
- VERSION = "1.0.20"
2
+ VERSION = "1.0.21"
3
3
  end
@@ -29,7 +29,7 @@ describe Bolognese::Metadata, vcr: true do
29
29
  it "Crossref DOI" do
30
30
  expect(subject.valid?).to be true
31
31
  expect(subject.identifier).to eq("https://doi.org/10.7554/elife.01567")
32
- expect(subject.types).to eq("bibtex"=>"article", "citeproc"=>"article-journal", "resourceTypeGeneral"=>"Text", "resource_type"=>"JournalArticle", "ris"=>"JOUR", "schemaOrg"=>"ScholarlyArticle")
32
+ expect(subject.types).to eq("bibtex"=>"article", "citeproc"=>"article-journal", "resourceTypeGeneral"=>"Text", "resourceType"=>"JournalArticle", "ris"=>"JOUR", "schemaOrg"=>"ScholarlyArticle")
33
33
  expect(subject.url).to eq("http://elifesciences.org/lookup/doi/10.7554/eLife.01567")
34
34
  expect(subject.creator.length).to eq(5)
35
35
  expect(subject.creator.first).to eq("type"=>"Person", "name"=>"Martial Sankar", "givenName"=>"Martial", "familyName"=>"Sankar")
@@ -48,7 +48,7 @@ describe Bolognese::Metadata, vcr: true do
48
48
  expect(subject.valid?).to be false
49
49
  expect(subject.state).to eq("not_found")
50
50
  expect(subject.identifier).to eq("https://doi.org/10.7554/elife.01567")
51
- expect(subject.types).to eq("bibtex"=>"phdthesis", "citeproc"=>"thesis", "resourceTypeGeneral"=>"Text", "resource_type"=>"Dissertation", "ris"=>"THES", "schemaOrg"=>"Thesis")
51
+ expect(subject.types).to eq("bibtex"=>"phdthesis", "citeproc"=>"thesis", "resourceTypeGeneral"=>"Text", "resourceType"=>"Dissertation", "ris"=>"THES", "schemaOrg"=>"Thesis")
52
52
  expect(subject.creator).to eq([{"type"=>"Person", "name"=>"Y. Toparlar", "givenName"=>"Y.", "familyName"=>"Toparlar"}])
53
53
  expect(subject.titles).to eq([{"title"=>"A multiscale analysis of the urban heat island effect: from city averaged temperatures to the energy demand of individual buildings"}])
54
54
  expect(subject.descriptions.first["description"]).to start_with("Designing the climates of cities")
@@ -37,7 +37,7 @@ describe Bolognese::Metadata, vcr: true do
37
37
  input = fixture_path + "crossref.bib"
38
38
  subject = Bolognese::Metadata.new(input: input, from: "bibtex")
39
39
  crosscite = JSON.parse(subject.crosscite)
40
- expect(crosscite.fetch("types")).to eq("bibtex"=>"article", "citeproc"=>"article-journal", "resourceTypeGeneral"=>"Text", "resource_type"=>"JournalArticle", "ris"=>"JOUR", "schemaOrg"=>"ScholarlyArticle")
40
+ expect(crosscite.fetch("types")).to eq("bibtex"=>"article", "citeproc"=>"article-journal", "resourceTypeGeneral"=>"Text", "resourceType"=>"JournalArticle", "ris"=>"JOUR", "schemaOrg"=>"ScholarlyArticle")
41
41
  expect(crosscite.fetch("titles")).to eq([{"title"=>"Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth"}])
42
42
  expect(crosscite.dig("descriptions", 0, "description")).to start_with("Among various advantages, their small size makes model organisms preferred subjects of investigation.")
43
43
  expect(crosscite.fetch("creator").count).to eq(5)
@@ -30,7 +30,7 @@ describe Bolognese::Metadata, vcr: true do
30
30
  input = fixture_path + "crossref.bib"
31
31
  subject = Bolognese::Metadata.new(input: input, from: "bibtex")
32
32
  datacite = JSON.parse(subject.datacite_json)
33
- expect(datacite.fetch("types")).to eq("bibtex"=>"article", "citeproc"=>"article-journal", "resource-type"=>"JournalArticle", "resourceTypeGeneral"=>"Text", "ris"=>"JOUR", "schemaOrg"=>"ScholarlyArticle")
33
+ expect(datacite.fetch("types")).to eq("bibtex"=>"article", "citeproc"=>"article-journal", "resourceType"=>"JournalArticle", "resourceTypeGeneral"=>"Text", "ris"=>"JOUR", "schemaOrg"=>"ScholarlyArticle")
34
34
  expect(datacite.fetch("titles")).to eq([{"title"=>"Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth"}])
35
35
  expect(datacite.dig("descriptions", 0, "description")).to start_with("Among various advantages, their small size makes model organisms preferred subjects of investigation.")
36
36
  expect(datacite.fetch("creator").length).to eq(5)
@@ -287,7 +287,7 @@ describe Bolognese::Metadata, vcr: true do
287
287
  subject = Bolognese::Metadata.new(input: input, from: "crossref")
288
288
  subject.doi = "123"
289
289
  subject.titles = "Data from: Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth"
290
- subject.types = "Dataset"
290
+ subject.types = { "schemaOrg" => "Dataset", "resourceTypeGeneral" => "Dataset" }
291
291
  expect(subject.doi).to eq("123")
292
292
  expect(subject.valid?).to be false
293
293
  expect(subject.errors.first).to start_with("3:0: ERROR: Element '{http://datacite.org/schema/kernel-4}identifier'")
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: 1.0.20
4
+ version: 1.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner