bolognese 0.9.79 → 0.9.80

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: 55a73ea6e167c7c06a36a5af075dee766544ce148ede9f10c557ede013b120bb
4
- data.tar.gz: a2b426ec2d2d57ecf4ec5bdf9937d10726c4371017c03ed1e2040fd5806c9202
3
+ metadata.gz: 63268aa42d12dee8d65c43ee18b4ef1737fc3a763b198b64fe31b6bfa714804d
4
+ data.tar.gz: 4b7d9245ff0cd109321010acec951d05c646876f462a17c31cf6c15197077818
5
5
  SHA512:
6
- metadata.gz: cea2c6a8c37845539b8fc183e76987ca20e20748b143ce2b86c8fc6a444aa985969d8bd755017c1d8bee535868250376f40078686430a4382aa0f8752d9321d2
7
- data.tar.gz: ea2b13fb57874cef658861714f70db5dce430156986ad4d8d453108ce57a15ca991943048a0ed391afdce6ab7e2d78dd07f93fc2d1ca00782563a24084fcafad
6
+ metadata.gz: f3dbbcb1a839d6a552e53913c0165e0e080e2716eb9905608f00c77d6ce815167a26b3f97540d99d799da5b90ebdc33ce633f4c2a6f31f442e2783898e61c4f8
7
+ data.tar.gz: a7e9ffbad8c3a991efce56f907ce13932ae3cdc853d15007f9212a50985d2796f07c959d56c00f9f25d71baf286a3bdc2ef9d9b004252a2cd6bb79f5ad5b62a7
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bolognese (0.9.79)
4
+ bolognese (0.9.80)
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.0)
79
79
  crass (~> 1.0.2)
80
80
  nokogiri (>= 1.5.9)
81
- maremma (4.0)
81
+ maremma (4.0.2)
82
82
  activesupport (>= 4.2.5, < 6)
83
83
  addressable (>= 2.3.6)
84
84
  builder (~> 3.2, >= 3.2.2)
@@ -61,7 +61,7 @@ module Bolognese
61
61
  include Bolognese::Writers::SchemaOrgWriter
62
62
  include Bolognese::Writers::TurtleWriter
63
63
 
64
- attr_accessor :id, :doi, :author, :title, :publisher, :contributor, :license,
64
+ attr_accessor :id, :doi, :author, :creator, :title, :publisher, :contributor, :license,
65
65
  :date_accepted, :date_available, :date_copyrighted, :date_collected,
66
66
  :date_submitted, :date_valid, :date_created, :date_modified,
67
67
  :date_registered, :date_updated, :provider_id, :client_id, :journal,
@@ -116,6 +116,20 @@ module Bolognese
116
116
  @metadata = @from.present? ? send("read_" + @from, string: string, id: id, sandbox: options[:sandbox], doi: options[:doi], url: options[:url]) : {}
117
117
  @raw = string.present? ? string.strip : nil
118
118
 
119
+ # input specific metadata elements required for DataCite
120
+ @doi = options[:doi].presence
121
+ @author = options[:author].presence
122
+ @title = options[:title].presence
123
+ @publisher = options[:publisher].presence
124
+ @publication_year = options[:publication_year].presence
125
+ @resource_type_general = options[:resource_type_general].presence
126
+
127
+ # input specific metadata elements recommended for DataCite
128
+ @additional_type = options[:additional_type].presence
129
+ @description = options[:description].presence
130
+ @license = options[:license].presence
131
+ @date_published = options[:date_published].presence
132
+
119
133
  # replace DOI in XML if provided in options
120
134
  if @from == "datacite" && options[:doi].present? && string.present?
121
135
  doc = Nokogiri::XML(string, nil, 'UTF-8', &:noblanks)
@@ -380,7 +394,7 @@ module Bolognese
380
394
  end
381
395
 
382
396
  def publication_year
383
- date_published.present? ? date_published[0..3].to_i.presence : nil
397
+ @publication_year ||= date_published.present? ? date_published[0..3].to_i.presence : nil
384
398
  end
385
399
 
386
400
  def container_title
@@ -95,8 +95,7 @@ module Bolognese
95
95
 
96
96
  { "id" => id,
97
97
  "type" => type,
98
- "additional_type" => meta.fetch("resourceType", {}).fetch("__content__", nil) ||
99
- meta.fetch("resourceType", {}).fetch("resourceTypeGeneral", nil),
98
+ "additional_type" => meta.fetch("resourceType", {}).fetch("__content__", nil),
100
99
  "citeproc_type" => Bolognese::Utils::DC_TO_CP_TRANSLATIONS[resource_type_general.to_s.dasherize] || "article",
101
100
  "bibtex_type" => Bolognese::Utils::SO_TO_BIB_TRANSLATIONS[type] || "misc",
102
101
  "ris_type" => Bolognese::Utils::DC_TO_RIS_TRANSLATIONS[resource_type_general.to_s.dasherize] || "GEN",
@@ -1,3 +1,3 @@
1
1
  module Bolognese
2
- VERSION = "0.9.79"
2
+ VERSION = "0.9.80"
3
3
  end
@@ -78,7 +78,6 @@ describe Bolognese::Metadata, vcr: true do
78
78
  expect(subject.valid?).to be true
79
79
  expect(subject.id).to eq("https://doi.org/10.5281/zenodo.48440")
80
80
  expect(subject.type).to eq("SoftwareSourceCode")
81
- expect(subject.additional_type).to eq("Software")
82
81
  expect(subject.resource_type_general).to eq("Software")
83
82
  expect(subject.author).to eq("type"=>"Person", "name"=>"Kristian Garza", "givenName"=>"Kristian", "familyName"=>"Garza")
84
83
  expect(subject.title).to eq("Analysis Tools For Crossover Experiment Of Ui Using Choice Architecture")
@@ -117,7 +116,6 @@ describe Bolognese::Metadata, vcr: true do
117
116
  expect(subject.valid?).to be true
118
117
  expect(subject.id).to eq("https://doi.org/10.5281/zenodo.1239")
119
118
  expect(subject.type).to eq("Dataset")
120
- expect(subject.additional_type).to eq("Dataset")
121
119
  expect(subject.resource_type_general).to eq("Dataset")
122
120
  expect(subject.author.length).to eq(4)
123
121
  expect(subject.author.first).to eq("type"=>"Person", "name"=>"Najko Jahn", "givenName"=>"Najko", "familyName"=>"Jahn")
@@ -335,7 +333,6 @@ describe Bolognese::Metadata, vcr: true do
335
333
  expect(subject.valid?).to be true
336
334
  expect(subject.id).to eq("https://handle.test.datacite.org/10.22002/d1.694")
337
335
  expect(subject.type).to eq("Dataset")
338
- expect(subject.additional_type).to eq("Dataset")
339
336
  expect(subject.resource_type_general).to eq("Dataset")
340
337
  expect(subject.author).to eq("name"=>"Tester")
341
338
  expect(subject.title).to eq("Test license")
@@ -352,7 +349,6 @@ describe Bolognese::Metadata, vcr: true do
352
349
  expect(subject.valid?).to be true
353
350
  expect(subject.id).to eq("https://handle.test.datacite.org/10.21956/gatesopenres.530.r190")
354
351
  expect(subject.type).to eq("ScholarlyArticle")
355
- expect(subject.additional_type).to eq("Text")
356
352
  expect(subject.resource_type_general).to eq("Text")
357
353
  expect(subject.author.length).to eq(5)
358
354
  expect(subject.author.first).to eq("type"=>"Person", "name"=>"Lina Patel", "givenName"=>"Lina", "familyName"=>"Patel")
@@ -403,4 +399,145 @@ describe Bolognese::Metadata, vcr: true do
403
399
  expect(subject.state).to eq("registered")
404
400
  end
405
401
  end
402
+
403
+ context "change datacite metadata on input" do
404
+ it "change doi" do
405
+ input = fixture_path + 'datacite.xml'
406
+ doi = "10.5061/dryad.8515"
407
+ subject = Bolognese::Metadata.new(input: input, doi: doi)
408
+ expect(subject.valid?).to be true
409
+ expect(subject.id).to eq("https://doi.org/10.5061/dryad.8515")
410
+ expect(subject.doi).to eq("10.5061/dryad.8515")
411
+ expect(subject.author).to eq("type"=>"Person", "id"=>"https://orcid.org/0000-0003-1419-2405", "name"=>"Fenner, Martin", "givenName"=>"Martin", "familyName"=>"Fenner")
412
+ expect(subject.title).to eq("Eating your own Dog Food")
413
+ expect(subject.publisher).to eq("DataCite")
414
+ expect(subject.publication_year).to eq(2016)
415
+ end
416
+
417
+ it "change author" do
418
+ input = fixture_path + 'datacite.xml'
419
+ author = { "type"=>"Person", "name"=>"Ollomo, Benjamin", "givenName"=>"Benjamin", "familyName"=>"Ollomo" }
420
+ subject = Bolognese::Metadata.new(input: input, author: author)
421
+ expect(subject.valid?).to be true
422
+ expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
423
+ expect(subject.doi).to eq("10.5438/4k3m-nyvg")
424
+ expect(subject.author).to eq("type"=>"Person", "name"=>"Ollomo, Benjamin", "givenName"=>"Benjamin", "familyName"=>"Ollomo")
425
+ expect(subject.title).to eq("Eating your own Dog Food")
426
+ expect(subject.publisher).to eq("DataCite")
427
+ expect(subject.publication_year).to eq(2016)
428
+ end
429
+
430
+ it "change title" do
431
+ input = fixture_path + 'datacite.xml'
432
+ title = "A new malaria agent in African hominids."
433
+ subject = Bolognese::Metadata.new(input: input, title: title)
434
+ expect(subject.valid?).to be true
435
+ expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
436
+ expect(subject.doi).to eq("10.5438/4k3m-nyvg")
437
+ expect(subject.title).to eq("A new malaria agent in African hominids.")
438
+ expect(subject.publisher).to eq("DataCite")
439
+ expect(subject.publication_year).to eq(2016)
440
+ end
441
+
442
+ it "change publisher" do
443
+ input = fixture_path + 'datacite.xml'
444
+ publisher = "Zenodo"
445
+ subject = Bolognese::Metadata.new(input: input, publisher: publisher)
446
+ expect(subject.valid?).to be true
447
+ expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
448
+ expect(subject.doi).to eq("10.5438/4k3m-nyvg")
449
+ expect(subject.title).to eq("Eating your own Dog Food")
450
+ expect(subject.publisher).to eq("Zenodo")
451
+ expect(subject.publication_year).to eq(2016)
452
+ end
453
+
454
+ it "change publication_year" do
455
+ input = fixture_path + 'datacite.xml'
456
+ publication_year = 2017
457
+ subject = Bolognese::Metadata.new(input: input, publication_year: publication_year)
458
+ expect(subject.valid?).to be true
459
+ expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
460
+ expect(subject.doi).to eq("10.5438/4k3m-nyvg")
461
+ expect(subject.title).to eq("Eating your own Dog Food")
462
+ expect(subject.publisher).to eq("DataCite")
463
+ expect(subject.publication_year).to eq(2017)
464
+ expect(subject.resource_type_general).to eq("Text")
465
+ expect(subject.additional_type).to eq("BlogPosting")
466
+ end
467
+
468
+ it "change resource_type_general" do
469
+ input = fixture_path + 'datacite.xml'
470
+ resource_type_general = "Software"
471
+ subject = Bolognese::Metadata.new(input: input, resource_type_general: resource_type_general)
472
+ expect(subject.valid?).to be true
473
+ expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
474
+ expect(subject.doi).to eq("10.5438/4k3m-nyvg")
475
+ expect(subject.title).to eq("Eating your own Dog Food")
476
+ expect(subject.publisher).to eq("DataCite")
477
+ expect(subject.publication_year).to eq(2016)
478
+ expect(subject.resource_type_general).to eq("Software")
479
+ expect(subject.additional_type).to eq("BlogPosting")
480
+ end
481
+
482
+ it "change additional_type" do
483
+ input = fixture_path + 'datacite.xml'
484
+ additional_type = "ScholarlyArticle"
485
+ subject = Bolognese::Metadata.new(input: input, additional_type: additional_type)
486
+ expect(subject.valid?).to be true
487
+ expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
488
+ expect(subject.doi).to eq("10.5438/4k3m-nyvg")
489
+ expect(subject.title).to eq("Eating your own Dog Food")
490
+ expect(subject.publisher).to eq("DataCite")
491
+ expect(subject.publication_year).to eq(2016)
492
+ expect(subject.resource_type_general).to eq("Text")
493
+ expect(subject.additional_type).to eq("ScholarlyArticle")
494
+ expect(subject.description).to eq("type"=>"Abstract", "text"=>"Eating your own dog food is a slang term to describe that an organization should itself use the products and services it provides. For DataCite this means that we should use DOIs with appropriate metadata and strategies for long-term preservation for...")
495
+ end
496
+
497
+ it "change description" do
498
+ input = fixture_path + 'datacite.xml'
499
+ description = "Eating your own dog food is a slang term to describe that an organization should itself use the products and services it provides. For DataCite this means that we should use DOIs with appropriate metadata and strategies for long-term preservation for..."
500
+ subject = Bolognese::Metadata.new(input: input, description: description)
501
+ expect(subject.valid?).to be true
502
+ expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
503
+ expect(subject.doi).to eq("10.5438/4k3m-nyvg")
504
+ expect(subject.title).to eq("Eating your own Dog Food")
505
+ expect(subject.publisher).to eq("DataCite")
506
+ expect(subject.publication_year).to eq(2016)
507
+ expect(subject.resource_type_general).to eq("Text")
508
+ expect(subject.additional_type).to eq("BlogPosting")
509
+ expect(subject.description).to eq(description)
510
+ end
511
+
512
+ it "change license" do
513
+ input = fixture_path + 'datacite.xml'
514
+ license = { "id"=>"http://creativecommons.org/publicdomain/zero/1.0" }
515
+ subject = Bolognese::Metadata.new(input: input, license: license)
516
+ expect(subject.valid?).to be true
517
+ expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
518
+ expect(subject.doi).to eq("10.5438/4k3m-nyvg")
519
+ expect(subject.title).to eq("Eating your own Dog Food")
520
+ expect(subject.publisher).to eq("DataCite")
521
+ expect(subject.publication_year).to eq(2016)
522
+ expect(subject.resource_type_general).to eq("Text")
523
+ expect(subject.additional_type).to eq("BlogPosting")
524
+ expect(subject.license).to eq(license)
525
+ expect(subject.date_published).to eq("2016-12-20")
526
+ end
527
+
528
+ it "change date_published" do
529
+ input = fixture_path + 'datacite.xml'
530
+ date_published = "2017-12-20"
531
+ subject = Bolognese::Metadata.new(input: input, date_published: date_published)
532
+ expect(subject.valid?).to be true
533
+ expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
534
+ expect(subject.doi).to eq("10.5438/4k3m-nyvg")
535
+ expect(subject.title).to eq("Eating your own Dog Food")
536
+ expect(subject.publisher).to eq("DataCite")
537
+ expect(subject.publication_year).to eq(2017)
538
+ expect(subject.resource_type_general).to eq("Text")
539
+ expect(subject.additional_type).to eq("BlogPosting")
540
+ expect(subject.date_published).to eq(date_published)
541
+ end
542
+ end
406
543
  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: 0.9.79
4
+ version: 0.9.80
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-03-02 00:00:00.000000000 Z
11
+ date: 2018-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maremma