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,61 +3,66 @@
|
|
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}crossref.bib" }
|
9
9
|
|
10
|
-
context
|
11
|
-
it
|
10
|
+
context 'detect format' do
|
11
|
+
it 'extension' do
|
12
12
|
expect(subject.valid?).to be true
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
16
|
-
|
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(
|
18
|
+
expect(subject.id).to eq('https://doi.org/10.7554/elife.01567')
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
context
|
23
|
-
it
|
24
|
-
expect(subject.raw).to eq(
|
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
|
29
|
-
it
|
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(
|
32
|
-
expect(subject.types).to eq(
|
33
|
-
|
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(
|
36
|
-
|
37
|
-
expect(subject.
|
38
|
-
expect(subject.
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
expect(subject.
|
45
|
-
expect(subject.
|
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
|
49
|
-
input = fixture_path
|
50
|
-
doi =
|
51
|
-
subject =
|
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(
|
54
|
-
expect(subject.id).to eq(
|
55
|
-
expect(subject.types).to eq(
|
56
|
-
|
57
|
-
expect(subject.
|
58
|
-
|
59
|
-
expect(subject.
|
60
|
-
expect(subject.
|
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
|
-
|
6
|
+
subject { described_class.new(input: input) }
|
7
7
|
|
8
|
-
|
8
|
+
let(:input) { 'https://github.com/citation-file-format/ruby-cff/blob/main/CITATION.cff' }
|
9
9
|
|
10
|
-
context
|
11
|
-
it
|
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(
|
14
|
-
expect(subject.url).to eq(
|
15
|
-
expect(subject.types).to eq(
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
expect(subject.
|
22
|
-
expect(subject.
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
expect(subject.
|
32
|
-
expect(subject.
|
33
|
-
expect(subject.
|
34
|
-
expect(subject.
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
43
|
-
input =
|
44
|
-
subject =
|
45
|
-
expect(subject.id).to eq(
|
46
|
-
expect(subject.url).to eq(
|
47
|
-
expect(subject.types).to eq(
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
expect(subject.
|
87
|
-
expect(subject.
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
expect(subject.
|
98
|
-
expect(subject.
|
99
|
-
expect(subject.
|
100
|
-
expect(subject.
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
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
|
114
|
+
it 'ruby-cff' do
|
109
115
|
expect(subject.valid?).to be true
|
110
|
-
expect(subject.id).to eq(
|
111
|
-
expect(subject.url).to eq(
|
112
|
-
expect(subject.types).to eq(
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
expect(subject.
|
119
|
-
expect(subject.
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
expect(subject.
|
129
|
-
expect(subject.
|
130
|
-
expect(subject.
|
131
|
-
expect(subject.
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
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
|
140
|
-
input =
|
141
|
-
subject =
|
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(
|
144
|
-
expect(subject.url).to eq(
|
145
|
-
expect(subject.types).to eq(
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
expect(subject.
|
152
|
-
expect(subject.
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
expect(subject.
|
162
|
-
expect(subject.
|
163
|
-
expect(subject.
|
164
|
-
expect(subject.
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
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
|
-
|
6
|
+
subject { described_class.new(input: input, from: 'citeproc') }
|
7
7
|
|
8
|
-
|
8
|
+
let(:input) { "#{fixture_path}citeproc.json" }
|
9
9
|
|
10
|
-
context
|
11
|
-
it
|
12
|
-
expect(subject.raw).to eq(
|
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
|
17
|
-
it
|
16
|
+
context 'get citeproc metadata' do
|
17
|
+
it 'BlogPosting' do
|
18
18
|
expect(subject.valid?).to be true
|
19
|
-
expect(subject.id).to eq(
|
20
|
-
expect(subject.url).to eq(
|
21
|
-
expect(subject.types).to eq(
|
22
|
-
|
23
|
-
expect(subject.
|
24
|
-
|
25
|
-
expect(subject.
|
26
|
-
expect(subject.
|
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
|
31
|
-
it
|
32
|
-
input = fixture_path
|
33
|
-
subject =
|
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(
|
36
|
-
expect(subject.url).to eq(
|
37
|
-
expect(subject.types).to eq(
|
38
|
-
|
39
|
-
expect(subject.
|
40
|
-
|
41
|
-
expect(subject.
|
42
|
-
expect(subject.
|
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
|
47
|
-
it
|
48
|
-
input = fixture_path
|
49
|
-
subject =
|
50
|
-
#expect(subject.valid?).to be true
|
51
|
-
expect(subject.id).to eq(
|
52
|
-
expect(subject.url).to eq(
|
53
|
-
expect(subject.types).to eq(
|
54
|
-
|
55
|
-
expect(subject.
|
56
|
-
expect(subject.
|
57
|
-
expect(subject.
|
58
|
-
expect(subject.
|
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
|