briard 2.4.2 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/codeql-analysis.yml +72 -0
- data/.github/workflows/rubocop.yml +50 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +144 -620
- data/.rubocop_todo.yml +76 -0
- data/CHANGELOG.md +18 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +43 -9
- data/Rakefile +1 -1
- data/{bolognese.gemspec → briard.gemspec} +46 -39
- data/lib/briard/array.rb +2 -2
- data/lib/briard/author_utils.rb +79 -71
- data/lib/briard/cli.rb +12 -13
- data/lib/briard/crossref_utils.rb +73 -61
- data/lib/briard/datacite_utils.rb +132 -106
- data/lib/briard/doi_utils.rb +10 -10
- data/lib/briard/metadata.rb +96 -106
- data/lib/briard/metadata_utils.rb +87 -78
- data/lib/briard/readers/bibtex_reader.rb +65 -65
- data/lib/briard/readers/cff_reader.rb +88 -70
- data/lib/briard/readers/citeproc_reader.rb +90 -84
- data/lib/briard/readers/codemeta_reader.rb +68 -50
- data/lib/briard/readers/crosscite_reader.rb +2 -2
- data/lib/briard/readers/crossref_reader.rb +249 -210
- data/lib/briard/readers/datacite_json_reader.rb +3 -3
- data/lib/briard/readers/datacite_reader.rb +225 -189
- data/lib/briard/readers/npm_reader.rb +49 -42
- data/lib/briard/readers/ris_reader.rb +82 -80
- data/lib/briard/readers/schema_org_reader.rb +182 -159
- data/lib/briard/string.rb +1 -1
- data/lib/briard/utils.rb +4 -4
- data/lib/briard/version.rb +3 -1
- data/lib/briard/whitelist_scrubber.rb +11 -4
- data/lib/briard/writers/bibtex_writer.rb +14 -8
- data/lib/briard/writers/cff_writer.rb +33 -26
- data/lib/briard/writers/codemeta_writer.rb +19 -15
- data/lib/briard/writers/csv_writer.rb +6 -4
- data/lib/briard/writers/datacite_json_writer.rb +8 -2
- data/lib/briard/writers/jats_writer.rb +33 -28
- data/lib/briard/writers/rdf_xml_writer.rb +1 -1
- data/lib/briard/writers/ris_writer.rb +30 -18
- data/lib/briard/writers/turtle_writer.rb +1 -1
- data/lib/briard.rb +6 -6
- data/rubocop.sarif +0 -0
- data/spec/array_spec.rb +5 -5
- data/spec/author_utils_spec.rb +151 -132
- data/spec/datacite_utils_spec.rb +135 -83
- data/spec/doi_utils_spec.rb +168 -164
- data/spec/find_from_format_spec.rb +69 -69
- data/spec/fixtures/vcr_cassettes/Briard_Metadata/sanitize/onlies_keep_specific_tags.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Briard_Metadata/sanitize/removes_a_tags.yml +65 -0
- data/spec/metadata_spec.rb +91 -90
- data/spec/readers/bibtex_reader_spec.rb +43 -38
- data/spec/readers/cff_reader_spec.rb +165 -153
- data/spec/readers/citeproc_reader_spec.rb +45 -40
- data/spec/readers/codemeta_reader_spec.rb +128 -115
- data/spec/readers/crosscite_reader_spec.rb +34 -24
- data/spec/readers/crossref_reader_spec.rb +1098 -939
- data/spec/readers/datacite_json_reader_spec.rb +53 -40
- data/spec/readers/datacite_reader_spec.rb +1541 -1337
- data/spec/readers/npm_reader_spec.rb +48 -43
- data/spec/readers/ris_reader_spec.rb +53 -47
- data/spec/readers/schema_org_reader_spec.rb +329 -267
- data/spec/spec_helper.rb +6 -5
- data/spec/utils_spec.rb +371 -347
- data/spec/writers/bibtex_writer_spec.rb +143 -143
- data/spec/writers/cff_writer_spec.rb +96 -90
- data/spec/writers/citation_writer_spec.rb +34 -33
- data/spec/writers/citeproc_writer_spec.rb +226 -224
- data/spec/writers/codemeta_writer_spec.rb +18 -16
- data/spec/writers/crosscite_writer_spec.rb +91 -73
- data/spec/writers/crossref_writer_spec.rb +99 -91
- data/spec/writers/csv_writer_spec.rb +70 -70
- data/spec/writers/datacite_json_writer_spec.rb +78 -68
- data/spec/writers/datacite_writer_spec.rb +417 -322
- data/spec/writers/jats_writer_spec.rb +177 -161
- data/spec/writers/rdf_xml_writer_spec.rb +68 -63
- data/spec/writers/ris_writer_spec.rb +162 -162
- data/spec/writers/schema_org_writer_spec.rb +329 -294
- data/spec/writers/turtle_writer_spec.rb +47 -47
- metadata +242 -166
- data/.github/workflows/release.yml +0 -47
@@ -3,29 +3,37 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Briard::Metadata, vcr: true do
|
6
|
-
|
6
|
+
subject { described_class.new(input: input) }
|
7
7
|
|
8
|
-
|
8
|
+
let(:input) { "#{fixture_path}datacite.json" }
|
9
9
|
|
10
|
-
context
|
11
|
-
it
|
12
|
-
expect(subject.raw).to eq(
|
10
|
+
context 'get datacite_json 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
|
17
|
-
it
|
16
|
+
context 'get datacite_json metadata' do
|
17
|
+
it 'BlogPosting' do
|
18
18
|
expect(subject.valid?).to be true
|
19
|
-
expect(subject.types).to eq(
|
20
|
-
|
21
|
-
expect(subject.
|
22
|
-
|
23
|
-
expect(subject.
|
24
|
-
expect(subject.
|
19
|
+
expect(subject.types).to eq('bibtex' => 'article', 'citeproc' => 'article-journal',
|
20
|
+
'resourceType' => 'BlogPosting', 'resourceTypeGeneral' => 'Text', 'ris' => 'RPRT', 'schemaOrg' => 'ScholarlyArticle')
|
21
|
+
expect(subject.creators).to eq([{ 'type' => 'Person',
|
22
|
+
'id' => 'http://orcid.org/0000-0003-1419-2405', 'name' => 'Fenner, Martin', 'givenName' => 'Martin', 'familyName' => 'Fenner' }])
|
23
|
+
expect(subject.titles).to eq([{ 'title' => 'Eating your own Dog Food' }])
|
24
|
+
expect(subject.identifiers).to eq([
|
25
|
+
{ 'identifier' => 'https://doi.org/10.5438/4k3m-nyvg',
|
26
|
+
'identifierType' => 'DOI' }, { 'identifier' => 'MS-49-3632-5083', 'identifierType' => 'Local accession number' }
|
27
|
+
])
|
28
|
+
expect(subject.dates).to eq([{ 'date' => '2016-12-20', 'dateType' => 'Created' },
|
29
|
+
{ 'date' => '2016-12-20', 'dateType' => 'Issued' }, { 'date' => '2016-12-20', 'dateType' => 'Updated' }])
|
30
|
+
expect(subject.publication_year).to eq('2016')
|
25
31
|
expect(subject.related_identifiers.length).to eq(3)
|
26
|
-
expect(subject.related_identifiers.first).to eq(
|
27
|
-
|
28
|
-
expect(subject.
|
32
|
+
expect(subject.related_identifiers.first).to eq('relatedIdentifier' => '10.5438/0000-00ss',
|
33
|
+
'relatedIdentifierType' => 'DOI', 'relationType' => 'IsPartOf')
|
34
|
+
expect(subject.related_identifiers.last).to eq('relatedIdentifier' => '10.5438/55e5-t5c0',
|
35
|
+
'relatedIdentifierType' => 'DOI', 'relationType' => 'References')
|
36
|
+
expect(subject.agency).to eq('datacite')
|
29
37
|
end
|
30
38
|
|
31
39
|
# it "SoftwareSourceCode" do
|
@@ -42,39 +50,44 @@ describe Briard::Metadata, vcr: true do
|
|
42
50
|
# expect(subject.agency).to eq("DataCite")
|
43
51
|
# end
|
44
52
|
|
45
|
-
it
|
46
|
-
input = fixture_path
|
47
|
-
subject =
|
53
|
+
it 'SoftwareSourceCode missing_comma' do
|
54
|
+
input = "#{fixture_path}datacite_software_missing_comma.json"
|
55
|
+
subject = described_class.new(input: input, from: 'datacite_json', show_errors: true)
|
48
56
|
expect(subject.valid?).to be false
|
49
|
-
expect(subject.errors).to eq([
|
50
|
-
expect(subject.codemeta).to
|
57
|
+
expect(subject.errors).to eq(['expected comma, not a string (after doi) at line 4, column 11 [parse.c:430]'])
|
58
|
+
expect(subject.codemeta.nil?).to be(true)
|
51
59
|
end
|
52
60
|
|
53
|
-
it
|
54
|
-
input = fixture_path
|
55
|
-
subject =
|
61
|
+
it 'SoftwareSourceCode overlapping_keys' do
|
62
|
+
input = "#{fixture_path}datacite_software_overlapping_keys.json"
|
63
|
+
subject = described_class.new(input: input, from: 'datacite_json', show_errors: true)
|
56
64
|
expect(subject.valid?).to be false
|
57
|
-
expect(subject.errors).to eq([
|
58
|
-
expect(subject.codemeta).to
|
65
|
+
expect(subject.errors).to eq(['The same key is defined more than once: id'])
|
66
|
+
expect(subject.codemeta.nil?).to be(true)
|
59
67
|
end
|
60
68
|
|
61
|
-
it
|
62
|
-
input =
|
63
|
-
subject =
|
69
|
+
it 'metadata from api' do
|
70
|
+
input = '10.5281/zenodo.28518'
|
71
|
+
subject = described_class.new(input: input, regenerate: true)
|
64
72
|
expect(subject.valid?).to be true
|
65
|
-
expect(subject.types).to eq(
|
73
|
+
expect(subject.types).to eq('bibtex' => 'misc', 'citeproc' => 'article',
|
74
|
+
'resourceTypeGeneral' => 'Software', 'ris' => 'COMP', 'schemaOrg' => 'SoftwareSourceCode')
|
66
75
|
expect(subject.creators.length).to eq(2)
|
67
|
-
expect(subject.creators.first).to eq(
|
68
|
-
|
69
|
-
expect(subject.
|
70
|
-
expect(subject.
|
71
|
-
expect(subject.
|
72
|
-
|
73
|
-
expect(subject.
|
74
|
-
expect(subject.
|
76
|
+
expect(subject.creators.first).to eq('affiliation' => [{ 'name' => 'University of Washington' }],
|
77
|
+
'familyName' => 'Vanderplas', 'givenName' => 'Jake', 'name' => 'Vanderplas, Jake', 'nameIdentifiers' => [], 'nameType' => 'Personal')
|
78
|
+
expect(subject.titles).to eq([{ 'title' => 'Supersmoother: Minor Bug Fix Release' }])
|
79
|
+
expect(subject.id).to eq('https://doi.org/10.5281/zenodo.28518')
|
80
|
+
expect(subject.identifiers).to eq([{ 'identifier' => 'https://zenodo.org/record/28518',
|
81
|
+
'identifierType' => 'URL' }])
|
82
|
+
expect(subject.dates).to eq([{ 'date' => '2015-08-19', 'dateType' => 'Issued' }])
|
83
|
+
expect(subject.publication_year).to eq('2015')
|
84
|
+
expect(subject.version_info).to eq('v0.3.2')
|
85
|
+
expect(subject.datacite).to include('<version>v0.3.2</version>')
|
75
86
|
expect(subject.related_identifiers.length).to eq(2)
|
76
|
-
expect(subject.related_identifiers.first).to eq(
|
77
|
-
|
87
|
+
expect(subject.related_identifiers.first).to eq(
|
88
|
+
'relatedIdentifier' => 'https://github.com/jakevdp/supersmoother/tree/v0.3.2', 'relatedIdentifierType' => 'URL', 'relationType' => 'IsSupplementTo'
|
89
|
+
)
|
90
|
+
expect(subject.agency).to eq('datacite')
|
78
91
|
end
|
79
92
|
end
|
80
93
|
end
|