briard 2.4.2 → 2.6.1

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.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codeql-analysis.yml +72 -0
  3. data/.github/workflows/rubocop.yml +50 -0
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +144 -620
  6. data/.rubocop_todo.yml +76 -0
  7. data/CHANGELOG.md +18 -0
  8. data/Gemfile +2 -0
  9. data/Gemfile.lock +43 -9
  10. data/Rakefile +1 -1
  11. data/{bolognese.gemspec → briard.gemspec} +46 -39
  12. data/lib/briard/array.rb +2 -2
  13. data/lib/briard/author_utils.rb +79 -71
  14. data/lib/briard/cli.rb +12 -13
  15. data/lib/briard/crossref_utils.rb +73 -61
  16. data/lib/briard/datacite_utils.rb +132 -106
  17. data/lib/briard/doi_utils.rb +10 -10
  18. data/lib/briard/metadata.rb +96 -106
  19. data/lib/briard/metadata_utils.rb +87 -78
  20. data/lib/briard/readers/bibtex_reader.rb +65 -65
  21. data/lib/briard/readers/cff_reader.rb +88 -70
  22. data/lib/briard/readers/citeproc_reader.rb +90 -84
  23. data/lib/briard/readers/codemeta_reader.rb +68 -50
  24. data/lib/briard/readers/crosscite_reader.rb +2 -2
  25. data/lib/briard/readers/crossref_reader.rb +249 -210
  26. data/lib/briard/readers/datacite_json_reader.rb +3 -3
  27. data/lib/briard/readers/datacite_reader.rb +225 -189
  28. data/lib/briard/readers/npm_reader.rb +49 -42
  29. data/lib/briard/readers/ris_reader.rb +82 -80
  30. data/lib/briard/readers/schema_org_reader.rb +182 -159
  31. data/lib/briard/string.rb +1 -1
  32. data/lib/briard/utils.rb +4 -4
  33. data/lib/briard/version.rb +3 -1
  34. data/lib/briard/whitelist_scrubber.rb +11 -4
  35. data/lib/briard/writers/bibtex_writer.rb +14 -8
  36. data/lib/briard/writers/cff_writer.rb +33 -26
  37. data/lib/briard/writers/codemeta_writer.rb +19 -15
  38. data/lib/briard/writers/csv_writer.rb +6 -4
  39. data/lib/briard/writers/datacite_json_writer.rb +8 -2
  40. data/lib/briard/writers/jats_writer.rb +33 -28
  41. data/lib/briard/writers/rdf_xml_writer.rb +1 -1
  42. data/lib/briard/writers/ris_writer.rb +30 -18
  43. data/lib/briard/writers/turtle_writer.rb +1 -1
  44. data/lib/briard.rb +6 -6
  45. data/rubocop.sarif +0 -0
  46. data/spec/array_spec.rb +5 -5
  47. data/spec/author_utils_spec.rb +151 -132
  48. data/spec/datacite_utils_spec.rb +135 -83
  49. data/spec/doi_utils_spec.rb +168 -164
  50. data/spec/find_from_format_spec.rb +69 -69
  51. data/spec/fixtures/vcr_cassettes/Briard_Metadata/sanitize/onlies_keep_specific_tags.yml +65 -0
  52. data/spec/fixtures/vcr_cassettes/Briard_Metadata/sanitize/removes_a_tags.yml +65 -0
  53. data/spec/metadata_spec.rb +91 -90
  54. data/spec/readers/bibtex_reader_spec.rb +43 -38
  55. data/spec/readers/cff_reader_spec.rb +165 -153
  56. data/spec/readers/citeproc_reader_spec.rb +45 -40
  57. data/spec/readers/codemeta_reader_spec.rb +128 -115
  58. data/spec/readers/crosscite_reader_spec.rb +34 -24
  59. data/spec/readers/crossref_reader_spec.rb +1098 -939
  60. data/spec/readers/datacite_json_reader_spec.rb +53 -40
  61. data/spec/readers/datacite_reader_spec.rb +1541 -1337
  62. data/spec/readers/npm_reader_spec.rb +48 -43
  63. data/spec/readers/ris_reader_spec.rb +53 -47
  64. data/spec/readers/schema_org_reader_spec.rb +329 -267
  65. data/spec/spec_helper.rb +6 -5
  66. data/spec/utils_spec.rb +371 -347
  67. data/spec/writers/bibtex_writer_spec.rb +143 -143
  68. data/spec/writers/cff_writer_spec.rb +96 -90
  69. data/spec/writers/citation_writer_spec.rb +34 -33
  70. data/spec/writers/citeproc_writer_spec.rb +226 -224
  71. data/spec/writers/codemeta_writer_spec.rb +18 -16
  72. data/spec/writers/crosscite_writer_spec.rb +91 -73
  73. data/spec/writers/crossref_writer_spec.rb +99 -91
  74. data/spec/writers/csv_writer_spec.rb +70 -70
  75. data/spec/writers/datacite_json_writer_spec.rb +78 -68
  76. data/spec/writers/datacite_writer_spec.rb +417 -322
  77. data/spec/writers/jats_writer_spec.rb +177 -161
  78. data/spec/writers/rdf_xml_writer_spec.rb +68 -63
  79. data/spec/writers/ris_writer_spec.rb +162 -162
  80. data/spec/writers/schema_org_writer_spec.rb +329 -294
  81. data/spec/writers/turtle_writer_spec.rb +47 -47
  82. metadata +242 -166
  83. data/.github/workflows/release.yml +0 -47
@@ -3,83 +3,83 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Briard::Metadata, vcr: true do
6
- context "write metadata as turtle" do
7
- it "Crossref DOI" do
8
- input = fixture_path + "crossref.bib"
9
- subject = Briard::Metadata.new(input: input, from: "bibtex")
6
+ context 'write metadata as turtle' do
7
+ it 'Crossref DOI' do
8
+ input = "#{fixture_path}crossref.bib"
9
+ subject = described_class.new(input: input, from: 'bibtex')
10
10
  ttl = subject.turtle.split("\n")
11
- expect(ttl[0]).to eq("@prefix schema: <http://schema.org/> .")
12
- expect(ttl[2]).to eq("<https://doi.org/10.7554/elife.01567> a schema:ScholarlyArticle;")
11
+ expect(ttl[0]).to eq('@prefix schema: <http://schema.org/> .')
12
+ expect(ttl[2]).to eq('<https://doi.org/10.7554/elife.01567> a schema:ScholarlyArticle;')
13
13
  end
14
14
 
15
- it "Dataset" do
16
- input = "https://doi.org/10.5061/DRYAD.8515"
17
- subject = Briard::Metadata.new(input: input, from: "datacite")
15
+ it 'Dataset' do
16
+ input = 'https://doi.org/10.5061/DRYAD.8515'
17
+ subject = described_class.new(input: input, from: 'datacite')
18
18
  expect(subject.valid?).to be true
19
19
  ttl = subject.turtle.split("\n")
20
- expect(ttl[0]).to eq("@prefix schema: <http://schema.org/> .")
21
- expect(ttl[2]).to eq("<https://doi.org/10.5061/dryad.8515> a schema:Dataset;")
20
+ expect(ttl[0]).to eq('@prefix schema: <http://schema.org/> .')
21
+ expect(ttl[2]).to eq('<https://doi.org/10.5061/dryad.8515> a schema:Dataset;')
22
22
  end
23
23
 
24
- it "BlogPosting" do
25
- input= "https://doi.org/10.5438/4K3M-NYVG"
26
- subject = Briard::Metadata.new(input: input, from: "datacite")
24
+ it 'BlogPosting' do
25
+ input = 'https://doi.org/10.5438/4K3M-NYVG'
26
+ subject = described_class.new(input: input, from: 'datacite')
27
27
  expect(subject.valid?).to be true
28
28
  ttl = subject.turtle.split("\n")
29
- expect(ttl[0]).to eq("@prefix schema: <http://schema.org/> .")
30
- expect(ttl[2]).to eq("<https://doi.org/10.5438/4k3m-nyvg> a schema:ScholarlyArticle;")
29
+ expect(ttl[0]).to eq('@prefix schema: <http://schema.org/> .')
30
+ expect(ttl[2]).to eq('<https://doi.org/10.5438/4k3m-nyvg> a schema:ScholarlyArticle;')
31
31
  end
32
32
 
33
- it "BlogPosting Citeproc JSON" do
34
- input = fixture_path + "citeproc.json"
35
- subject = Briard::Metadata.new(input: input, from: "citeproc")
33
+ it 'BlogPosting Citeproc JSON' do
34
+ input = "#{fixture_path}citeproc.json"
35
+ subject = described_class.new(input: input, from: 'citeproc')
36
36
  ttl = subject.turtle.split("\n")
37
- expect(ttl[0]).to eq("@prefix schema: <http://schema.org/> .")
38
- expect(ttl[2]).to eq("<https://doi.org/10.5438/4k3m-nyvg> a schema:BlogPosting;")
37
+ expect(ttl[0]).to eq('@prefix schema: <http://schema.org/> .')
38
+ expect(ttl[2]).to eq('<https://doi.org/10.5438/4k3m-nyvg> a schema:BlogPosting;')
39
39
  end
40
40
 
41
- it "BlogPosting DataCite JSON" do
42
- input = fixture_path + "datacite.json"
43
- subject = Briard::Metadata.new(input: input, from: "datacite_json")
41
+ it 'BlogPosting DataCite JSON' do
42
+ input = "#{fixture_path}datacite.json"
43
+ subject = described_class.new(input: input, from: 'datacite_json')
44
44
  ttl = subject.turtle.split("\n")
45
- expect(ttl[0]).to eq("@prefix schema: <http://schema.org/> .")
46
- expect(ttl[2]).to eq("<https://doi.org/10.5438/4k3m-nyvg> a schema:ScholarlyArticle;")
45
+ expect(ttl[0]).to eq('@prefix schema: <http://schema.org/> .')
46
+ expect(ttl[2]).to eq('<https://doi.org/10.5438/4k3m-nyvg> a schema:ScholarlyArticle;')
47
47
  end
48
48
 
49
- it "BlogPosting schema.org" do
50
- input = "https://blog.front-matter.io/posts/eating-your-own-dog-food//"
51
- subject = Briard::Metadata.new(input: input, from: "schema_org")
49
+ it 'BlogPosting schema.org' do
50
+ input = 'https://blog.front-matter.io/posts/eating-your-own-dog-food//'
51
+ subject = described_class.new(input: input, from: 'schema_org')
52
52
  expect(subject.valid?).to be true
53
53
  ttl = subject.turtle.split("\n")
54
- expect(ttl[0]).to eq("@prefix schema: <http://schema.org/> .")
55
- expect(ttl[2]).to eq("<https://doi.org/10.53731/r79vxn1-97aq74v-ag58n> a schema:Article;")
56
- expect(ttl[3]).to eq(" schema:author <https://orcid.org/0000-0003-1419-2405>;")
54
+ expect(ttl[0]).to eq('@prefix schema: <http://schema.org/> .')
55
+ expect(ttl[2]).to eq('<https://doi.org/10.53731/r79vxn1-97aq74v-ag58n> a schema:Article;')
56
+ expect(ttl[3]).to eq(' schema:author <https://orcid.org/0000-0003-1419-2405>;')
57
57
  end
58
58
 
59
- it "DataONE" do
60
- input = fixture_path + 'codemeta.json'
61
- subject = Briard::Metadata.new(input: input, from: "codemeta")
59
+ it 'DataONE' do
60
+ input = "#{fixture_path}codemeta.json"
61
+ subject = described_class.new(input: input, from: 'codemeta')
62
62
  ttl = subject.turtle.split("\n")
63
- expect(ttl[0]).to eq("@prefix schema: <http://schema.org/> .")
64
- expect(ttl[2]).to eq("<https://doi.org/10.5063/f1m61h5x> a schema:SoftwareSourceCode;")
63
+ expect(ttl[0]).to eq('@prefix schema: <http://schema.org/> .')
64
+ expect(ttl[2]).to eq('<https://doi.org/10.5063/f1m61h5x> a schema:SoftwareSourceCode;')
65
65
  end
66
66
 
67
- it "journal article" do
68
- input = "10.7554/eLife.01567"
69
- subject = Briard::Metadata.new(input: input, from: "crossref")
67
+ it 'journal article' do
68
+ input = '10.7554/eLife.01567'
69
+ subject = described_class.new(input: input, from: 'crossref')
70
70
  expect(subject.valid?).to be true
71
71
  ttl = subject.turtle.split("\n")
72
- expect(ttl[0]).to eq("@prefix schema: <http://schema.org/> .")
73
- expect(ttl[2]).to eq("<https://doi.org/10.7554/elife.01567> a schema:ScholarlyArticle;")
72
+ expect(ttl[0]).to eq('@prefix schema: <http://schema.org/> .')
73
+ expect(ttl[2]).to eq('<https://doi.org/10.7554/elife.01567> a schema:ScholarlyArticle;')
74
74
  end
75
75
 
76
- it "with pages" do
77
- input = "https://doi.org/10.1155/2012/291294"
78
- subject = Briard::Metadata.new(input: input, from: "crossref")
76
+ it 'with pages' do
77
+ input = 'https://doi.org/10.1155/2012/291294'
78
+ subject = described_class.new(input: input, from: 'crossref')
79
79
  expect(subject.valid?).to be true
80
80
  ttl = subject.turtle.split("\n")
81
- expect(ttl[0]).to eq("@prefix schema: <http://schema.org/> .")
82
- expect(ttl[2]).to eq("<https://doi.org/10.1155/2012/291294> a schema:ScholarlyArticle;")
81
+ expect(ttl[0]).to eq('@prefix schema: <http://schema.org/> .')
82
+ expect(ttl[2]).to eq('<https://doi.org/10.1155/2012/291294> a schema:ScholarlyArticle;')
83
83
  end
84
84
  end
85
85
  end