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
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2022-01-30 21:43:14 UTC using RuboCop version 1.25.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 101
|
10
|
+
InternalAffairs/NodeDestructuring:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
# Offense count: 55
|
14
|
+
# Configuration parameters: CountComments, CountAsOne.
|
15
|
+
Metrics/ClassLength:
|
16
|
+
Max: 191
|
17
|
+
|
18
|
+
# Offense count: 235
|
19
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
20
|
+
Metrics/MethodLength:
|
21
|
+
Max: 14
|
22
|
+
|
23
|
+
# Offense count: 8
|
24
|
+
# Configuration parameters: CountComments, CountAsOne.
|
25
|
+
Metrics/ModuleLength:
|
26
|
+
Max: 129
|
27
|
+
|
28
|
+
# Offense count: 9
|
29
|
+
RSpec/AnyInstance:
|
30
|
+
Exclude:
|
31
|
+
- 'spec/rubocop/cli_spec.rb'
|
32
|
+
- 'spec/rubocop/cli/suggest_extensions_spec.rb'
|
33
|
+
- 'spec/rubocop/cop/lint/duplicate_methods_spec.rb'
|
34
|
+
- 'spec/rubocop/cop/team_spec.rb'
|
35
|
+
- 'spec/rubocop/target_finder_spec.rb'
|
36
|
+
|
37
|
+
# Offense count: 1279
|
38
|
+
# Configuration parameters: Prefixes.
|
39
|
+
# Prefixes: when, with, without
|
40
|
+
RSpec/ContextWording:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
# Offense count: 2414
|
44
|
+
# Configuration parameters: CountAsOne.
|
45
|
+
RSpec/ExampleLength:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
# Offense count: 39
|
49
|
+
RSpec/ExpectOutput:
|
50
|
+
Exclude:
|
51
|
+
- 'spec/rubocop/cli/auto_gen_config_spec.rb'
|
52
|
+
- 'spec/rubocop/cli/options_spec.rb'
|
53
|
+
- 'spec/rubocop/config_spec.rb'
|
54
|
+
- 'spec/rubocop/cop/cop_spec.rb'
|
55
|
+
- 'spec/rubocop/formatter/disabled_config_formatter_spec.rb'
|
56
|
+
- 'spec/rubocop/formatter/formatter_set_spec.rb'
|
57
|
+
- 'spec/rubocop/options_spec.rb'
|
58
|
+
- 'spec/rubocop/rake_task_spec.rb'
|
59
|
+
- 'spec/rubocop/result_cache_spec.rb'
|
60
|
+
- 'spec/rubocop/target_finder_spec.rb'
|
61
|
+
|
62
|
+
# Offense count: 404
|
63
|
+
RSpec/MultipleExpectations:
|
64
|
+
Max: 25
|
65
|
+
|
66
|
+
# Offense count: 9
|
67
|
+
RSpec/SubjectStub:
|
68
|
+
Exclude:
|
69
|
+
- 'spec/rubocop/config_spec.rb'
|
70
|
+
- 'spec/rubocop/formatter/json_formatter_spec.rb'
|
71
|
+
- 'spec/rubocop/formatter/pacman_formatter_spec.rb'
|
72
|
+
- 'spec/rubocop/formatter/progress_formatter_spec.rb'
|
73
|
+
|
74
|
+
# Offense count: 12
|
75
|
+
Rake/MethodDefinitionInTask:
|
76
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v2.5.1](https://github.com/front-matter/briard/tree/v2.5.1) (2022-09-18)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/front-matter/briard/compare/v2.5.0...v2.5.1)
|
6
|
+
|
7
|
+
## [v2.5.0](https://github.com/front-matter/briard/tree/v2.5.0) (2022-09-18)
|
8
|
+
|
9
|
+
[Full Changelog](https://github.com/front-matter/briard/compare/v2.4.2...v2.5.0)
|
10
|
+
|
11
|
+
**Fixed bugs:**
|
12
|
+
|
13
|
+
- Incomplete URL substring sanitization [\#12](https://github.com/front-matter/briard/issues/12)
|
14
|
+
- Incomplete URL substring sanitization [\#11](https://github.com/front-matter/briard/issues/11)
|
15
|
+
- Incomplete URL substring sanitization [\#10](https://github.com/front-matter/briard/issues/10)
|
16
|
+
|
17
|
+
## [v2.4.2](https://github.com/front-matter/briard/tree/v2.4.2) (2022-08-24)
|
18
|
+
|
19
|
+
[Full Changelog](https://github.com/front-matter/briard/compare/v2.4.1...v2.4.2)
|
20
|
+
|
3
21
|
## [v2.4.1](https://github.com/front-matter/briard/tree/v2.4.1) (2022-08-24)
|
4
22
|
|
5
23
|
[Full Changelog](https://github.com/front-matter/briard/compare/v2.4...v2.4.1)
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
briard (2.
|
4
|
+
briard (2.5.1)
|
5
5
|
activesupport (>= 4.2.5)
|
6
6
|
base32-url (>= 0.5.0, < 1)
|
7
7
|
benchmark_methods (~> 0.7)
|
@@ -34,7 +34,7 @@ PATH
|
|
34
34
|
GEM
|
35
35
|
remote: https://rubygems.org/
|
36
36
|
specs:
|
37
|
-
activesupport (7.0.
|
37
|
+
activesupport (7.0.4)
|
38
38
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
39
39
|
i18n (>= 1.6, < 2)
|
40
40
|
minitest (>= 5.1)
|
@@ -42,6 +42,7 @@ GEM
|
|
42
42
|
addressable (2.8.1)
|
43
43
|
public_suffix (>= 2.0.2, < 6.0)
|
44
44
|
amazing_print (1.4.0)
|
45
|
+
ast (2.4.2)
|
45
46
|
base32-url (0.5)
|
46
47
|
benchmark_methods (0.7)
|
47
48
|
bibtex-ruby (6.0.0)
|
@@ -52,6 +53,8 @@ GEM
|
|
52
53
|
citeproc-ruby (1.1.14)
|
53
54
|
citeproc (~> 1.0, >= 1.0.9)
|
54
55
|
csl (~> 1.6)
|
56
|
+
code-scanning-rubocop (0.6.1)
|
57
|
+
rubocop (~> 1.0)
|
55
58
|
colorize (0.8.1)
|
56
59
|
concurrent-ruby (1.1.10)
|
57
60
|
crack (0.4.5)
|
@@ -110,7 +113,7 @@ GEM
|
|
110
113
|
optimist (~> 3)
|
111
114
|
latex-decode (0.4.0)
|
112
115
|
link_header (0.0.8)
|
113
|
-
loofah (2.
|
116
|
+
loofah (2.19.0)
|
114
117
|
crass (~> 1.0.2)
|
115
118
|
nokogiri (>= 1.5.9)
|
116
119
|
maremma (4.9.8)
|
@@ -136,6 +139,9 @@ GEM
|
|
136
139
|
oj (3.13.21)
|
137
140
|
oj_mimic_json (1.0.1)
|
138
141
|
optimist (3.0.1)
|
142
|
+
parallel (1.22.1)
|
143
|
+
parser (3.1.2.1)
|
144
|
+
ast (~> 2.4.1)
|
139
145
|
postrank-uri (1.0.24)
|
140
146
|
addressable (>= 2.4.0)
|
141
147
|
nokogiri (>= 1.8.0)
|
@@ -145,6 +151,7 @@ GEM
|
|
145
151
|
rack (2.2.4)
|
146
152
|
rack-test (0.8.3)
|
147
153
|
rack (>= 1.0, < 3)
|
154
|
+
rainbow (3.1.1)
|
148
155
|
rake (12.3.3)
|
149
156
|
rdf (3.2.9)
|
150
157
|
link_header (~> 0.0, >= 0.0.8)
|
@@ -170,6 +177,7 @@ GEM
|
|
170
177
|
rdf-xsd (3.2.1)
|
171
178
|
rdf (~> 3.2)
|
172
179
|
rexml (~> 3.2)
|
180
|
+
regexp_parser (2.5.0)
|
173
181
|
rexml (3.2.5)
|
174
182
|
rspec (3.11.0)
|
175
183
|
rspec-core (~> 3.11.0)
|
@@ -177,16 +185,36 @@ GEM
|
|
177
185
|
rspec-mocks (~> 3.11.0)
|
178
186
|
rspec-core (3.11.0)
|
179
187
|
rspec-support (~> 3.11.0)
|
180
|
-
rspec-expectations (3.11.
|
188
|
+
rspec-expectations (3.11.1)
|
181
189
|
diff-lcs (>= 1.2.0, < 2.0)
|
182
190
|
rspec-support (~> 3.11.0)
|
183
191
|
rspec-mocks (3.11.1)
|
184
192
|
diff-lcs (>= 1.2.0, < 2.0)
|
185
193
|
rspec-support (~> 3.11.0)
|
186
|
-
rspec-support (3.11.
|
194
|
+
rspec-support (3.11.1)
|
187
195
|
rspec-xsd (0.1.0)
|
188
196
|
nokogiri (~> 1.6)
|
189
197
|
rspec (~> 3)
|
198
|
+
rubocop (1.36.0)
|
199
|
+
json (~> 2.3)
|
200
|
+
parallel (~> 1.10)
|
201
|
+
parser (>= 3.1.2.1)
|
202
|
+
rainbow (>= 2.2.2, < 4.0)
|
203
|
+
regexp_parser (>= 1.8, < 3.0)
|
204
|
+
rexml (>= 3.2.5, < 4.0)
|
205
|
+
rubocop-ast (>= 1.20.1, < 2.0)
|
206
|
+
ruby-progressbar (~> 1.7)
|
207
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
208
|
+
rubocop-ast (1.21.0)
|
209
|
+
parser (>= 3.1.1.0)
|
210
|
+
rubocop-performance (1.15.0)
|
211
|
+
rubocop (>= 1.7.0, < 2.0)
|
212
|
+
rubocop-ast (>= 0.4.0)
|
213
|
+
rubocop-rake (0.6.0)
|
214
|
+
rubocop (~> 1.0)
|
215
|
+
rubocop-rspec (2.13.1)
|
216
|
+
rubocop (~> 1.33)
|
217
|
+
ruby-progressbar (1.11.0)
|
190
218
|
scanf (1.0.0)
|
191
219
|
simplecov (0.17.1)
|
192
220
|
docile (~> 1.1)
|
@@ -201,7 +229,8 @@ GEM
|
|
201
229
|
tilt (2.0.11)
|
202
230
|
tzinfo (2.0.5)
|
203
231
|
concurrent-ruby (~> 1.0)
|
204
|
-
unicode-
|
232
|
+
unicode-display_width (2.3.0)
|
233
|
+
unicode-types (1.8.0)
|
205
234
|
unicode_utils (1.4.0)
|
206
235
|
vcr (3.0.3)
|
207
236
|
webmock (3.18.1)
|
@@ -215,11 +244,16 @@ PLATFORMS
|
|
215
244
|
DEPENDENCIES
|
216
245
|
briard!
|
217
246
|
bundler (>= 1.0)
|
247
|
+
code-scanning-rubocop (~> 0.6.1)
|
218
248
|
hashdiff (>= 1.0.0.beta1, < 2.0.0)
|
219
249
|
rack-test (~> 0)
|
220
250
|
rake (~> 12.0)
|
221
251
|
rspec (~> 3.4)
|
222
252
|
rspec-xsd (~> 0.1.0)
|
253
|
+
rubocop (~> 1.36)
|
254
|
+
rubocop-performance (~> 1.15)
|
255
|
+
rubocop-rake (~> 0.6.0)
|
256
|
+
rubocop-rspec (~> 2.13)
|
223
257
|
simplecov (= 0.17.1)
|
224
258
|
vcr (~> 3.0, >= 3.0.3)
|
225
259
|
webmock (~> 3.0, >= 3.0.1)
|
data/Rakefile
CHANGED
@@ -1,61 +1,68 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'English'
|
4
|
+
require 'date'
|
5
|
+
require File.expand_path('lib/briard/version', __dir__)
|
3
6
|
|
4
7
|
Gem::Specification.new do |s|
|
5
|
-
s.authors =
|
6
|
-
s.email =
|
7
|
-
s.name =
|
8
|
-
s.homepage =
|
9
|
-
s.summary =
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.require_paths = ["lib"]
|
8
|
+
s.authors = 'Martin Fenner'
|
9
|
+
s.email = 'martin@front-matter.io'
|
10
|
+
s.name = 'briard'
|
11
|
+
s.homepage = 'https://github.com/front-matter/briard'
|
12
|
+
s.summary = 'Ruby client library for conversion of DOI Metadata'
|
13
|
+
s.description = 'Ruby gem and command-line utility for conversion of DOI metadata from and to different metadata formats, including schema.org. Fork of version 1.19.12 of the bolognese gem.'
|
14
|
+
s.require_paths = ['lib']
|
13
15
|
s.version = Briard::VERSION
|
14
|
-
s.extra_rdoc_files = [
|
15
|
-
s.license
|
16
|
+
s.extra_rdoc_files = ['README.md']
|
17
|
+
s.license = 'MIT'
|
16
18
|
s.required_ruby_version = '~> 2.3'
|
17
19
|
|
18
20
|
# Declare dependencies here, rather than in the Gemfile
|
19
|
-
s.add_dependency 'maremma', '>= 4.9.7', '< 5'
|
20
|
-
s.add_dependency 'base32-url', '>= 0.5.0', '< 1'
|
21
|
-
s.add_dependency 'faraday', '~> 0.17.3'
|
22
|
-
s.add_dependency 'faraday-multipart', '~> 1.0.4'
|
23
|
-
s.add_dependency 'nokogiri', '~> 1.13.1'
|
24
|
-
s.add_dependency 'loofah', '~> 2.0', '>= 2.0.3'
|
25
|
-
s.add_dependency 'builder', '~> 3.2', '>= 3.2.2'
|
26
21
|
s.add_dependency 'activesupport', '>= 4.2.5'
|
22
|
+
s.add_dependency 'base32-url', '>= 0.5.0', '< 1'
|
23
|
+
s.add_dependency 'benchmark_methods', '~> 0.7'
|
27
24
|
s.add_dependency 'bibtex-ruby', '>= 5.1.0'
|
28
|
-
s.add_dependency '
|
29
|
-
s.add_dependency 'colorize', '~> 0.8.1'
|
30
|
-
s.add_dependency 'namae', '~> 1.0'
|
31
|
-
s.add_dependency 'edtf', '~> 3.0', '>= 3.0.4'
|
25
|
+
s.add_dependency 'builder', '~> 3.2', '>= 3.2.2'
|
32
26
|
s.add_dependency 'citeproc-ruby', '~> 1.1', '>= 1.1.12'
|
27
|
+
s.add_dependency 'colorize', '~> 0.8.1'
|
28
|
+
s.add_dependency 'concurrent-ruby', '~> 1.1', '>= 1.1.5'
|
33
29
|
s.add_dependency 'csl-styles', '~> 1.0', '>= 1.0.1.10'
|
30
|
+
s.add_dependency 'dotenv', '~> 2.1', '>= 2.1.1'
|
31
|
+
s.add_dependency 'edtf', '~> 3.0', '>= 3.0.4'
|
32
|
+
s.add_dependency 'faraday', '~> 0.17.3'
|
33
|
+
s.add_dependency 'faraday-multipart', '~> 1.0.4'
|
34
|
+
s.add_dependency 'gender_detector', '~> 0.1.2'
|
34
35
|
s.add_dependency 'iso8601', '~> 0.9.1'
|
35
|
-
s.add_dependency 'postrank-uri', '~> 1.0', '>= 1.0.18'
|
36
|
-
s.add_dependency 'public_suffix', '2.0.5'
|
37
36
|
s.add_dependency 'json-ld-preloaded', '~> 3.1', '>= 3.1.3'
|
38
37
|
s.add_dependency 'jsonlint', '~> 0.3.0'
|
38
|
+
s.add_dependency 'loofah', '~> 2.0', '>= 2.0.3'
|
39
|
+
s.add_dependency 'maremma', '>= 4.9.7', '< 5'
|
40
|
+
s.add_dependency 'namae', '~> 1.0'
|
41
|
+
s.add_dependency 'nokogiri', '~> 1.13.1'
|
39
42
|
s.add_dependency 'oj', '~> 3.10'
|
40
|
-
s.add_dependency
|
41
|
-
s.add_dependency '
|
43
|
+
s.add_dependency 'oj_mimic_json', '~> 1.0', '>= 1.0.1'
|
44
|
+
s.add_dependency 'postrank-uri', '~> 1.0', '>= 1.0.18'
|
45
|
+
s.add_dependency 'public_suffix', '2.0.5'
|
42
46
|
s.add_dependency 'rdf-rdfxml', '~> 3.1'
|
43
|
-
s.add_dependency '
|
44
|
-
s.add_dependency '
|
45
|
-
s.add_dependency 'gender_detector', '~> 0.1.2'
|
46
|
-
s.add_dependency 'concurrent-ruby', '~> 1.1', '>= 1.1.5'
|
47
|
+
s.add_dependency 'rdf-turtle', '~> 3.1'
|
48
|
+
s.add_dependency 'thor', '>= 1.1.0'
|
47
49
|
s.add_development_dependency 'bundler', '>= 1.0'
|
50
|
+
s.add_development_dependency 'code-scanning-rubocop', '~> 0.6.1'
|
51
|
+
s.add_development_dependency 'hashdiff', ['>= 1.0.0.beta1', '< 2.0.0']
|
52
|
+
s.add_development_dependency 'rack-test', '~> 0'
|
53
|
+
s.add_development_dependency 'rake', '~> 12.0'
|
48
54
|
s.add_development_dependency 'rspec', '~> 3.4'
|
49
55
|
s.add_development_dependency 'rspec-xsd', '~> 0.1.0'
|
50
|
-
s.add_development_dependency '
|
51
|
-
s.add_development_dependency '
|
56
|
+
s.add_development_dependency 'rubocop', '~> 1.36'
|
57
|
+
s.add_development_dependency 'rubocop-performance', '~> 1.15'
|
58
|
+
s.add_development_dependency 'rubocop-rake', '~> 0.6.0'
|
59
|
+
s.add_development_dependency 'rubocop-rspec', '~> 2.13'
|
60
|
+
s.add_development_dependency 'simplecov', '0.17.1'
|
52
61
|
s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.3'
|
53
62
|
s.add_development_dependency 'webmock', '~> 3.0', '>= 3.0.1'
|
54
|
-
s.add_development_dependency 'simplecov', '0.17.1'
|
55
|
-
s.add_development_dependency 'hashdiff', ['>= 1.0.0.beta1', '< 2.0.0']
|
56
63
|
|
57
|
-
s.require_paths = [
|
58
|
-
s.files
|
59
|
-
s.
|
60
|
-
s.
|
64
|
+
s.require_paths = ['lib']
|
65
|
+
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
66
|
+
s.executables = ['briard']
|
67
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
61
68
|
end
|
data/lib/briard/array.rb
CHANGED
data/lib/briard/author_utils.rb
CHANGED
@@ -8,53 +8,56 @@ module Briard
|
|
8
8
|
#
|
9
9
|
# benchmark :get_authors
|
10
10
|
|
11
|
-
IDENTIFIER_SCHEME_URIS = {
|
12
|
-
"ORCID" => "https://orcid.org/"
|
13
|
-
}
|
11
|
+
IDENTIFIER_SCHEME_URIS = { 'ORCID' => 'https://orcid.org/' }.freeze
|
14
12
|
|
15
13
|
def get_one_author(author)
|
16
14
|
# author is a string
|
17
|
-
author = {
|
15
|
+
author = { 'creatorName' => author } if author.is_a?(String)
|
18
16
|
|
19
17
|
# malformed XML
|
20
|
-
return nil if author.fetch(
|
18
|
+
return nil if author.fetch('creatorName', nil).is_a?(Array)
|
21
19
|
|
22
|
-
name = parse_attributes(author.fetch(
|
23
|
-
parse_attributes(author.fetch(
|
24
|
-
given_name = parse_attributes(author.fetch(
|
25
|
-
family_name = parse_attributes(author.fetch(
|
20
|
+
name = parse_attributes(author.fetch('creatorName', nil)) ||
|
21
|
+
parse_attributes(author.fetch('contributorName', nil))
|
22
|
+
given_name = parse_attributes(author.fetch('givenName', nil))
|
23
|
+
family_name = parse_attributes(author.fetch('familyName', nil))
|
26
24
|
name = cleanup_author(name)
|
27
|
-
name = [family_name, given_name].join(
|
28
|
-
contributor_type = parse_attributes(author.fetch(
|
25
|
+
name = [family_name, given_name].join(', ') if family_name.present? && given_name.present?
|
26
|
+
contributor_type = parse_attributes(author.fetch('contributorType', nil))
|
29
27
|
|
30
|
-
name_type = parse_attributes(author.fetch(
|
28
|
+
name_type = parse_attributes(author.fetch('creatorName', nil), content: 'nameType',
|
29
|
+
first: true) || parse_attributes(author.fetch('contributorName', nil), content: 'nameType',
|
30
|
+
first: true)
|
31
31
|
|
32
|
-
name_identifiers = Array.wrap(author.fetch(
|
33
|
-
if ni[
|
32
|
+
name_identifiers = Array.wrap(author.fetch('nameIdentifier', nil)).map do |ni|
|
33
|
+
if ni['nameIdentifierScheme'] == 'ORCID'
|
34
34
|
{
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
'nameIdentifier' => normalize_orcid(ni['__content__']),
|
36
|
+
'schemeUri' => 'https://orcid.org',
|
37
|
+
'nameIdentifierScheme' => 'ORCID'
|
38
|
+
}.compact
|
39
|
+
elsif ni['schemeURI'].present?
|
39
40
|
{
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
'nameIdentifier' => ni['schemeURI'].to_s + ni['__content__'].to_s,
|
42
|
+
'schemeUri' => ni['schemeURI'].to_s,
|
43
|
+
'nameIdentifierScheme' => ni['nameIdentifierScheme']
|
44
|
+
}.compact
|
43
45
|
else
|
44
46
|
{
|
45
|
-
|
46
|
-
|
47
|
-
|
47
|
+
'nameIdentifier' => ni['__content__'],
|
48
|
+
'schemeUri' => nil,
|
49
|
+
'nameIdentifierScheme' => ni['nameIdentifierScheme']
|
50
|
+
}.compact
|
48
51
|
end
|
49
52
|
end.presence
|
50
53
|
|
51
|
-
author = {
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
author = { 'nameType' => name_type,
|
55
|
+
'name' => name,
|
56
|
+
'givenName' => given_name,
|
57
|
+
'familyName' => family_name,
|
58
|
+
'nameIdentifiers' => name_identifiers,
|
59
|
+
'affiliation' => get_affiliations(author.fetch('affiliation', nil)),
|
60
|
+
'contributorType' => contributor_type }.compact
|
58
61
|
|
59
62
|
return author if family_name.present?
|
60
63
|
|
@@ -66,25 +69,25 @@ module Briard
|
|
66
69
|
if parsed_name.present?
|
67
70
|
given_name = parsed_name.given
|
68
71
|
family_name = parsed_name.family
|
69
|
-
name = [family_name, given_name].join(
|
72
|
+
name = [family_name, given_name].join(', ')
|
70
73
|
else
|
71
74
|
given_name = nil
|
72
75
|
family_name = nil
|
73
76
|
end
|
74
77
|
|
75
|
-
{
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
{ 'nameType' => 'Personal',
|
79
|
+
'name' => name,
|
80
|
+
'givenName' => given_name,
|
81
|
+
'familyName' => family_name,
|
82
|
+
'nameIdentifiers' => Array.wrap(name_identifiers),
|
83
|
+
'affiliation' => Array.wrap(author.fetch('affiliation', nil)),
|
84
|
+
'contributorType' => contributor_type }.compact
|
82
85
|
else
|
83
|
-
{
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
86
|
+
{ 'nameType' => name_type,
|
87
|
+
'name' => name,
|
88
|
+
'nameIdentifiers' => Array.wrap(name_identifiers),
|
89
|
+
'affiliation' => Array.wrap(author.fetch('affiliation', nil)),
|
90
|
+
'contributorType' => contributor_type }.compact
|
88
91
|
end
|
89
92
|
end
|
90
93
|
|
@@ -92,10 +95,12 @@ module Briard
|
|
92
95
|
return nil unless author.present?
|
93
96
|
|
94
97
|
# detect pattern "Smith J.", but not "Smith, John K."
|
95
|
-
|
98
|
+
unless author.include?(',')
|
99
|
+
author = author.gsub(/[[:space:]]([A-Z]\.)?(-?[A-Z]\.)$/, ', \1\2')
|
100
|
+
end
|
96
101
|
|
97
102
|
# remove spaces around hyphens
|
98
|
-
author = author.gsub(
|
103
|
+
author = author.gsub(' - ', '-')
|
99
104
|
|
100
105
|
# titleize strings
|
101
106
|
# remove non-standard space characters
|
@@ -103,12 +108,15 @@ module Briard
|
|
103
108
|
end
|
104
109
|
|
105
110
|
def is_personal_name?(author)
|
106
|
-
return false if author.fetch(
|
107
|
-
return true if Array.wrap(author.fetch(
|
108
|
-
|
109
|
-
|
110
|
-
author.fetch(
|
111
|
-
|
111
|
+
return false if author.fetch('nameType', nil) == 'Organizational'
|
112
|
+
return true if Array.wrap(author.fetch('nameIdentifiers', nil)).find do |a|
|
113
|
+
a['nameIdentifierScheme'] == 'ORCID'
|
114
|
+
end.present? ||
|
115
|
+
author.fetch('familyName', '').present? ||
|
116
|
+
(author.fetch('name', '').include?(',') &&
|
117
|
+
author.fetch('name', '').exclude?(';')) ||
|
118
|
+
name_exists?(author.fetch('name', '').split.first)
|
119
|
+
|
112
120
|
false
|
113
121
|
end
|
114
122
|
|
@@ -126,14 +134,14 @@ module Briard
|
|
126
134
|
|
127
135
|
def authors_as_string(authors)
|
128
136
|
Array.wrap(authors).map do |a|
|
129
|
-
if a[
|
130
|
-
[a[
|
131
|
-
elsif a[
|
132
|
-
a[
|
133
|
-
elsif a[
|
134
|
-
"{
|
137
|
+
if a['familyName'].present?
|
138
|
+
[a['familyName'], a['givenName']].join(', ')
|
139
|
+
elsif a['type'] == 'Person'
|
140
|
+
a['name']
|
141
|
+
elsif a['name'].present?
|
142
|
+
"{#{a['name']}}"
|
135
143
|
end
|
136
|
-
end.join(
|
144
|
+
end.join(' and ').presence
|
137
145
|
end
|
138
146
|
|
139
147
|
def get_affiliations(affiliations)
|
@@ -144,22 +152,22 @@ module Briard
|
|
144
152
|
affiliation_identifier_scheme = nil
|
145
153
|
scheme_uri = nil
|
146
154
|
else
|
147
|
-
if a[
|
148
|
-
affiliation_identifier = a[
|
149
|
-
if a[
|
150
|
-
schemeURI = a[
|
155
|
+
if a['affiliationIdentifier'].present?
|
156
|
+
affiliation_identifier = a['affiliationIdentifier']
|
157
|
+
if a['schemeURI'].present?
|
158
|
+
schemeURI = a['schemeURI'].end_with?('/') ? a['schemeURI'] : "#{a['schemeURI']}/"
|
151
159
|
end
|
152
|
-
affiliation_identifier = !affiliation_identifier.to_s.start_with?(
|
160
|
+
affiliation_identifier = !affiliation_identifier.to_s.start_with?('https://') && schemeURI.present? ? normalize_id(schemeURI + affiliation_identifier) : normalize_id(affiliation_identifier)
|
153
161
|
end
|
154
|
-
name = a[
|
155
|
-
affiliation_identifier_scheme = a[
|
156
|
-
scheme_uri = a[
|
162
|
+
name = a['__content__'].to_s.squish.presence
|
163
|
+
affiliation_identifier_scheme = a['affiliationIdentifierScheme']
|
164
|
+
scheme_uri = a['SchemeURI']
|
157
165
|
end
|
158
166
|
|
159
|
-
{
|
160
|
-
|
161
|
-
|
162
|
-
|
167
|
+
{ 'name' => name,
|
168
|
+
'affiliationIdentifier' => affiliation_identifier,
|
169
|
+
'affiliationIdentifierScheme' => affiliation_identifier_scheme,
|
170
|
+
'schemeUri' => scheme_uri }.compact
|
163
171
|
end.presence
|
164
172
|
end
|
165
173
|
end
|
data/lib/briard/cli.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
|
-
require
|
3
|
+
require 'thor'
|
5
4
|
|
6
5
|
require_relative 'doi_utils'
|
7
6
|
require_relative 'utils'
|
@@ -18,18 +17,18 @@ module Briard
|
|
18
17
|
# from http://stackoverflow.com/questions/22809972/adding-a-version-option-to-a-ruby-thor-cli
|
19
18
|
map %w[--version -v] => :__print_version
|
20
19
|
|
21
|
-
desc
|
20
|
+
desc '--version, -v', 'print the version'
|
22
21
|
def __print_version
|
23
22
|
puts Briard::VERSION
|
24
23
|
end
|
25
24
|
|
26
|
-
desc
|
27
|
-
method_option :from, aliases:
|
28
|
-
method_option :to, aliases:
|
29
|
-
method_option :regenerate, :
|
30
|
-
method_option :style, aliases:
|
31
|
-
method_option :locale, aliases:
|
32
|
-
method_option :show_errors, :
|
25
|
+
desc '', 'convert metadata'
|
26
|
+
method_option :from, aliases: '-f'
|
27
|
+
method_option :to, aliases: '-t', default: 'schema_org'
|
28
|
+
method_option :regenerate, type: :boolean, force: false
|
29
|
+
method_option :style, aliases: '-s', default: 'apa'
|
30
|
+
method_option :locale, aliases: '-l', default: 'en-US'
|
31
|
+
method_option :show_errors, type: :boolean, force: false
|
33
32
|
method_option :depositor
|
34
33
|
method_option :email
|
35
34
|
method_option :registrant
|
@@ -44,16 +43,16 @@ module Briard
|
|
44
43
|
depositor: options[:depositor],
|
45
44
|
email: options[:email],
|
46
45
|
registrant: options[:registrant])
|
47
|
-
to = options[:to] ||
|
46
|
+
to = options[:to] || 'schema_org'
|
48
47
|
|
49
48
|
if options[:show_errors] && !metadata.valid?
|
50
|
-
|
49
|
+
warn metadata.errors
|
51
50
|
else
|
52
51
|
puts metadata.send(to)
|
53
52
|
end
|
54
53
|
end
|
55
54
|
|
56
|
-
desc
|
55
|
+
desc '', 'encode'
|
57
56
|
def encode(prefix)
|
58
57
|
puts encode_doi(prefix)
|
59
58
|
end
|