briard 2.4.2 → 2.6.0
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/.rubocop.yml +144 -620
- data/.rubocop_todo.yml +76 -0
- data/CHANGELOG.md +18 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +40 -6
- 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/turtle_writer_spec.rb +47 -47
- metadata +242 -166
- data/.github/workflows/release.yml +0 -47
@@ -3,136 +3,149 @@
|
|
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/datacite/maremma/blob/master/codemeta.json' }
|
9
9
|
|
10
|
-
context
|
11
|
-
it
|
12
|
-
input = fixture_path
|
13
|
-
subject =
|
14
|
-
expect(subject.raw).to eq(
|
10
|
+
context 'get codemeta raw' do
|
11
|
+
it 'rdataone' do
|
12
|
+
input = "#{fixture_path}codemeta.json"
|
13
|
+
subject = described_class.new(input: input)
|
14
|
+
expect(subject.raw).to eq(File.read(input).strip)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
context
|
19
|
-
it
|
18
|
+
context 'get codemeta metadata' do
|
19
|
+
it 'maremma' do
|
20
20
|
expect(subject.valid?).to be true
|
21
|
-
expect(subject.id).to eq(
|
22
|
-
expect(subject.url).to eq(
|
23
|
-
expect(subject.types).to eq(
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
expect(subject.
|
35
|
-
expect(subject.
|
36
|
-
expect(subject.
|
37
|
-
|
38
|
-
expect(subject.
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
21
|
+
expect(subject.id).to eq('https://doi.org/10.5438/qeg0-3gm3')
|
22
|
+
expect(subject.url).to eq('https://github.com/datacite/maremma')
|
23
|
+
expect(subject.types).to eq('bibtex' => 'misc', 'citeproc' => 'article-journal',
|
24
|
+
'resourceTypeGeneral' => 'Software', 'ris' => 'COMP', 'schemaOrg' => 'SoftwareSourceCode')
|
25
|
+
expect(subject.creators).to eq([{ 'affiliation' => [{ 'name' => 'DataCite' }],
|
26
|
+
'familyName' => 'Fenner',
|
27
|
+
'givenName' => 'Martin',
|
28
|
+
'name' => 'Fenner, Martin',
|
29
|
+
'nameIdentifiers' =>
|
30
|
+
[{ 'nameIdentifier' => 'https://orcid.org/0000-0003-0077-4738',
|
31
|
+
'nameIdentifierScheme' => 'ORCID',
|
32
|
+
'schemeUri' => 'https://orcid.org' }],
|
33
|
+
'nameType' => 'Personal' }])
|
34
|
+
expect(subject.titles).to eq([{ 'title' => 'Maremma: a Ruby library for simplified network calls' }])
|
35
|
+
expect(subject.descriptions.first['description']).to start_with('Ruby utility library for network requests')
|
36
|
+
expect(subject.subjects).to eq([{ 'subject' => 'faraday' }, { 'subject' => 'excon' },
|
37
|
+
{ 'subject' => 'net/http' }])
|
38
|
+
expect(subject.dates).to eq([{ 'date' => '2017-02-24', 'dateType' => 'Issued' },
|
39
|
+
{ 'date' => '2015-11-28', 'dateType' => 'Created' }, { 'date' => '2017-02-24', 'dateType' => 'Updated' }])
|
40
|
+
expect(subject.publication_year).to eq('2017')
|
41
|
+
expect(subject.publisher).to eq('DataCite')
|
42
|
+
expect(subject.rights_list).to eq([{ 'rights' => 'MIT License',
|
43
|
+
'rightsIdentifier' => 'mit',
|
44
|
+
'rightsIdentifierScheme' => 'SPDX',
|
45
|
+
'rightsUri' => 'https://opensource.org/licenses/MIT',
|
46
|
+
'schemeUri' => 'https://spdx.org/licenses/' }])
|
44
47
|
end
|
45
48
|
|
46
|
-
it
|
47
|
-
input = fixture_path
|
48
|
-
subject =
|
49
|
-
expect(subject.id).to eq(
|
50
|
-
expect(subject.url).to eq(
|
51
|
-
expect(subject.types).to eq(
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
expect(subject.
|
75
|
-
expect(subject.
|
76
|
-
expect(subject.
|
77
|
-
|
78
|
-
expect(subject.
|
79
|
-
expect(subject.
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
49
|
+
it 'rdataone' do
|
50
|
+
input = "#{fixture_path}codemeta.json"
|
51
|
+
subject = described_class.new(input: input)
|
52
|
+
expect(subject.id).to eq('https://doi.org/10.5063/f1m61h5x')
|
53
|
+
expect(subject.url).to eq('https://github.com/DataONEorg/rdataone')
|
54
|
+
expect(subject.types).to eq('bibtex' => 'misc', 'citeproc' => 'article-journal',
|
55
|
+
'resourceTypeGeneral' => 'Software', 'ris' => 'COMP', 'schemaOrg' => 'SoftwareSourceCode')
|
56
|
+
expect(subject.creators).to eq([{ 'affiliation' => [{ 'name' => 'NCEAS' }],
|
57
|
+
'familyName' => 'Jones',
|
58
|
+
'givenName' => 'Matt',
|
59
|
+
'name' => 'Jones, Matt',
|
60
|
+
'nameIdentifiers' =>
|
61
|
+
[{ 'nameIdentifier' => 'https://orcid.org/0000-0003-0077-4738',
|
62
|
+
'nameIdentifierScheme' => 'ORCID',
|
63
|
+
'schemeUri' => 'https://orcid.org' }],
|
64
|
+
'nameType' => 'Personal' },
|
65
|
+
{ 'affiliation' => [{ 'name' => 'NCEAS' }],
|
66
|
+
'familyName' => 'Slaughter',
|
67
|
+
'givenName' => 'Peter',
|
68
|
+
'name' => 'Slaughter, Peter',
|
69
|
+
'nameIdentifiers' =>
|
70
|
+
[{ 'nameIdentifier' => 'https://orcid.org/0000-0002-2192-403X',
|
71
|
+
'nameIdentifierScheme' => 'ORCID',
|
72
|
+
'schemeUri' => 'https://orcid.org' }],
|
73
|
+
'nameType' => 'Personal' },
|
74
|
+
{ 'name' => 'University Of California, Santa Barbara',
|
75
|
+
'nameType' => 'Organizational',
|
76
|
+
'nameIdentifiers' => [], 'affiliation' => [] }])
|
77
|
+
expect(subject.titles).to eq([{ 'title' => 'R Interface to the DataONE REST API' }])
|
78
|
+
expect(subject.descriptions.first['description']).to start_with('Provides read and write access to data and metadata')
|
79
|
+
expect(subject.subjects).to eq([{ 'subject' => 'data sharing' }, { 'subject' => 'data repository' },
|
80
|
+
{ 'subject' => 'dataone' }])
|
81
|
+
expect(subject.version_info).to eq('2.0.0')
|
82
|
+
expect(subject.dates).to eq([{ 'date' => '2016-05-27', 'dateType' => 'Issued' },
|
83
|
+
{ 'date' => '2016-05-27', 'dateType' => 'Created' }, { 'date' => '2016-05-27', 'dateType' => 'Updated' }])
|
84
|
+
expect(subject.publication_year).to eq('2016')
|
85
|
+
expect(subject.publisher).to eq('https://cran.r-project.org')
|
86
|
+
expect(subject.rights_list).to eq([{ 'rights' => 'Apache License 2.0',
|
87
|
+
'rightsIdentifier' => 'apache-2.0',
|
88
|
+
'rightsIdentifierScheme' => 'SPDX',
|
89
|
+
'rightsUri' => 'http://www.apache.org/licenses/LICENSE-2.0',
|
90
|
+
'schemeUri' => 'https://spdx.org/licenses/' }])
|
85
91
|
end
|
86
92
|
|
87
|
-
it
|
88
|
-
input = fixture_path
|
89
|
-
subject =
|
93
|
+
it 'maremma' do
|
94
|
+
input = "#{fixture_path}maremma/codemeta.json"
|
95
|
+
subject = described_class.new(input: input)
|
90
96
|
expect(subject.valid?).to be true
|
91
|
-
expect(subject.id).to eq(
|
92
|
-
expect(subject.url).to eq(
|
93
|
-
expect(subject.types).to eq(
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
expect(subject.
|
105
|
-
expect(subject.
|
106
|
-
expect(subject.
|
107
|
-
|
108
|
-
expect(subject.
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
97
|
+
expect(subject.id).to eq('https://doi.org/10.5438/qeg0-3gm3')
|
98
|
+
expect(subject.url).to eq('https://github.com/datacite/maremma')
|
99
|
+
expect(subject.types).to eq('bibtex' => 'misc', 'citeproc' => 'article-journal',
|
100
|
+
'resourceTypeGeneral' => 'Software', 'ris' => 'COMP', 'schemaOrg' => 'SoftwareSourceCode')
|
101
|
+
expect(subject.creators).to eq([{ 'affiliation' => [{ 'name' => 'DataCite' }],
|
102
|
+
'familyName' => 'Fenner',
|
103
|
+
'givenName' => 'Martin',
|
104
|
+
'name' => 'Fenner, Martin',
|
105
|
+
'nameIdentifiers' =>
|
106
|
+
[{ 'nameIdentifier' => 'https://orcid.org/0000-0003-0077-4738',
|
107
|
+
'nameIdentifierScheme' => 'ORCID',
|
108
|
+
'schemeUri' => 'https://orcid.org' }],
|
109
|
+
'nameType' => 'Personal' }])
|
110
|
+
expect(subject.titles).to eq([{ 'title' => 'Maremma: a Ruby library for simplified network calls' }])
|
111
|
+
expect(subject.descriptions.first['description']).to start_with('Simplifies network calls')
|
112
|
+
expect(subject.subjects).to eq([{ 'subject' => 'faraday' }, { 'subject' => 'excon' },
|
113
|
+
{ 'subject' => 'net/http' }])
|
114
|
+
expect(subject.dates).to eq([{ 'date' => '2017-02-24', 'dateType' => 'Issued' },
|
115
|
+
{ 'date' => '2015-11-28', 'dateType' => 'Created' }, { 'date' => '2017-02-24', 'dateType' => 'Updated' }])
|
116
|
+
expect(subject.publication_year).to eq('2017')
|
117
|
+
expect(subject.publisher).to eq('DataCite')
|
118
|
+
expect(subject.rights_list).to eq([{ 'rights' => 'MIT License',
|
119
|
+
'rightsIdentifier' => 'mit',
|
120
|
+
'rightsIdentifierScheme' => 'SPDX',
|
121
|
+
'rightsUri' => 'https://opensource.org/licenses/MIT',
|
122
|
+
'schemeUri' => 'https://spdx.org/licenses/' }])
|
114
123
|
end
|
115
124
|
|
116
|
-
it
|
117
|
-
input =
|
118
|
-
subject =
|
125
|
+
it 'metadata_reports' do
|
126
|
+
input = 'https://github.com/datacite/metadata-reports/blob/master/software/codemeta.json'
|
127
|
+
subject = described_class.new(input: input)
|
119
128
|
expect(subject.valid?).to be true
|
120
|
-
expect(subject.id).to eq(
|
121
|
-
expect(subject.url).to eq(
|
122
|
-
expect(subject.types).to eq(
|
129
|
+
expect(subject.id).to eq('https://doi.org/10.5438/wr0x-e194')
|
130
|
+
expect(subject.url).to eq('https://github.com/datacite/metadata-reports')
|
131
|
+
expect(subject.types).to eq('bibtex' => 'misc', 'citeproc' => 'article-journal',
|
132
|
+
'resourceTypeGeneral' => 'Software', 'ris' => 'COMP', 'schemaOrg' => 'SoftwareSourceCode')
|
123
133
|
expect(subject.creators.size).to eq(4)
|
124
|
-
expect(subject.creators.last).to eq(
|
125
|
-
|
126
|
-
expect(subject.
|
127
|
-
expect(subject.
|
128
|
-
expect(subject.
|
129
|
-
|
130
|
-
expect(subject.
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
134
|
+
expect(subject.creators.last).to eq('familyName' => 'Nielsen', 'givenName' => 'Lars Holm',
|
135
|
+
'name' => 'Nielsen, Lars Holm', 'nameIdentifiers' => [{ 'nameIdentifier' => 'https://orcid.org/0000-0001-8135-3489', 'nameIdentifierScheme' => 'ORCID', 'schemeUri' => 'https://orcid.org' }], 'nameType' => 'Personal', 'affiliation' => [])
|
136
|
+
expect(subject.titles).to eq([{ 'title' => 'DOI Registrations for Software' }])
|
137
|
+
expect(subject.descriptions.first['description']).to start_with('Analysis of DataCite DOIs registered for software')
|
138
|
+
expect(subject.subjects).to eq([{ 'subject' => 'doi' }, { 'subject' => 'software' },
|
139
|
+
{ 'subject' => 'codemeta' }])
|
140
|
+
expect(subject.dates).to eq([{ 'date' => '2018-05-17', 'dateType' => 'Issued' },
|
141
|
+
{ 'date' => '2018-03-09', 'dateType' => 'Created' }, { 'date' => '2018-05-17', 'dateType' => 'Updated' }])
|
142
|
+
expect(subject.publication_year).to eq('2018')
|
143
|
+
expect(subject.publisher).to eq('DataCite')
|
144
|
+
expect(subject.rights_list).to eq([{ 'rights' => 'MIT License',
|
145
|
+
'rightsIdentifier' => 'mit',
|
146
|
+
'rightsIdentifierScheme' => 'SPDX',
|
147
|
+
'rightsUri' => 'https://opensource.org/licenses/MIT',
|
148
|
+
'schemeUri' => 'https://spdx.org/licenses/' }])
|
136
149
|
end
|
137
150
|
end
|
138
151
|
end
|
@@ -3,39 +3,49 @@
|
|
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}crosscite.json" }
|
9
9
|
|
10
|
-
context
|
11
|
-
it
|
12
|
-
expect(subject.raw).to eq(
|
10
|
+
context 'get crosscite raw' do
|
11
|
+
it 'SoftwareSourceCode' 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 crosscite metadata' do
|
17
|
+
it 'SoftwareSourceCode' do
|
18
18
|
expect(subject.valid?).to be true
|
19
|
-
expect(subject.identifiers).to eq([
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
expect(subject.
|
24
|
-
|
25
|
-
expect(subject.
|
19
|
+
expect(subject.identifiers).to eq([
|
20
|
+
{ 'Identifier' => 'https://doi.org/10.5281/zenodo.48440',
|
21
|
+
'identifierType' => 'DOI' }, { 'Identifier' => 'http://zenodo.org/record/48440', 'identifierType' => 'URL' }
|
22
|
+
])
|
23
|
+
expect(subject.types).to eq('bibtex' => 'misc', 'citeproc' => 'other',
|
24
|
+
'resourceType' => 'Software', 'resourceTypeGeneral' => 'Software', 'ris' => 'COMP', 'schemaOrg' => 'SoftwareSourceCode')
|
25
|
+
expect(subject.creators).to eq([{ 'type' => 'Person', 'familyName' => 'Garza',
|
26
|
+
'givenName' => 'Kristian', 'name' => 'Kristian Garza' }])
|
27
|
+
expect(subject.titles).to eq([{ 'title' => 'Analysis Tools for Crossover Experiment of UI using Choice Architecture' }])
|
28
|
+
expect(subject.descriptions.first['description']).to start_with('This tools are used to analyse the data produced by the Crosssover Experiment')
|
29
|
+
expect(subject.dates).to eq('date' => '2016-03-27', 'dateType' => 'Issued')
|
30
|
+
expect(subject.publication_year).to eq('2016')
|
26
31
|
end
|
27
32
|
|
28
|
-
it
|
29
|
-
input =
|
30
|
-
subject =
|
33
|
+
it 'SoftwareSourceCode as string' do
|
34
|
+
input = File.read("#{fixture_path}crosscite.json")
|
35
|
+
subject = described_class.new(input: input)
|
31
36
|
expect(subject.valid?).to be true
|
32
|
-
expect(subject.identifiers).to eq([
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
expect(subject.
|
37
|
-
|
38
|
-
expect(subject.
|
37
|
+
expect(subject.identifiers).to eq([
|
38
|
+
{ 'Identifier' => 'https://doi.org/10.5281/zenodo.48440',
|
39
|
+
'identifierType' => 'DOI' }, { 'Identifier' => 'http://zenodo.org/record/48440', 'identifierType' => 'URL' }
|
40
|
+
])
|
41
|
+
expect(subject.types).to eq('bibtex' => 'misc', 'citeproc' => 'other',
|
42
|
+
'resourceType' => 'Software', 'resourceTypeGeneral' => 'Software', 'ris' => 'COMP', 'schemaOrg' => 'SoftwareSourceCode')
|
43
|
+
expect(subject.creators).to eq([{ 'type' => 'Person', 'familyName' => 'Garza',
|
44
|
+
'givenName' => 'Kristian', 'name' => 'Kristian Garza' }])
|
45
|
+
expect(subject.titles).to eq([{ 'title' => 'Analysis Tools for Crossover Experiment of UI using Choice Architecture' }])
|
46
|
+
expect(subject.descriptions.first['description']).to start_with('This tools are used to analyse the data produced by the Crosssover Experiment')
|
47
|
+
expect(subject.dates).to eq('date' => '2016-03-27', 'dateType' => 'Issued')
|
48
|
+
expect(subject.publication_year).to eq('2016')
|
39
49
|
end
|
40
50
|
end
|
41
51
|
end
|