briard 2.4.1 → 2.6.0

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 (81) 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/.rubocop.yml +144 -620
  5. data/.rubocop_todo.yml +76 -0
  6. data/CHANGELOG.md +22 -0
  7. data/Gemfile +2 -0
  8. data/Gemfile.lock +43 -6
  9. data/Rakefile +1 -1
  10. data/{bolognese.gemspec → briard.gemspec} +46 -38
  11. data/lib/briard/array.rb +2 -2
  12. data/lib/briard/author_utils.rb +79 -71
  13. data/lib/briard/cli.rb +12 -13
  14. data/lib/briard/crossref_utils.rb +73 -61
  15. data/lib/briard/datacite_utils.rb +132 -106
  16. data/lib/briard/doi_utils.rb +10 -10
  17. data/lib/briard/metadata.rb +96 -106
  18. data/lib/briard/metadata_utils.rb +87 -78
  19. data/lib/briard/readers/bibtex_reader.rb +65 -65
  20. data/lib/briard/readers/cff_reader.rb +88 -70
  21. data/lib/briard/readers/citeproc_reader.rb +90 -84
  22. data/lib/briard/readers/codemeta_reader.rb +68 -50
  23. data/lib/briard/readers/crosscite_reader.rb +2 -2
  24. data/lib/briard/readers/crossref_reader.rb +249 -210
  25. data/lib/briard/readers/datacite_json_reader.rb +3 -3
  26. data/lib/briard/readers/datacite_reader.rb +225 -189
  27. data/lib/briard/readers/npm_reader.rb +49 -42
  28. data/lib/briard/readers/ris_reader.rb +82 -80
  29. data/lib/briard/readers/schema_org_reader.rb +182 -159
  30. data/lib/briard/string.rb +1 -1
  31. data/lib/briard/utils.rb +4 -4
  32. data/lib/briard/version.rb +3 -1
  33. data/lib/briard/whitelist_scrubber.rb +11 -4
  34. data/lib/briard/writers/bibtex_writer.rb +14 -8
  35. data/lib/briard/writers/cff_writer.rb +33 -26
  36. data/lib/briard/writers/codemeta_writer.rb +19 -15
  37. data/lib/briard/writers/csv_writer.rb +6 -4
  38. data/lib/briard/writers/datacite_json_writer.rb +8 -2
  39. data/lib/briard/writers/jats_writer.rb +33 -28
  40. data/lib/briard/writers/rdf_xml_writer.rb +1 -1
  41. data/lib/briard/writers/ris_writer.rb +30 -18
  42. data/lib/briard/writers/turtle_writer.rb +1 -1
  43. data/lib/briard.rb +6 -6
  44. data/rubocop.sarif +0 -0
  45. data/spec/array_spec.rb +5 -5
  46. data/spec/author_utils_spec.rb +151 -132
  47. data/spec/datacite_utils_spec.rb +135 -83
  48. data/spec/doi_utils_spec.rb +168 -164
  49. data/spec/find_from_format_spec.rb +69 -69
  50. data/spec/fixtures/vcr_cassettes/Briard_Metadata/sanitize/onlies_keep_specific_tags.yml +65 -0
  51. data/spec/fixtures/vcr_cassettes/Briard_Metadata/sanitize/removes_a_tags.yml +65 -0
  52. data/spec/metadata_spec.rb +91 -90
  53. data/spec/readers/bibtex_reader_spec.rb +43 -38
  54. data/spec/readers/cff_reader_spec.rb +165 -153
  55. data/spec/readers/citeproc_reader_spec.rb +45 -40
  56. data/spec/readers/codemeta_reader_spec.rb +128 -115
  57. data/spec/readers/crosscite_reader_spec.rb +34 -24
  58. data/spec/readers/crossref_reader_spec.rb +1098 -939
  59. data/spec/readers/datacite_json_reader_spec.rb +53 -40
  60. data/spec/readers/datacite_reader_spec.rb +1541 -1337
  61. data/spec/readers/npm_reader_spec.rb +48 -43
  62. data/spec/readers/ris_reader_spec.rb +53 -47
  63. data/spec/readers/schema_org_reader_spec.rb +329 -267
  64. data/spec/spec_helper.rb +6 -5
  65. data/spec/utils_spec.rb +371 -347
  66. data/spec/writers/bibtex_writer_spec.rb +143 -143
  67. data/spec/writers/cff_writer_spec.rb +96 -90
  68. data/spec/writers/citation_writer_spec.rb +34 -33
  69. data/spec/writers/citeproc_writer_spec.rb +226 -224
  70. data/spec/writers/codemeta_writer_spec.rb +18 -16
  71. data/spec/writers/crosscite_writer_spec.rb +91 -73
  72. data/spec/writers/crossref_writer_spec.rb +99 -91
  73. data/spec/writers/csv_writer_spec.rb +70 -70
  74. data/spec/writers/datacite_json_writer_spec.rb +78 -68
  75. data/spec/writers/datacite_writer_spec.rb +417 -322
  76. data/spec/writers/jats_writer_spec.rb +177 -161
  77. data/spec/writers/rdf_xml_writer_spec.rb +68 -63
  78. data/spec/writers/ris_writer_spec.rb +162 -162
  79. data/spec/writers/turtle_writer_spec.rb +47 -47
  80. metadata +250 -160
  81. data/.github/workflows/release.yml +0 -47
@@ -3,61 +3,66 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Briard::Metadata, vcr: true do
6
- let(:input) { fixture_path + "crossref.bib" }
6
+ subject { described_class.new(input: input) }
7
7
 
8
- subject { Briard::Metadata.new(input: input) }
8
+ let(:input) { "#{fixture_path}crossref.bib" }
9
9
 
10
- context "detect format" do
11
- it "extension" do
10
+ context 'detect format' do
11
+ it 'extension' do
12
12
  expect(subject.valid?).to be true
13
13
  end
14
14
 
15
- it "string" do
16
- Briard::Metadata.new(input: IO.read(input).strip)
15
+ it 'string' do
16
+ described_class.new(input: File.read(input).strip)
17
17
  expect(subject.valid?).to be true
18
- expect(subject.id).to eq("https://doi.org/10.7554/elife.01567")
18
+ expect(subject.id).to eq('https://doi.org/10.7554/elife.01567')
19
19
  end
20
20
  end
21
21
 
22
- context "get bibtex raw" do
23
- it "Crossref DOI" do
24
- expect(subject.raw).to eq(IO.read(input).strip)
22
+ context 'get bibtex raw' do
23
+ it 'Crossref DOI' do
24
+ expect(subject.raw).to eq(File.read(input).strip)
25
25
  end
26
26
  end
27
27
 
28
- context "get bibtex metadata" do
29
- it "Crossref DOI" do
28
+ context 'get bibtex metadata' do
29
+ it 'Crossref DOI' do
30
30
  expect(subject.valid?).to be true
31
- expect(subject.id).to eq("https://doi.org/10.7554/elife.01567")
32
- expect(subject.types).to eq("bibtex"=>"article", "citeproc"=>"article-journal", "resourceTypeGeneral"=>"JournalArticle", "resourceType"=>"JournalArticle", "ris"=>"JOUR", "schemaOrg"=>"ScholarlyArticle")
33
- expect(subject.url).to eq("http://elifesciences.org/lookup/doi/10.7554/eLife.01567")
31
+ expect(subject.id).to eq('https://doi.org/10.7554/elife.01567')
32
+ expect(subject.types).to eq('bibtex' => 'article', 'citeproc' => 'article-journal',
33
+ 'resourceTypeGeneral' => 'JournalArticle', 'resourceType' => 'JournalArticle', 'ris' => 'JOUR', 'schemaOrg' => 'ScholarlyArticle')
34
+ expect(subject.url).to eq('http://elifesciences.org/lookup/doi/10.7554/eLife.01567')
34
35
  expect(subject.creators.length).to eq(5)
35
- expect(subject.creators.first).to eq("familyName"=>"Sankar", "givenName"=>"Martial", "name"=>"Sankar, Martial", "nameType"=>"Personal")
36
- expect(subject.titles).to eq([{"title"=>"Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth"}])
37
- expect(subject.descriptions.first["description"]).to start_with("Among various advantages, their small size makes model organisms preferred subjects of investigation.")
38
- expect(subject.rights_list).to eq([{"rights"=>"Creative Commons Attribution 3.0 Unported",
39
- "rightsIdentifier"=>"cc-by-3.0",
40
- "rightsIdentifierScheme"=>"SPDX",
41
- "rightsUri"=>"https://creativecommons.org/licenses/by/3.0/legalcode",
42
- "schemeUri"=>"https://spdx.org/licenses/"}])
43
- expect(subject.dates).to eq([{"date"=>"2014", "dateType"=>"Issued"}])
44
- expect(subject.publication_year).to eq("2014")
45
- expect(subject.related_identifiers).to eq([{"relatedIdentifier"=>"2050-084X", "relatedIdentifierType"=>"ISSN", "relationType"=>"IsPartOf", "title"=>"eLife", "type"=>"Periodical"}])
36
+ expect(subject.creators.first).to eq('familyName' => 'Sankar', 'givenName' => 'Martial',
37
+ 'name' => 'Sankar, Martial', 'nameType' => 'Personal')
38
+ expect(subject.titles).to eq([{ 'title' => 'Automated quantitative histology reveals vascular morphodynamics during Arabidopsis hypocotyl secondary growth' }])
39
+ expect(subject.descriptions.first['description']).to start_with('Among various advantages, their small size makes model organisms preferred subjects of investigation.')
40
+ expect(subject.rights_list).to eq([{ 'rights' => 'Creative Commons Attribution 3.0 Unported',
41
+ 'rightsIdentifier' => 'cc-by-3.0',
42
+ 'rightsIdentifierScheme' => 'SPDX',
43
+ 'rightsUri' => 'https://creativecommons.org/licenses/by/3.0/legalcode',
44
+ 'schemeUri' => 'https://spdx.org/licenses/' }])
45
+ expect(subject.dates).to eq([{ 'date' => '2014', 'dateType' => 'Issued' }])
46
+ expect(subject.publication_year).to eq('2014')
47
+ expect(subject.related_identifiers).to eq([{ 'relatedIdentifier' => '2050-084X',
48
+ 'relatedIdentifierType' => 'ISSN', 'relationType' => 'IsPartOf', 'title' => 'eLife', 'type' => 'Periodical' }])
46
49
  end
47
50
 
48
- it "DOI does not exist" do
49
- input = fixture_path + "pure.bib"
50
- doi = "10.7554/elife.01567"
51
- subject = Briard::Metadata.new(input: input, doi: doi)
51
+ it 'DOI does not exist' do
52
+ input = "#{fixture_path}pure.bib"
53
+ doi = '10.7554/elife.01567'
54
+ subject = described_class.new(input: input, doi: doi)
52
55
  expect(subject.valid?).to be false
53
- expect(subject.state).to eq("not_found")
54
- expect(subject.id).to eq("https://doi.org/10.7554/elife.01567")
55
- expect(subject.types).to eq("bibtex"=>"phdthesis", "citeproc"=>"thesis", "resourceTypeGeneral"=>"Dissertation", "resourceType"=>"Dissertation", "ris"=>"THES", "schemaOrg"=>"Thesis")
56
- expect(subject.creators).to eq([{"familyName"=>"Toparlar", "givenName"=>"Y.", "name"=>"Toparlar, Y.", "nameType"=>"Personal"}])
57
- 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"}])
58
- expect(subject.descriptions.first["description"]).to start_with("Designing the climates of cities")
59
- expect(subject.dates).to eq([{"date"=>"2018", "dateType"=>"Issued"}])
60
- expect(subject.publication_year).to eq("2018")
56
+ expect(subject.state).to eq('not_found')
57
+ expect(subject.id).to eq('https://doi.org/10.7554/elife.01567')
58
+ expect(subject.types).to eq('bibtex' => 'phdthesis', 'citeproc' => 'thesis',
59
+ 'resourceTypeGeneral' => 'Dissertation', 'resourceType' => 'Dissertation', 'ris' => 'THES', 'schemaOrg' => 'Thesis')
60
+ expect(subject.creators).to eq([{ 'familyName' => 'Toparlar', 'givenName' => 'Y.',
61
+ 'name' => 'Toparlar, Y.', 'nameType' => 'Personal' }])
62
+ 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' }])
63
+ expect(subject.descriptions.first['description']).to start_with('Designing the climates of cities')
64
+ expect(subject.dates).to eq([{ 'date' => '2018', 'dateType' => 'Issued' }])
65
+ expect(subject.publication_year).to eq('2018')
61
66
  end
62
67
  end
63
68
  end
@@ -3,170 +3,182 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Briard::Metadata, vcr: true do
6
- let(:input) { "https://github.com/citation-file-format/ruby-cff/blob/main/CITATION.cff" }
6
+ subject { described_class.new(input: input) }
7
7
 
8
- subject { Briard::Metadata.new(input: input) }
8
+ let(:input) { 'https://github.com/citation-file-format/ruby-cff/blob/main/CITATION.cff' }
9
9
 
10
- context "get cff metadata" do
11
- it "ruby-cff" do
10
+ context 'get cff metadata' do
11
+ it 'ruby-cff' do
12
12
  expect(subject.valid?).to be true
13
- expect(subject.id).to eq("https://doi.org/10.5281/zenodo.1184077")
14
- expect(subject.url).to eq("https://github.com/citation-file-format/ruby-cff")
15
- expect(subject.types).to eq("bibtex"=>"misc", "citeproc"=>"article-journal", "resourceTypeGeneral"=>"Software", "ris"=>"COMP", "schemaOrg"=>"SoftwareSourceCode")
16
- expect(subject.creators).to eq([{"affiliation"=>[{"name"=>"The University of Manchester, UK"}], "familyName"=>"Haines", "givenName"=>"Robert", "name"=>"Haines, Robert", "nameIdentifiers"=>
17
- [{"nameIdentifier"=>"https://orcid.org/0000-0002-9538-7919",
18
- "nameIdentifierScheme"=>"ORCID",
19
- "schemeUri"=>"https://orcid.org"}], "nameType"=>"Personal"}, {"name"=>"The Ruby Citation File Format Developers", "nameType"=>"Organizational"}])
20
- expect(subject.titles).to eq([{"title"=>"Ruby CFF Library"}])
21
- expect(subject.descriptions.first["description"]).to start_with("This library provides a Ruby interface to manipulate Citation File Format files")
22
- expect(subject.subjects).to eq([{"subject"=>"ruby"},
23
- {"subject"=>"credit"},
24
- {"subject"=>"software citation"},
25
- {"subject"=>"research software"},
26
- {"subject"=>"software sustainability"},
27
- {"subject"=>"metadata"},
28
- {"subject"=>"citation file format"},
29
- {"subject"=>"cff"}])
30
- expect(subject.version_info).to eq("0.9.0")
31
- expect(subject.dates).to eq([{"date"=>"2021-08-18", "dateType"=>"Issued"}])
32
- expect(subject.publication_year).to eq("2021")
33
- expect(subject.publisher).to eq("GitHub")
34
- expect(subject.rights_list).to eq([{"rights"=>"Apache License 2.0",
35
- "rightsIdentifier"=>"apache-2.0",
36
- "rightsIdentifierScheme"=>"SPDX",
37
- "rightsUri"=>"http://www.apache.org/licenses/LICENSE-2.0",
38
- "schemeUri"=>"https://spdx.org/licenses/"}])
39
- expect(subject.related_identifiers).to eq([{"relatedIdentifier"=>"https://doi.org/10.5281/zenodo.1003149", "relatedIdentifierType"=>"DOI", "relationType"=>"References"}])
13
+ expect(subject.id).to eq('https://doi.org/10.5281/zenodo.1184077')
14
+ expect(subject.url).to eq('https://github.com/citation-file-format/ruby-cff')
15
+ expect(subject.types).to eq('bibtex' => 'misc', 'citeproc' => 'article-journal',
16
+ 'resourceTypeGeneral' => 'Software', 'ris' => 'COMP', 'schemaOrg' => 'SoftwareSourceCode')
17
+ expect(subject.creators).to eq([{ 'affiliation' => [{ 'name' => 'The University of Manchester, UK' }], 'familyName' => 'Haines', 'givenName' => 'Robert', 'name' => 'Haines, Robert', 'nameIdentifiers' =>
18
+ [{ 'nameIdentifier' => 'https://orcid.org/0000-0002-9538-7919',
19
+ 'nameIdentifierScheme' => 'ORCID',
20
+ 'schemeUri' => 'https://orcid.org' }], 'nameType' => 'Personal' }, { 'name' => 'The Ruby Citation File Format Developers', 'nameType' => 'Organizational' }])
21
+ expect(subject.titles).to eq([{ 'title' => 'Ruby CFF Library' }])
22
+ expect(subject.descriptions.first['description']).to start_with('This library provides a Ruby interface to manipulate Citation File Format files')
23
+ expect(subject.subjects).to eq([{ 'subject' => 'ruby' },
24
+ { 'subject' => 'credit' },
25
+ { 'subject' => 'software citation' },
26
+ { 'subject' => 'research software' },
27
+ { 'subject' => 'software sustainability' },
28
+ { 'subject' => 'metadata' },
29
+ { 'subject' => 'citation file format' },
30
+ { 'subject' => 'cff' }])
31
+ expect(subject.version_info).to eq('0.9.0')
32
+ expect(subject.dates).to eq([{ 'date' => '2021-08-18', 'dateType' => 'Issued' }])
33
+ expect(subject.publication_year).to eq('2021')
34
+ expect(subject.publisher).to eq('GitHub')
35
+ expect(subject.rights_list).to eq([{ 'rights' => 'Apache License 2.0',
36
+ 'rightsIdentifier' => 'apache-2.0',
37
+ 'rightsIdentifierScheme' => 'SPDX',
38
+ 'rightsUri' => 'http://www.apache.org/licenses/LICENSE-2.0',
39
+ 'schemeUri' => 'https://spdx.org/licenses/' }])
40
+ expect(subject.related_identifiers).to eq([{
41
+ 'relatedIdentifier' => 'https://doi.org/10.5281/zenodo.1003149', 'relatedIdentifierType' => 'DOI', 'relationType' => 'References'
42
+ }])
40
43
  end
41
44
 
42
- it "cff-converter-python" do
43
- input = "https://github.com/citation-file-format/cff-converter-python/blob/main/CITATION.cff"
44
- subject = Briard::Metadata.new(input: input)
45
- expect(subject.id).to eq("https://doi.org/10.5281/zenodo.1162057")
46
- expect(subject.url).to eq("https://github.com/citation-file-format/cff-converter-python")
47
- expect(subject.types).to eq("bibtex"=>"misc", "citeproc"=>"article-journal", "resourceTypeGeneral"=>"Software", "ris"=>"COMP", "schemaOrg"=>"SoftwareSourceCode")
48
- expect(subject.creators).to eq([{"affiliation"=>[{"name"=>"Netherlands eScience Center"}],
49
- "familyName"=>"Spaaks",
50
- "givenName"=>"Jurriaan H.",
51
- "name"=>"Spaaks, Jurriaan H.",
52
- "nameIdentifiers"=>
53
- [{"nameIdentifier"=>"https://orcid.org/0000-0002-7064-4069",
54
- "nameIdentifierScheme"=>"ORCID",
55
- "schemeUri"=>"https://orcid.org"}],
56
- "nameType"=>"Personal"},
57
- {"affiliation"=>[{"name"=>"Netherlands eScience Center"}],
58
- "familyName"=>"Klaver",
59
- "givenName"=>"Tom",
60
- "name"=>"Klaver, Tom",
61
- "nameType"=>"Personal"},
62
- {"affiliation"=>[{"name"=>"Netherlands eScience Center"}],
63
- "familyName"=>"Verhoeven",
64
- "givenName"=>"Stefan",
65
- "name"=>"Verhoeven, Stefan",
66
- "nameIdentifiers"=>
67
- [{"nameIdentifier"=>"https://orcid.org/0000-0002-5821-2060",
68
- "nameIdentifierScheme"=>"ORCID",
69
- "schemeUri"=>"https://orcid.org"}],
70
- "nameType"=>"Personal"},
71
- {"affiliation"=>[{"name"=>"Humboldt-Universit??t zu Berlin"}],
72
- "familyName"=>"Druskat",
73
- "givenName"=>"Stephan",
74
- "name"=>"Druskat, Stephan",
75
- "nameIdentifiers"=>
76
- [{"nameIdentifier"=>"https://orcid.org/0000-0003-4925-7248",
77
- "nameIdentifierScheme"=>"ORCID",
78
- "schemeUri"=>"https://orcid.org"}],
79
- "nameType"=>"Personal"},
80
- {"affiliation"=>[{"name"=>"University of Oslo"}],
81
- "familyName"=>"Leoncio",
82
- "givenName"=>"Waldir",
83
- "name"=>"Leoncio, Waldir",
84
- "nameType"=>"Personal"}])
85
- expect(subject.titles).to eq([{"title"=>"cffconvert"}])
86
- expect(subject.descriptions.first["description"]).to start_with("Command line program to validate and convert CITATION.cff files")
87
- expect(subject.subjects).to eq([{"subject"=>"bibliography"},
88
- {"subject"=>"bibtex"},
89
- {"subject"=>"cff"},
90
- {"subject"=>"citation"},
91
- {"subject"=>"citation.cff"},
92
- {"subject"=>"codemeta"},
93
- {"subject"=>"endnote"},
94
- {"subject"=>"ris"},
95
- {"subject"=>"citation file format"}])
96
- expect(subject.version_info).to eq("2.0.0")
97
- expect(subject.dates).to eq([{"date"=>"2021-09-22", "dateType"=>"Issued"}])
98
- expect(subject.publication_year).to eq("2021")
99
- expect(subject.publisher).to eq("GitHub")
100
- expect(subject.rights_list).to eq([{"rights"=>"Apache License 2.0",
101
- "rightsIdentifier"=>"apache-2.0",
102
- "rightsIdentifierScheme"=>"SPDX",
103
- "rightsUri"=>"http://www.apache.org/licenses/LICENSE-2.0",
104
- "schemeUri"=>"https://spdx.org/licenses/"}])
105
- expect(subject.related_identifiers).to eq([{"relatedIdentifier"=>"https://doi.org/10.5281/zenodo.1310751", "relatedIdentifierType"=>"DOI", "relationType"=>"References"}])
45
+ it 'cff-converter-python' do
46
+ input = 'https://github.com/citation-file-format/cff-converter-python/blob/main/CITATION.cff'
47
+ subject = described_class.new(input: input)
48
+ expect(subject.id).to eq('https://doi.org/10.5281/zenodo.1162057')
49
+ expect(subject.url).to eq('https://github.com/citation-file-format/cff-converter-python')
50
+ expect(subject.types).to eq('bibtex' => 'misc', 'citeproc' => 'article-journal',
51
+ 'resourceTypeGeneral' => 'Software', 'ris' => 'COMP', 'schemaOrg' => 'SoftwareSourceCode')
52
+ expect(subject.creators).to eq([{ 'affiliation' => [{ 'name' => 'Netherlands eScience Center' }],
53
+ 'familyName' => 'Spaaks',
54
+ 'givenName' => 'Jurriaan H.',
55
+ 'name' => 'Spaaks, Jurriaan H.',
56
+ 'nameIdentifiers' =>
57
+ [{ 'nameIdentifier' => 'https://orcid.org/0000-0002-7064-4069',
58
+ 'nameIdentifierScheme' => 'ORCID',
59
+ 'schemeUri' => 'https://orcid.org' }],
60
+ 'nameType' => 'Personal' },
61
+ { 'affiliation' => [{ 'name' => 'Netherlands eScience Center' }],
62
+ 'familyName' => 'Klaver',
63
+ 'givenName' => 'Tom',
64
+ 'name' => 'Klaver, Tom',
65
+ 'nameType' => 'Personal' },
66
+ { 'affiliation' => [{ 'name' => 'Netherlands eScience Center' }],
67
+ 'familyName' => 'Verhoeven',
68
+ 'givenName' => 'Stefan',
69
+ 'name' => 'Verhoeven, Stefan',
70
+ 'nameIdentifiers' =>
71
+ [{ 'nameIdentifier' => 'https://orcid.org/0000-0002-5821-2060',
72
+ 'nameIdentifierScheme' => 'ORCID',
73
+ 'schemeUri' => 'https://orcid.org' }],
74
+ 'nameType' => 'Personal' },
75
+ { 'affiliation' => [{ 'name' => 'Humboldt-Universit??t zu Berlin' }],
76
+ 'familyName' => 'Druskat',
77
+ 'givenName' => 'Stephan',
78
+ 'name' => 'Druskat, Stephan',
79
+ 'nameIdentifiers' =>
80
+ [{ 'nameIdentifier' => 'https://orcid.org/0000-0003-4925-7248',
81
+ 'nameIdentifierScheme' => 'ORCID',
82
+ 'schemeUri' => 'https://orcid.org' }],
83
+ 'nameType' => 'Personal' },
84
+ { 'affiliation' => [{ 'name' => 'University of Oslo' }],
85
+ 'familyName' => 'Leoncio',
86
+ 'givenName' => 'Waldir',
87
+ 'name' => 'Leoncio, Waldir',
88
+ 'nameType' => 'Personal' }])
89
+ expect(subject.titles).to eq([{ 'title' => 'cffconvert' }])
90
+ expect(subject.descriptions.first['description']).to start_with('Command line program to validate and convert CITATION.cff files')
91
+ expect(subject.subjects).to eq([{ 'subject' => 'bibliography' },
92
+ { 'subject' => 'bibtex' },
93
+ { 'subject' => 'cff' },
94
+ { 'subject' => 'citation' },
95
+ { 'subject' => 'citation.cff' },
96
+ { 'subject' => 'codemeta' },
97
+ { 'subject' => 'endnote' },
98
+ { 'subject' => 'ris' },
99
+ { 'subject' => 'citation file format' }])
100
+ expect(subject.version_info).to eq('2.0.0')
101
+ expect(subject.dates).to eq([{ 'date' => '2021-09-22', 'dateType' => 'Issued' }])
102
+ expect(subject.publication_year).to eq('2021')
103
+ expect(subject.publisher).to eq('GitHub')
104
+ expect(subject.rights_list).to eq([{ 'rights' => 'Apache License 2.0',
105
+ 'rightsIdentifier' => 'apache-2.0',
106
+ 'rightsIdentifierScheme' => 'SPDX',
107
+ 'rightsUri' => 'http://www.apache.org/licenses/LICENSE-2.0',
108
+ 'schemeUri' => 'https://spdx.org/licenses/' }])
109
+ expect(subject.related_identifiers).to eq([{
110
+ 'relatedIdentifier' => 'https://doi.org/10.5281/zenodo.1310751', 'relatedIdentifierType' => 'DOI', 'relationType' => 'References'
111
+ }])
106
112
  end
107
113
 
108
- it "ruby-cff" do
114
+ it 'ruby-cff' do
109
115
  expect(subject.valid?).to be true
110
- expect(subject.id).to eq("https://doi.org/10.5281/zenodo.1184077")
111
- expect(subject.url).to eq("https://github.com/citation-file-format/ruby-cff")
112
- expect(subject.types).to eq("bibtex"=>"misc", "citeproc"=>"article-journal", "resourceTypeGeneral"=>"Software", "ris"=>"COMP", "schemaOrg"=>"SoftwareSourceCode")
113
- expect(subject.creators).to eq([{"affiliation"=>[{"name"=>"The University of Manchester, UK"}], "familyName"=>"Haines", "givenName"=>"Robert", "name"=>"Haines, Robert", "nameIdentifiers"=>
114
- [{"nameIdentifier"=>"https://orcid.org/0000-0002-9538-7919",
115
- "nameIdentifierScheme"=>"ORCID",
116
- "schemeUri"=>"https://orcid.org"}], "nameType"=>"Personal"}, {"name"=>"The Ruby Citation File Format Developers", "nameType"=>"Organizational"}])
117
- expect(subject.titles).to eq([{"title"=>"Ruby CFF Library"}])
118
- expect(subject.descriptions.first["description"]).to start_with("This library provides a Ruby interface to manipulate Citation File Format files")
119
- expect(subject.subjects).to eq([{"subject"=>"ruby"},
120
- {"subject"=>"credit"},
121
- {"subject"=>"software citation"},
122
- {"subject"=>"research software"},
123
- {"subject"=>"software sustainability"},
124
- {"subject"=>"metadata"},
125
- {"subject"=>"citation file format"},
126
- {"subject"=>"cff"}])
127
- expect(subject.version_info).to eq("0.9.0")
128
- expect(subject.dates).to eq([{"date"=>"2021-08-18", "dateType"=>"Issued"}])
129
- expect(subject.publication_year).to eq("2021")
130
- expect(subject.publisher).to eq("GitHub")
131
- expect(subject.rights_list).to eq([{"rights"=>"Apache License 2.0",
132
- "rightsIdentifier"=>"apache-2.0",
133
- "rightsIdentifierScheme"=>"SPDX",
134
- "rightsUri"=>"http://www.apache.org/licenses/LICENSE-2.0",
135
- "schemeUri"=>"https://spdx.org/licenses/"}])
136
- expect(subject.related_identifiers).to eq([{"relatedIdentifier"=>"https://doi.org/10.5281/zenodo.1003149", "relatedIdentifierType"=>"DOI", "relationType"=>"References"}])
116
+ expect(subject.id).to eq('https://doi.org/10.5281/zenodo.1184077')
117
+ expect(subject.url).to eq('https://github.com/citation-file-format/ruby-cff')
118
+ expect(subject.types).to eq('bibtex' => 'misc', 'citeproc' => 'article-journal',
119
+ 'resourceTypeGeneral' => 'Software', 'ris' => 'COMP', 'schemaOrg' => 'SoftwareSourceCode')
120
+ expect(subject.creators).to eq([{ 'affiliation' => [{ 'name' => 'The University of Manchester, UK' }], 'familyName' => 'Haines', 'givenName' => 'Robert', 'name' => 'Haines, Robert', 'nameIdentifiers' =>
121
+ [{ 'nameIdentifier' => 'https://orcid.org/0000-0002-9538-7919',
122
+ 'nameIdentifierScheme' => 'ORCID',
123
+ 'schemeUri' => 'https://orcid.org' }], 'nameType' => 'Personal' }, { 'name' => 'The Ruby Citation File Format Developers', 'nameType' => 'Organizational' }])
124
+ expect(subject.titles).to eq([{ 'title' => 'Ruby CFF Library' }])
125
+ expect(subject.descriptions.first['description']).to start_with('This library provides a Ruby interface to manipulate Citation File Format files')
126
+ expect(subject.subjects).to eq([{ 'subject' => 'ruby' },
127
+ { 'subject' => 'credit' },
128
+ { 'subject' => 'software citation' },
129
+ { 'subject' => 'research software' },
130
+ { 'subject' => 'software sustainability' },
131
+ { 'subject' => 'metadata' },
132
+ { 'subject' => 'citation file format' },
133
+ { 'subject' => 'cff' }])
134
+ expect(subject.version_info).to eq('0.9.0')
135
+ expect(subject.dates).to eq([{ 'date' => '2021-08-18', 'dateType' => 'Issued' }])
136
+ expect(subject.publication_year).to eq('2021')
137
+ expect(subject.publisher).to eq('GitHub')
138
+ expect(subject.rights_list).to eq([{ 'rights' => 'Apache License 2.0',
139
+ 'rightsIdentifier' => 'apache-2.0',
140
+ 'rightsIdentifierScheme' => 'SPDX',
141
+ 'rightsUri' => 'http://www.apache.org/licenses/LICENSE-2.0',
142
+ 'schemeUri' => 'https://spdx.org/licenses/' }])
143
+ expect(subject.related_identifiers).to eq([{
144
+ 'relatedIdentifier' => 'https://doi.org/10.5281/zenodo.1003149', 'relatedIdentifierType' => 'DOI', 'relationType' => 'References'
145
+ }])
137
146
  end
138
147
 
139
- it "ruby-cff repository url" do
140
- input = "https://github.com/citation-file-format/ruby-cff"
141
- subject = Briard::Metadata.new(input: input)
148
+ it 'ruby-cff repository url' do
149
+ input = 'https://github.com/citation-file-format/ruby-cff'
150
+ subject = described_class.new(input: input)
142
151
  expect(subject.valid?).to be true
143
- expect(subject.id).to eq("https://doi.org/10.5281/zenodo.1184077")
144
- expect(subject.url).to eq("https://github.com/citation-file-format/ruby-cff")
145
- expect(subject.types).to eq("bibtex"=>"misc", "citeproc"=>"article-journal", "resourceTypeGeneral"=>"Software", "ris"=>"COMP", "schemaOrg"=>"SoftwareSourceCode")
146
- expect(subject.creators).to eq([{"affiliation"=>[{"name"=>"The University of Manchester, UK"}], "familyName"=>"Haines", "givenName"=>"Robert", "name"=>"Haines, Robert", "nameIdentifiers"=>
147
- [{"nameIdentifier"=>"https://orcid.org/0000-0002-9538-7919",
148
- "nameIdentifierScheme"=>"ORCID",
149
- "schemeUri"=>"https://orcid.org"}], "nameType"=>"Personal"}, {"name"=>"The Ruby Citation File Format Developers", "nameType"=>"Organizational"}])
150
- expect(subject.titles).to eq([{"title"=>"Ruby CFF Library"}])
151
- expect(subject.descriptions.first["description"]).to start_with("This library provides a Ruby interface to manipulate Citation File Format files")
152
- expect(subject.subjects).to eq([{"subject"=>"ruby"},
153
- {"subject"=>"credit"},
154
- {"subject"=>"software citation"},
155
- {"subject"=>"research software"},
156
- {"subject"=>"software sustainability"},
157
- {"subject"=>"metadata"},
158
- {"subject"=>"citation file format"},
159
- {"subject"=>"cff"}])
160
- expect(subject.version_info).to eq("0.9.0")
161
- expect(subject.dates).to eq([{"date"=>"2021-08-18", "dateType"=>"Issued"}])
162
- expect(subject.publication_year).to eq("2021")
163
- expect(subject.publisher).to eq("GitHub")
164
- expect(subject.rights_list).to eq([{"rights"=>"Apache License 2.0",
165
- "rightsIdentifier"=>"apache-2.0",
166
- "rightsIdentifierScheme"=>"SPDX",
167
- "rightsUri"=>"http://www.apache.org/licenses/LICENSE-2.0",
168
- "schemeUri"=>"https://spdx.org/licenses/"}])
169
- expect(subject.related_identifiers).to eq([{"relatedIdentifier"=>"https://doi.org/10.5281/zenodo.1003149", "relatedIdentifierType"=>"DOI", "relationType"=>"References"}])
152
+ expect(subject.id).to eq('https://doi.org/10.5281/zenodo.1184077')
153
+ expect(subject.url).to eq('https://github.com/citation-file-format/ruby-cff')
154
+ expect(subject.types).to eq('bibtex' => 'misc', 'citeproc' => 'article-journal',
155
+ 'resourceTypeGeneral' => 'Software', 'ris' => 'COMP', 'schemaOrg' => 'SoftwareSourceCode')
156
+ expect(subject.creators).to eq([{ 'affiliation' => [{ 'name' => 'The University of Manchester, UK' }], 'familyName' => 'Haines', 'givenName' => 'Robert', 'name' => 'Haines, Robert', 'nameIdentifiers' =>
157
+ [{ 'nameIdentifier' => 'https://orcid.org/0000-0002-9538-7919',
158
+ 'nameIdentifierScheme' => 'ORCID',
159
+ 'schemeUri' => 'https://orcid.org' }], 'nameType' => 'Personal' }, { 'name' => 'The Ruby Citation File Format Developers', 'nameType' => 'Organizational' }])
160
+ expect(subject.titles).to eq([{ 'title' => 'Ruby CFF Library' }])
161
+ expect(subject.descriptions.first['description']).to start_with('This library provides a Ruby interface to manipulate Citation File Format files')
162
+ expect(subject.subjects).to eq([{ 'subject' => 'ruby' },
163
+ { 'subject' => 'credit' },
164
+ { 'subject' => 'software citation' },
165
+ { 'subject' => 'research software' },
166
+ { 'subject' => 'software sustainability' },
167
+ { 'subject' => 'metadata' },
168
+ { 'subject' => 'citation file format' },
169
+ { 'subject' => 'cff' }])
170
+ expect(subject.version_info).to eq('0.9.0')
171
+ expect(subject.dates).to eq([{ 'date' => '2021-08-18', 'dateType' => 'Issued' }])
172
+ expect(subject.publication_year).to eq('2021')
173
+ expect(subject.publisher).to eq('GitHub')
174
+ expect(subject.rights_list).to eq([{ 'rights' => 'Apache License 2.0',
175
+ 'rightsIdentifier' => 'apache-2.0',
176
+ 'rightsIdentifierScheme' => 'SPDX',
177
+ 'rightsUri' => 'http://www.apache.org/licenses/LICENSE-2.0',
178
+ 'schemeUri' => 'https://spdx.org/licenses/' }])
179
+ expect(subject.related_identifiers).to eq([{
180
+ 'relatedIdentifier' => 'https://doi.org/10.5281/zenodo.1003149', 'relatedIdentifierType' => 'DOI', 'relationType' => 'References'
181
+ }])
170
182
  end
171
183
  end
172
184
  end
@@ -3,59 +3,64 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Briard::Metadata, vcr: true do
6
- let(:input) { fixture_path + "citeproc.json" }
6
+ subject { described_class.new(input: input, from: 'citeproc') }
7
7
 
8
- subject { Briard::Metadata.new(input: input, from: "citeproc") }
8
+ let(:input) { "#{fixture_path}citeproc.json" }
9
9
 
10
- context "get citeproc raw" do
11
- it "BlogPosting" do
12
- expect(subject.raw).to eq(IO.read(input).strip)
10
+ context 'get citeproc raw' do
11
+ it 'BlogPosting' do
12
+ expect(subject.raw).to eq(File.read(input).strip)
13
13
  end
14
14
  end
15
15
 
16
- context "get citeproc metadata" do
17
- it "BlogPosting" do
16
+ context 'get citeproc metadata' do
17
+ it 'BlogPosting' do
18
18
  expect(subject.valid?).to be true
19
- expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
20
- expect(subject.url).to eq("https://blog.datacite.org/eating-your-own-dog-food")
21
- expect(subject.types).to eq("bibtex"=>"article", "citeproc"=>"post-weblog", "resourceTypeGeneral"=>"Text", "ris"=>"GEN", "schemaOrg"=>"BlogPosting")
22
- expect(subject.creators).to eq([{"familyName"=>"Fenner", "givenName"=>"Martin", "name"=>"Fenner, Martin"}])
23
- expect(subject.titles).to eq([{"title"=>"Eating your own Dog Food"}])
24
- expect(subject.descriptions.first["description"]).to start_with("Eating your own dog food")
25
- expect(subject.dates).to eq([{"date"=>"2016-12-20", "dateType"=>"Issued"}])
26
- expect(subject.publication_year).to eq("2016")
19
+ expect(subject.id).to eq('https://doi.org/10.5438/4k3m-nyvg')
20
+ expect(subject.url).to eq('https://blog.datacite.org/eating-your-own-dog-food')
21
+ expect(subject.types).to eq('bibtex' => 'article', 'citeproc' => 'post-weblog',
22
+ 'resourceTypeGeneral' => 'Text', 'ris' => 'GEN', 'schemaOrg' => 'BlogPosting')
23
+ expect(subject.creators).to eq([{ 'familyName' => 'Fenner', 'givenName' => 'Martin',
24
+ 'name' => 'Fenner, Martin' }])
25
+ expect(subject.titles).to eq([{ 'title' => 'Eating your own Dog Food' }])
26
+ expect(subject.descriptions.first['description']).to start_with('Eating your own dog food')
27
+ expect(subject.dates).to eq([{ 'date' => '2016-12-20', 'dateType' => 'Issued' }])
28
+ expect(subject.publication_year).to eq('2016')
27
29
  end
28
30
  end
29
31
 
30
- context "get citeproc no categories" do
31
- it "BlogPosting" do
32
- input = fixture_path + "citeproc-no-categories.json"
33
- subject = Briard::Metadata.new(input: input)
32
+ context 'get citeproc no categories' do
33
+ it 'BlogPosting' do
34
+ input = "#{fixture_path}citeproc-no-categories.json"
35
+ subject = described_class.new(input: input)
34
36
  expect(subject.valid?).to be true
35
- expect(subject.id).to eq("https://doi.org/10.5072/4k3m-nyvg")
36
- expect(subject.url).to eq("https://blog.datacite.org/eating-your-own-dog-food")
37
- expect(subject.types).to eq("bibtex"=>"article", "citeproc"=>"post-weblog", "resourceTypeGeneral"=>"Text", "ris"=>"GEN", "schemaOrg"=>"BlogPosting")
38
- expect(subject.creators).to eq([{"familyName"=>"Fenner", "givenName"=>"Martin", "name"=>"Fenner, Martin"}])
39
- expect(subject.titles).to eq([{"title"=>"Eating your own Dog Food"}])
40
- expect(subject.descriptions.first["description"]).to start_with("Eating your own dog food")
41
- expect(subject.dates).to eq([{"date"=>"2016-12-20", "dateType"=>"Issued"}])
42
- expect(subject.publication_year).to eq("2016")
37
+ expect(subject.id).to eq('https://doi.org/10.5072/4k3m-nyvg')
38
+ expect(subject.url).to eq('https://blog.datacite.org/eating-your-own-dog-food')
39
+ expect(subject.types).to eq('bibtex' => 'article', 'citeproc' => 'post-weblog',
40
+ 'resourceTypeGeneral' => 'Text', 'ris' => 'GEN', 'schemaOrg' => 'BlogPosting')
41
+ expect(subject.creators).to eq([{ 'familyName' => 'Fenner', 'givenName' => 'Martin',
42
+ 'name' => 'Fenner, Martin' }])
43
+ expect(subject.titles).to eq([{ 'title' => 'Eating your own Dog Food' }])
44
+ expect(subject.descriptions.first['description']).to start_with('Eating your own dog food')
45
+ expect(subject.dates).to eq([{ 'date' => '2016-12-20', 'dateType' => 'Issued' }])
46
+ expect(subject.publication_year).to eq('2016')
43
47
  end
44
48
  end
45
49
 
46
- context "get citeproc no author" do
47
- it "Journal article" do
48
- input = fixture_path + "citeproc-no-author.json"
49
- subject = Briard::Metadata.new(input: input)
50
- #expect(subject.valid?).to be true
51
- expect(subject.id).to eq("https://doi.org/10.5438/4k3m-nyvg")
52
- expect(subject.url).to eq("https://blog.datacite.org/eating-your-own-dog-food")
53
- expect(subject.types).to eq("bibtex"=>"article", "citeproc"=>"post-weblog", "resourceTypeGeneral"=>"Text", "ris"=>"GEN", "schemaOrg"=>"BlogPosting")
54
- expect(subject.creators).to eq([{"name"=>":(unav)", "nameType"=>"Organizational"}])
55
- expect(subject.titles).to eq([{"title"=>"Eating your own Dog Food"}])
56
- expect(subject.descriptions.first["description"]).to start_with("Eating your own dog food")
57
- expect(subject.dates).to eq([{"date"=>"2016-12-20", "dateType"=>"Issued"}])
58
- expect(subject.publication_year).to eq("2016")
50
+ context 'get citeproc no author' do
51
+ it 'Journal article' do
52
+ input = "#{fixture_path}citeproc-no-author.json"
53
+ subject = described_class.new(input: input)
54
+ # expect(subject.valid?).to be true
55
+ expect(subject.id).to eq('https://doi.org/10.5438/4k3m-nyvg')
56
+ expect(subject.url).to eq('https://blog.datacite.org/eating-your-own-dog-food')
57
+ expect(subject.types).to eq('bibtex' => 'article', 'citeproc' => 'post-weblog',
58
+ 'resourceTypeGeneral' => 'Text', 'ris' => 'GEN', 'schemaOrg' => 'BlogPosting')
59
+ expect(subject.creators).to eq([{ 'name' => ':(unav)', 'nameType' => 'Organizational' }])
60
+ expect(subject.titles).to eq([{ 'title' => 'Eating your own Dog Food' }])
61
+ expect(subject.descriptions.first['description']).to start_with('Eating your own dog food')
62
+ expect(subject.dates).to eq([{ 'date' => '2016-12-20', 'dateType' => 'Issued' }])
63
+ expect(subject.publication_year).to eq('2016')
59
64
  end
60
65
  end
61
66
  end