bolognese 1.9.18 → 1.11.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/build.yml +4 -18
- data/.github/workflows/ci.yml +22 -0
- data/.github/workflows/pull-request.yml +2 -14
- data/.github/workflows/release.yml +8 -13
- data/CHANGELOG.md +20 -11
- data/Gemfile.lock +35 -21
- data/bolognese.gemspec +2 -2
- data/lib/bolognese/doi_utils.rb +4 -0
- data/lib/bolognese/readers/datacite_reader.rb +6 -6
- data/lib/bolognese/utils.rb +50 -9
- data/lib/bolognese/version.rb +1 -1
- data/spec/fixtures/datacite-example-relateditems-with-attributes.xml +61 -0
- data/spec/readers/datacite_reader_spec.rb +43 -0
- data/spec/utils_spec.rb +53 -4
- metadata +5 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f87808df4f12983e33877e77b31bc8aee2e1fe6f0a7e888da3d7b67ce19ab87e
|
4
|
+
data.tar.gz: 5143917378eacceff49c3d0d6e5b71f634237d025a7dad867db79ae34ed737f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 351c69b0b3b528bdbe5c89ec27a6f503e461c5acfb9060894d6822045193eb8a93cbc51fd952da023e5fb7cf9a52e0b710d03c92fd27ece9fb95062da0feaf6f
|
7
|
+
data.tar.gz: bf72537500650c6a963ea792af54d7d1ac18410e0160e6dd9088bdd9033fe2049a871367d76bf7f892fba03c20b2b9df75e744efaf03cd973305d3b75fff1d87
|
data/.github/workflows/build.yml
CHANGED
@@ -5,33 +5,19 @@ on:
|
|
5
5
|
branches:
|
6
6
|
- "master"
|
7
7
|
jobs:
|
8
|
+
ci:
|
9
|
+
uses: ./.github/workflows/ci.yml
|
8
10
|
build:
|
11
|
+
needs: ci
|
9
12
|
runs-on: ubuntu-latest
|
10
13
|
env:
|
11
14
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
12
15
|
steps:
|
13
|
-
- uses: actions/checkout@v2
|
14
|
-
- name: Set up Ruby 2.6
|
15
|
-
uses: actions/setup-ruby@v1
|
16
|
-
with:
|
17
|
-
ruby-version: 2.6.x
|
18
|
-
|
19
|
-
- name: Build and test
|
20
|
-
run: |
|
21
|
-
gem install bundler
|
22
|
-
bundle install
|
23
|
-
bundle exec rspec
|
24
|
-
|
25
|
-
- name: Publish code coverage
|
26
|
-
uses: paambaati/codeclimate-action@v2.7.4
|
27
|
-
env:
|
28
|
-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
29
|
-
|
30
16
|
- name: Notify Slack
|
31
17
|
uses: adamkdean/simple-slack-notify@1.0.4
|
32
18
|
with:
|
33
19
|
channel: '#ops'
|
34
20
|
username: 'GitHub Actions'
|
35
21
|
color: 'good'
|
36
|
-
text: 'A new version of the bolognese gem
|
22
|
+
text: 'A new version of the bolognese gem is ready for release.'
|
37
23
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: Run Tests
|
2
|
+
on:
|
3
|
+
workflow_call:
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
strategy:
|
8
|
+
fail-fast: false
|
9
|
+
matrix:
|
10
|
+
ruby: ["2.6", "2.7", "3.0", "3.1"]
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v3
|
14
|
+
- name: Set up Ruby ${{matrix.ruby}}
|
15
|
+
uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: ${{matrix.ruby}}
|
18
|
+
bundler-cache: true
|
19
|
+
|
20
|
+
- name: Run tests
|
21
|
+
run: |
|
22
|
+
bundle exec rspec
|
@@ -5,17 +5,5 @@ on:
|
|
5
5
|
branches:
|
6
6
|
- master
|
7
7
|
jobs:
|
8
|
-
|
9
|
-
|
10
|
-
steps:
|
11
|
-
- uses: actions/checkout@v2
|
12
|
-
- name: Set up Ruby 2.6
|
13
|
-
uses: actions/setup-ruby@v1
|
14
|
-
with:
|
15
|
-
ruby-version: 2.6.x
|
16
|
-
|
17
|
-
- name: Install and test
|
18
|
-
run: |
|
19
|
-
gem install bundler
|
20
|
-
bundle install
|
21
|
-
bundle exec rspec
|
8
|
+
ci:
|
9
|
+
uses: ./.github/workflows/ci.yml
|
@@ -4,28 +4,23 @@ on:
|
|
4
4
|
release:
|
5
5
|
types: [published]
|
6
6
|
jobs:
|
7
|
+
ci:
|
8
|
+
uses: ./.github/workflows/ci.yml
|
7
9
|
build:
|
10
|
+
needs: ci
|
8
11
|
runs-on: ubuntu-latest
|
9
12
|
env:
|
10
13
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
11
14
|
steps:
|
12
|
-
- uses: actions/checkout@
|
15
|
+
- uses: actions/checkout@v3
|
13
16
|
- name: Set up Ruby 2.6
|
14
|
-
uses:
|
17
|
+
uses: ruby/setup-ruby@v1
|
15
18
|
with:
|
16
|
-
ruby-version: 2.6
|
19
|
+
ruby-version: "2.6"
|
17
20
|
|
18
|
-
- name: Build
|
21
|
+
- name: Build
|
19
22
|
run: |
|
20
|
-
gem install bundler
|
21
23
|
bundle install
|
22
|
-
bundle exec rspec spec
|
23
|
-
|
24
|
-
- name: Code Climate Test Reporter
|
25
|
-
uses: aktions/codeclimate-test-reporter@v1
|
26
|
-
with:
|
27
|
-
codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }}
|
28
|
-
command: after-build
|
29
24
|
|
30
25
|
- name: Publish to RubyGems
|
31
26
|
run: |
|
@@ -44,4 +39,4 @@ jobs:
|
|
44
39
|
channel: '#ops'
|
45
40
|
username: 'GitHub Actions'
|
46
41
|
color: 'good'
|
47
|
-
text: 'A new version of the bolognese gem has been released.'
|
42
|
+
text: 'A new version of the bolognese gem has been released.'
|
data/CHANGELOG.md
CHANGED
@@ -1,20 +1,26 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## [
|
3
|
+
## [1.10.0](https://github.com/datacite/bolognese/tree/1.10.0) (2022-10-14)
|
4
4
|
|
5
|
-
[Full Changelog](https://github.com/datacite/bolognese/compare/1.9.18...
|
5
|
+
[Full Changelog](https://github.com/datacite/bolognese/compare/1.9.18...1.10.0)
|
6
6
|
|
7
|
-
**
|
7
|
+
**Merged pull requests:**
|
8
8
|
|
9
|
-
-
|
10
|
-
-
|
9
|
+
- Add DFG-to-FOS mappings utility function [\#147](https://github.com/datacite/bolognese/pull/147) ([jrhoads](https://github.com/jrhoads))
|
10
|
+
- Test against multiple versions of ruby \(2.6, 2.7, 3.0, and 3.1\) [\#141](https://github.com/datacite/bolognese/pull/141) ([jrhoads](https://github.com/jrhoads))
|
11
11
|
|
12
12
|
## [1.9.18](https://github.com/datacite/bolognese/tree/1.9.18) (2022-10-11)
|
13
13
|
|
14
14
|
[Full Changelog](https://github.com/datacite/bolognese/compare/1.9.17...1.9.18)
|
15
15
|
|
16
|
+
**Fixed bugs:**
|
17
|
+
|
18
|
+
- Fix related items handling to not include elements when they are blank [\#140](https://github.com/datacite/bolognese/issues/140)
|
19
|
+
- Related Items error out if RelatedItemIdentifier is nil [\#139](https://github.com/datacite/bolognese/issues/139)
|
20
|
+
|
16
21
|
**Merged pull requests:**
|
17
22
|
|
23
|
+
- bump version number [\#145](https://github.com/datacite/bolognese/pull/145) ([digitaldogsbody](https://github.com/digitaldogsbody))
|
18
24
|
- Fix relatedItems handling [\#144](https://github.com/datacite/bolognese/pull/144) ([digitaldogsbody](https://github.com/digitaldogsbody))
|
19
25
|
- Fixes normalization behavior that omitted non-URL funding identifiers when reading from DataCite XML. Adds normalization for Crossref Funder ID and ROR funderIdentifierTypes. [\#143](https://github.com/datacite/bolognese/pull/143) ([codycooperross](https://github.com/codycooperross))
|
20
26
|
- Including a schemeURI with a nameIdentifier that is a URL will concat… [\#137](https://github.com/datacite/bolognese/pull/137) ([codycooperross](https://github.com/codycooperross))
|
@@ -130,6 +136,10 @@
|
|
130
136
|
|
131
137
|
- Singular geoLocationPolygons are wrapped in additional array [\#110](https://github.com/datacite/bolognese/issues/110)
|
132
138
|
|
139
|
+
**Merged pull requests:**
|
140
|
+
|
141
|
+
- Support returning single geoLocationPolygon [\#111](https://github.com/datacite/bolognese/pull/111) ([richardhallett](https://github.com/richardhallett))
|
142
|
+
|
133
143
|
## [1.9.3](https://github.com/datacite/bolognese/tree/1.9.3) (2021-03-26)
|
134
144
|
|
135
145
|
[Full Changelog](https://github.com/datacite/bolognese/compare/1.9.2...1.9.3)
|
@@ -159,7 +169,6 @@
|
|
159
169
|
|
160
170
|
**Merged pull requests:**
|
161
171
|
|
162
|
-
- Support returning single geoLocationPolygon [\#111](https://github.com/datacite/bolognese/pull/111) ([richardhallett](https://github.com/richardhallett))
|
163
172
|
- Change detection for crosscite format [\#107](https://github.com/datacite/bolognese/pull/107) ([richardhallett](https://github.com/richardhallett))
|
164
173
|
- Add support for multiple geolocation polygons [\#106](https://github.com/datacite/bolognese/pull/106) ([richardhallett](https://github.com/richardhallett))
|
165
174
|
- Support schema 4 4 [\#105](https://github.com/datacite/bolognese/pull/105) ([richardhallett](https://github.com/richardhallett))
|
@@ -1380,15 +1389,15 @@
|
|
1380
1389
|
|
1381
1390
|
## [v.0.9.70](https://github.com/datacite/bolognese/tree/v.0.9.70) (2018-01-12)
|
1382
1391
|
|
1383
|
-
[Full Changelog](https://github.com/datacite/bolognese/compare/v.0.
|
1392
|
+
[Full Changelog](https://github.com/datacite/bolognese/compare/v.0.9.69...v.0.9.70)
|
1384
1393
|
|
1385
|
-
## [v.0.
|
1394
|
+
## [v.0.9.69](https://github.com/datacite/bolognese/tree/v.0.9.69) (2018-01-11)
|
1386
1395
|
|
1387
|
-
[Full Changelog](https://github.com/datacite/bolognese/compare/v.0.
|
1396
|
+
[Full Changelog](https://github.com/datacite/bolognese/compare/v.0.6.69...v.0.9.69)
|
1388
1397
|
|
1389
|
-
## [v.0.
|
1398
|
+
## [v.0.6.69](https://github.com/datacite/bolognese/tree/v.0.6.69) (2018-01-11)
|
1390
1399
|
|
1391
|
-
[Full Changelog](https://github.com/datacite/bolognese/compare/v.0.9.68...v.0.
|
1400
|
+
[Full Changelog](https://github.com/datacite/bolognese/compare/v.0.9.68...v.0.6.69)
|
1392
1401
|
|
1393
1402
|
## [v.0.9.68](https://github.com/datacite/bolognese/tree/v.0.9.68) (2018-01-11)
|
1394
1403
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bolognese (1.
|
4
|
+
bolognese (1.11.0)
|
5
5
|
activesupport (>= 4.2.5)
|
6
6
|
benchmark_methods (~> 0.7)
|
7
7
|
bibtex-ruby (>= 5.1.0)
|
@@ -11,7 +11,6 @@ PATH
|
|
11
11
|
concurrent-ruby (~> 1.1, >= 1.1.5)
|
12
12
|
csl-styles (~> 1.0, >= 1.0.1.10)
|
13
13
|
edtf (~> 3.0, >= 3.0.4)
|
14
|
-
faraday (~> 0.17.3)
|
15
14
|
gender_detector (~> 0.1.2)
|
16
15
|
iso8601 (~> 0.9.1)
|
17
16
|
json-ld-preloaded (~> 3.1, >= 3.1.3)
|
@@ -36,8 +35,8 @@ GEM
|
|
36
35
|
minitest (>= 5.1)
|
37
36
|
tzinfo (~> 2.0)
|
38
37
|
zeitwerk (~> 2.3)
|
39
|
-
addressable (2.8.
|
40
|
-
public_suffix (>= 2.0.2, <
|
38
|
+
addressable (2.8.1)
|
39
|
+
public_suffix (>= 2.0.2, < 6.0)
|
41
40
|
amazing_print (1.4.0)
|
42
41
|
benchmark_methods (0.7)
|
43
42
|
bibtex-ruby (6.0.0)
|
@@ -70,12 +69,22 @@ GEM
|
|
70
69
|
edtf (3.1.0)
|
71
70
|
activesupport (>= 3.0, < 8.0)
|
72
71
|
excon (0.71.1)
|
73
|
-
faraday (
|
74
|
-
|
72
|
+
faraday (2.6.0)
|
73
|
+
faraday-net_http (>= 2.0, < 3.1)
|
74
|
+
ruby2_keywords (>= 0.0.4)
|
75
75
|
faraday-encoding (0.0.5)
|
76
76
|
faraday
|
77
|
-
|
78
|
-
|
77
|
+
faraday-excon (2.1.0)
|
78
|
+
excon (>= 0.27.4)
|
79
|
+
faraday (~> 2.0)
|
80
|
+
faraday-follow_redirects (0.3.0)
|
81
|
+
faraday (>= 1, < 3)
|
82
|
+
faraday-gzip (0.1.0)
|
83
|
+
faraday (>= 1.0)
|
84
|
+
zlib (~> 2.1)
|
85
|
+
faraday-multipart (1.0.4)
|
86
|
+
multipart-post (~> 2)
|
87
|
+
faraday-net_http (3.0.1)
|
79
88
|
gender_detector (0.1.2)
|
80
89
|
unicode_utils (>= 1.3.0)
|
81
90
|
haml (5.2.2)
|
@@ -106,15 +115,18 @@ GEM
|
|
106
115
|
loofah (2.19.0)
|
107
116
|
crass (~> 1.0.2)
|
108
117
|
nokogiri (>= 1.5.9)
|
109
|
-
maremma (4.9.
|
118
|
+
maremma (4.9.9)
|
110
119
|
activesupport (>= 4.2.5)
|
111
120
|
addressable (>= 2.3.6)
|
112
121
|
builder (~> 3.2, >= 3.2.2)
|
113
122
|
excon (~> 0.71.0)
|
114
|
-
faraday (
|
115
|
-
faraday-encoding (~> 0.0.
|
116
|
-
|
117
|
-
|
123
|
+
faraday (>= 2.0)
|
124
|
+
faraday-encoding (~> 0.0.5)
|
125
|
+
faraday-excon (~> 2.1.0)
|
126
|
+
faraday-follow_redirects (~> 0.3.0)
|
127
|
+
faraday-gzip (~> 0.1.0)
|
128
|
+
faraday-multipart (~> 1.0.4)
|
129
|
+
nokogiri (>= 1.13.1, < 1.14.0)
|
118
130
|
oj (>= 2.8.3)
|
119
131
|
oj_mimic_json (~> 1.0, >= 1.0.1)
|
120
132
|
matrix (0.4.2)
|
@@ -123,7 +135,7 @@ GEM
|
|
123
135
|
multi_json (1.15.0)
|
124
136
|
multipart-post (2.2.3)
|
125
137
|
namae (1.1.1)
|
126
|
-
nokogiri (1.13.
|
138
|
+
nokogiri (1.13.9)
|
127
139
|
mini_portile2 (~> 2.8.0)
|
128
140
|
racc (~> 1.4)
|
129
141
|
oj (3.13.21)
|
@@ -135,7 +147,7 @@ GEM
|
|
135
147
|
public_suffix (>= 2.0.0, < 2.1)
|
136
148
|
public_suffix (2.0.5)
|
137
149
|
racc (1.6.0)
|
138
|
-
rack (2.2.
|
150
|
+
rack (2.2.4)
|
139
151
|
rack-test (0.8.3)
|
140
152
|
rack (>= 1.0, < 3)
|
141
153
|
rake (12.3.3)
|
@@ -170,24 +182,25 @@ GEM
|
|
170
182
|
rspec-mocks (~> 3.11.0)
|
171
183
|
rspec-core (3.11.0)
|
172
184
|
rspec-support (~> 3.11.0)
|
173
|
-
rspec-expectations (3.11.
|
185
|
+
rspec-expectations (3.11.1)
|
174
186
|
diff-lcs (>= 1.2.0, < 2.0)
|
175
187
|
rspec-support (~> 3.11.0)
|
176
188
|
rspec-mocks (3.11.1)
|
177
189
|
diff-lcs (>= 1.2.0, < 2.0)
|
178
190
|
rspec-support (~> 3.11.0)
|
179
|
-
rspec-support (3.11.
|
191
|
+
rspec-support (3.11.1)
|
180
192
|
rspec-xsd (0.1.0)
|
181
193
|
nokogiri (~> 1.6)
|
182
194
|
rspec (~> 3)
|
195
|
+
ruby2_keywords (0.0.5)
|
183
196
|
scanf (1.0.0)
|
184
197
|
simplecov (0.17.1)
|
185
198
|
docile (~> 1.1)
|
186
199
|
json (>= 1.8, < 3)
|
187
200
|
simplecov-html (~> 0.10.0)
|
188
201
|
simplecov-html (0.10.2)
|
189
|
-
sxp (1.2.
|
190
|
-
matrix
|
202
|
+
sxp (1.2.3)
|
203
|
+
matrix (~> 0.4)
|
191
204
|
rdf (~> 3.2)
|
192
205
|
temple (0.8.2)
|
193
206
|
thor (1.2.1)
|
@@ -197,11 +210,12 @@ GEM
|
|
197
210
|
unicode-types (1.8.0)
|
198
211
|
unicode_utils (1.4.0)
|
199
212
|
vcr (3.0.3)
|
200
|
-
webmock (3.
|
213
|
+
webmock (3.18.1)
|
201
214
|
addressable (>= 2.8.0)
|
202
215
|
crack (>= 0.3.2)
|
203
216
|
hashdiff (>= 0.4.0, < 2.0.0)
|
204
217
|
zeitwerk (2.6.1)
|
218
|
+
zlib (2.1.1)
|
205
219
|
|
206
220
|
PLATFORMS
|
207
221
|
ruby
|
@@ -219,4 +233,4 @@ DEPENDENCIES
|
|
219
233
|
webmock (~> 3.0, >= 3.0.1)
|
220
234
|
|
221
235
|
BUNDLED WITH
|
222
|
-
2.3.
|
236
|
+
2.3.12
|
data/bolognese.gemspec
CHANGED
@@ -13,11 +13,11 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.version = Bolognese::VERSION
|
14
14
|
s.extra_rdoc_files = ["README.md"]
|
15
15
|
s.license = 'MIT'
|
16
|
-
s.required_ruby_version = '
|
16
|
+
s.required_ruby_version = ['>=2.3']
|
17
17
|
|
18
18
|
# Declare dependencies here, rather than in the Gemfile
|
19
19
|
s.add_dependency 'maremma', '>= 4.9.4', '< 5'
|
20
|
-
s.add_dependency 'faraday', '~> 0.17.3'
|
20
|
+
#s.add_dependency 'faraday', '~> 0.17.3'
|
21
21
|
s.add_dependency 'nokogiri', '>= 1.13.2', '< 1.14'
|
22
22
|
s.add_dependency 'loofah', '~> 2.0', '>= 2.0.3'
|
23
23
|
s.add_dependency 'builder', '~> 3.2', '>= 3.2.2'
|
data/lib/bolognese/doi_utils.rb
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
module Bolognese
|
4
4
|
module DoiUtils
|
5
|
+
class << self
|
6
|
+
include DoiUtils
|
7
|
+
end
|
8
|
+
|
5
9
|
def validate_doi(doi)
|
6
10
|
doi = Array(/\A(?:(http|https):\/(\/)?(dx\.)?(doi.org|handle.stage.datacite.org|handle.test.datacite.org)\/)?(doi:)?(10\.\d{4,5}\/.+)\z/.match(doi)).last
|
7
11
|
# remove non-printing whitespace and downcase
|
@@ -230,14 +230,14 @@ module Bolognese
|
|
230
230
|
"creators" => get_authors(Array.wrap(ri.dig("creators", "creator"))),
|
231
231
|
"titles" => get_titles(ri),
|
232
232
|
"publicationYear" => ri["publicationYear"],
|
233
|
-
"volume" => ri["volume"],
|
234
|
-
"issue" => ri["issue"],
|
233
|
+
"volume" => parse_attributes(ri["volume"]),
|
234
|
+
"issue" => parse_attributes(ri["issue"]),
|
235
235
|
"number" => number,
|
236
236
|
"numberType" => numberType,
|
237
|
-
"firstPage" => ri["firstPage"],
|
238
|
-
"lastPage" => ri["lastPage"],
|
239
|
-
"publisher" => ri["publisher"],
|
240
|
-
"edition" => ri["edition"],
|
237
|
+
"firstPage" => parse_attributes(ri["firstPage"]),
|
238
|
+
"lastPage" => parse_attributes(ri["lastPage"]),
|
239
|
+
"publisher" => parse_attributes(ri["publisher"]),
|
240
|
+
"edition" => parse_attributes(ri["edition"]),
|
241
241
|
"contributors" => get_authors(Array.wrap(ri.dig("contributors", "contributor"))),
|
242
242
|
}.compact
|
243
243
|
end
|
data/lib/bolognese/utils.rb
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
module Bolognese
|
4
4
|
module Utils
|
5
|
+
class << self
|
6
|
+
include Utils
|
7
|
+
end
|
8
|
+
|
5
9
|
NORMALIZED_LICENSES = {
|
6
10
|
"https://creativecommons.org/licenses/by/1.0" => "https://creativecommons.org/licenses/by/1.0/legalcode",
|
7
11
|
"https://creativecommons.org/licenses/by/2.0" => "https://creativecommons.org/licenses/by/2.0/legalcode",
|
@@ -484,6 +488,28 @@ module Bolognese
|
|
484
488
|
":etal" => "too numerous to list (et alia)"
|
485
489
|
}
|
486
490
|
|
491
|
+
RESOURCE_PATHS = {
|
492
|
+
spdx: 'spdx/licenses.json',
|
493
|
+
fos: 'oecd/fos-mappings.json',
|
494
|
+
for: 'oecd/for-mappings.json',
|
495
|
+
dfg: 'oecd/dfg-mappings.json'
|
496
|
+
}
|
497
|
+
|
498
|
+
def resources_dir_path
|
499
|
+
File.expand_path('../../../resources', __FILE__) + '/'
|
500
|
+
end
|
501
|
+
|
502
|
+
def resource_file( extra_path )
|
503
|
+
File.read(resources_dir_path + extra_path)
|
504
|
+
end
|
505
|
+
|
506
|
+
def resource_json( resource_symbol )
|
507
|
+
if RESOURCE_PATHS.keys().include?(resource_symbol)
|
508
|
+
JSON.load(resource_file(RESOURCE_PATHS[resource_symbol]))
|
509
|
+
end
|
510
|
+
end
|
511
|
+
|
512
|
+
|
487
513
|
def find_from_format(id: nil, string: nil, ext: nil, filename: nil)
|
488
514
|
if id.present?
|
489
515
|
find_from_format_by_id(id)
|
@@ -615,7 +641,7 @@ module Bolognese
|
|
615
641
|
return nil unless id.present?
|
616
642
|
|
617
643
|
# check for valid DOI
|
618
|
-
doi = normalize_doi(id, options)
|
644
|
+
doi = DoiUtils::normalize_doi(id, options)
|
619
645
|
return doi if doi.present?
|
620
646
|
|
621
647
|
# check for valid HTTP uri
|
@@ -674,8 +700,8 @@ module Bolognese
|
|
674
700
|
def normalize_ids(ids: nil, relation_type: nil)
|
675
701
|
Array.wrap(ids).select { |idx| idx["@id"].present? }.map do |idx|
|
676
702
|
id = normalize_id(idx["@id"])
|
677
|
-
related_identifier_type = doi_from_url(id).present? ? "DOI" : "URL"
|
678
|
-
id = doi_from_url(id) || id
|
703
|
+
related_identifier_type = DoiUtils::doi_from_url(id).present? ? "DOI" : "URL"
|
704
|
+
id = DoiUtils::doi_from_url(id) || id
|
679
705
|
|
680
706
|
{ "relatedIdentifier" => id,
|
681
707
|
"relationType" => relation_type,
|
@@ -1233,7 +1259,7 @@ module Bolognese
|
|
1233
1259
|
end
|
1234
1260
|
|
1235
1261
|
def name_to_spdx(name)
|
1236
|
-
spdx =
|
1262
|
+
spdx = resource_json(:spdx).fetch("licenses")
|
1237
1263
|
license = spdx.find { |l| l["name"] == name || l["licenseId"] == name || l["seeAlso"].first == normalize_cc_url(name) }
|
1238
1264
|
|
1239
1265
|
if license
|
@@ -1249,7 +1275,7 @@ module Bolognese
|
|
1249
1275
|
end
|
1250
1276
|
|
1251
1277
|
def hsh_to_spdx(hsh)
|
1252
|
-
spdx =
|
1278
|
+
spdx = resource_json(:spdx).fetch("licenses")
|
1253
1279
|
license = spdx.find { |l| l["licenseId"].casecmp?(hsh["rightsIdentifier"]) || l["seeAlso"].first == normalize_cc_url(hsh["rightsURI"]) || l["name"] == hsh["rights"] || l["seeAlso"].first == normalize_cc_url(hsh["rights"]) }
|
1254
1280
|
|
1255
1281
|
if license
|
@@ -1273,7 +1299,7 @@ module Bolognese
|
|
1273
1299
|
|
1274
1300
|
def name_to_fos(name)
|
1275
1301
|
# first find subject in Fields of Science (OECD)
|
1276
|
-
fos =
|
1302
|
+
fos = resource_json(:fos).fetch("fosFields")
|
1277
1303
|
|
1278
1304
|
subject = fos.find { |l| l["fosLabel"] == name || "FOS: " + l["fosLabel"] == name }
|
1279
1305
|
|
@@ -1289,7 +1315,7 @@ module Bolognese
|
|
1289
1315
|
|
1290
1316
|
# if not found, look in Fields of Research (Australian and New Zealand Standard Research Classification)
|
1291
1317
|
# and map to Fields of Science. Add an extra entry for the latter
|
1292
|
-
fores =
|
1318
|
+
fores = resource_json(:for)
|
1293
1319
|
for_fields = fores.fetch("forFields")
|
1294
1320
|
for_disciplines = fores.fetch("forDisciplines")
|
1295
1321
|
|
@@ -1311,7 +1337,7 @@ module Bolognese
|
|
1311
1337
|
|
1312
1338
|
def hsh_to_fos(hsh)
|
1313
1339
|
# first find subject in Fields of Science (OECD)
|
1314
|
-
fos =
|
1340
|
+
fos = resource_json(:fos).fetch("fosFields")
|
1315
1341
|
subject = fos.find { |l| l["fosLabel"] == hsh["__content__"] || "FOS: " + l["fosLabel"] == hsh["__content__"] || l["fosLabel"] == hsh["subject"]}
|
1316
1342
|
|
1317
1343
|
if subject
|
@@ -1330,7 +1356,7 @@ module Bolognese
|
|
1330
1356
|
|
1331
1357
|
# if not found, look in Fields of Research (Australian and New Zealand Standard Research Classification)
|
1332
1358
|
# and map to Fields of Science. Add an extra entry for the latter
|
1333
|
-
fores =
|
1359
|
+
fores = resource_json(:for)
|
1334
1360
|
for_fields = fores.fetch("forFields")
|
1335
1361
|
for_disciplines = fores.fetch("forDisciplines")
|
1336
1362
|
|
@@ -1369,5 +1395,20 @@ module Bolognese
|
|
1369
1395
|
"lang" => hsh["lang"] }.compact]
|
1370
1396
|
end
|
1371
1397
|
end
|
1398
|
+
|
1399
|
+
def dfg_ids_to_fos(dfg_ids)
|
1400
|
+
dfgs = resource_json(:dfg).fetch("dfgFields")
|
1401
|
+
ids = Array.wrap(dfg_ids)
|
1402
|
+
|
1403
|
+
subjects = dfgs.select { |l| ids.include?(l["dfgId"])}
|
1404
|
+
subjects.map do |subject|
|
1405
|
+
{
|
1406
|
+
"classificationCode" => subject["fosId"],
|
1407
|
+
"subject" => subject["fosLabel"],
|
1408
|
+
"subjectScheme" => "Fields of Science and Technology (FOS)",
|
1409
|
+
"schemeUri" => "http://www.oecd.org/science/inno/38235147.pdf"
|
1410
|
+
}
|
1411
|
+
end
|
1412
|
+
end
|
1372
1413
|
end
|
1373
1414
|
end
|
data/lib/bolognese/version.rb
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
3
|
+
xmlns="http://datacite.org/schema/kernel-4" xsi:schemaLocation="http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4.4/metadata.xsd">
|
4
|
+
<identifier identifierType="DOI">10.5072/example-full</identifier>
|
5
|
+
<creators>
|
6
|
+
<creator>
|
7
|
+
<creatorName nameType="Personal">Hallett, Richard</creatorName>
|
8
|
+
<givenName>Richard</givenName>
|
9
|
+
<familyName>Hallett</familyName>
|
10
|
+
</creator>
|
11
|
+
</creators>
|
12
|
+
<titles>
|
13
|
+
<title xml:lang="en-US">Example for related items</title>
|
14
|
+
</titles>
|
15
|
+
<publisher xml:lang="en">DataCite</publisher>
|
16
|
+
<publicationYear>2021</publicationYear>
|
17
|
+
<dates>
|
18
|
+
<date dateType="Updated" dateInformation="Updated with 4.4 properties">2021-01-26</date>
|
19
|
+
</dates>
|
20
|
+
<language>en-US</language>
|
21
|
+
<resourceType resourceTypeGeneral="Software">XML</resourceType>
|
22
|
+
<version>1</version>
|
23
|
+
<descriptions>
|
24
|
+
<description xml:lang="en-US" descriptionType="Abstract">A test example for related items</description>
|
25
|
+
</descriptions>
|
26
|
+
<relatedItems>
|
27
|
+
<relatedItem relationType="IsPublishedIn" relatedItemType="Journal">
|
28
|
+
<relatedItemIdentifier
|
29
|
+
relatedItemIdentifierType="DOI"
|
30
|
+
relatedMetadataScheme="citeproc+json"
|
31
|
+
schemeURI="https://github.com/citation-style-language/schema/raw/master/csl-data.json"
|
32
|
+
schemeType="URL">10.5072/john-smiths-1234</relatedItemIdentifier>
|
33
|
+
<creators>
|
34
|
+
<creator>
|
35
|
+
<creatorName nameType="Personal">Smith, John</creatorName>
|
36
|
+
<givenName>John</givenName>
|
37
|
+
<familyName>Smith</familyName>
|
38
|
+
</creator>
|
39
|
+
</creators>
|
40
|
+
<titles>
|
41
|
+
<title>Understanding the fictional John Smith</title>
|
42
|
+
<title titleType="Subtitle">A detailed look</title>
|
43
|
+
</titles>
|
44
|
+
<publicationYear>1776</publicationYear>
|
45
|
+
<volume xml:lang="en">776</volume>
|
46
|
+
<issue xml:lang="en">1</issue>
|
47
|
+
<number numberType="Chapter">1</number>
|
48
|
+
<firstPage xml:lang="en">50</firstPage>
|
49
|
+
<lastPage xml:lang="en">60</lastPage>
|
50
|
+
<publisher xml:lang="en">Example Inc</publisher>
|
51
|
+
<edition xml:lang="en">1</edition>
|
52
|
+
<contributors>
|
53
|
+
<contributor contributorType="ProjectLeader">
|
54
|
+
<contributorName>Richard, Hallett</contributorName>
|
55
|
+
<givenName>Richard</givenName>
|
56
|
+
<familyName>Hallett</familyName>
|
57
|
+
</contributor>
|
58
|
+
</contributors>
|
59
|
+
</relatedItem>
|
60
|
+
</relatedItems>
|
61
|
+
</resource>
|
@@ -1555,6 +1555,49 @@ describe Bolognese::Metadata, vcr: true do
|
|
1555
1555
|
)
|
1556
1556
|
end
|
1557
1557
|
|
1558
|
+
it "Schema 4.4 related items from string with attributes" do
|
1559
|
+
input = fixture_path + "datacite-example-relateditems-with-attributes.xml"
|
1560
|
+
subject = Bolognese::Metadata.new(input: input)
|
1561
|
+
expect(subject.valid?).to be true
|
1562
|
+
|
1563
|
+
expect(subject.related_items.last).to eq(
|
1564
|
+
{
|
1565
|
+
"relatedItemType"=>"Journal",
|
1566
|
+
"relationType"=>"IsPublishedIn",
|
1567
|
+
"relatedItemIdentifier"=>
|
1568
|
+
{
|
1569
|
+
"relatedItemIdentifier"=>"10.5072/john-smiths-1234",
|
1570
|
+
"relatedItemIdentifierType"=>"DOI",
|
1571
|
+
"relatedMetadataScheme"=>"citeproc+json",
|
1572
|
+
"schemeURI"=>"https://github.com/citation-style-language/schema/raw/master/csl-data.json",
|
1573
|
+
"schemeType"=>"URL"
|
1574
|
+
},
|
1575
|
+
"creators" =>
|
1576
|
+
[
|
1577
|
+
{"nameType"=>"Personal", "name"=>"Smith, John", "givenName"=>"John", "familyName"=>"Smith"}
|
1578
|
+
],
|
1579
|
+
"titles"=>
|
1580
|
+
[
|
1581
|
+
{"title"=>"Understanding the fictional John Smith"},
|
1582
|
+
{"title"=>"A detailed look", "titleType"=>"Subtitle"}
|
1583
|
+
],
|
1584
|
+
"volume"=>"776",
|
1585
|
+
"issue"=>"1",
|
1586
|
+
"number"=>"1",
|
1587
|
+
"numberType"=>"Chapter",
|
1588
|
+
"firstPage"=>"50",
|
1589
|
+
"lastPage"=>"60",
|
1590
|
+
"publisher"=>"Example Inc",
|
1591
|
+
"publicationYear"=>"1776",
|
1592
|
+
"edition"=>"1",
|
1593
|
+
"contributors"=>
|
1594
|
+
[
|
1595
|
+
{"name"=>"Hallett, Richard", "givenName"=>"Richard", "familyName"=>"Hallett", "contributorType"=>"ProjectLeader"}
|
1596
|
+
]
|
1597
|
+
}
|
1598
|
+
)
|
1599
|
+
end
|
1600
|
+
|
1558
1601
|
it "Schema 4.4 dissertation from string" do
|
1559
1602
|
input = fixture_path + "datacite-example-dissertation-v4.4.xml"
|
1560
1603
|
subject = Bolognese::Metadata.new(input: input)
|
data/spec/utils_spec.rb
CHANGED
@@ -2,10 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Bolognese::
|
6
|
-
|
7
|
-
|
8
|
-
subject { Bolognese::Metadata.new(input: input, from: "crossref") }
|
5
|
+
describe Bolognese::Utils do
|
6
|
+
subject { Bolognese::Utils }
|
9
7
|
|
10
8
|
context "validate url" do
|
11
9
|
it "DOI" do
|
@@ -614,4 +612,55 @@ describe Bolognese::Metadata, vcr: true do
|
|
614
612
|
end
|
615
613
|
|
616
614
|
end
|
615
|
+
|
616
|
+
context "DFG mappings" do
|
617
|
+
it "dfg_id_to_fos match" do
|
618
|
+
dfg_id = "20108"
|
619
|
+
response = subject.dfg_ids_to_fos(dfg_id)
|
620
|
+
expect(response).to eq([
|
621
|
+
{
|
622
|
+
"classificationCode" =>"1.6",
|
623
|
+
"subject" => "Biological sciences",
|
624
|
+
"subjectScheme" => "Fields of Science and Technology (FOS)",
|
625
|
+
"schemeUri" => "http://www.oecd.org/science/inno/38235147.pdf"
|
626
|
+
},
|
627
|
+
{
|
628
|
+
"classificationCode" =>"3.1",
|
629
|
+
"subject" => "Basic medicine",
|
630
|
+
"subjectScheme" => "Fields of Science and Technology (FOS)",
|
631
|
+
"schemeUri" => "http://www.oecd.org/science/inno/38235147.pdf"
|
632
|
+
},
|
633
|
+
])
|
634
|
+
end
|
635
|
+
it "dfg_id_to_fos no match" do
|
636
|
+
dfg_id = "000"
|
637
|
+
response = subject.dfg_ids_to_fos(dfg_id)
|
638
|
+
expect(response).to eq([])
|
639
|
+
end
|
640
|
+
|
641
|
+
it "dfg_id_to_fos match list" do
|
642
|
+
dfg_ids = ["101", "20108"]
|
643
|
+
response = subject.dfg_ids_to_fos(dfg_ids)
|
644
|
+
expect(response).to eq([
|
645
|
+
{"classificationCode"=>"6.1",
|
646
|
+
"schemeUri"=>"http://www.oecd.org/science/inno/38235147.pdf",
|
647
|
+
"subject"=>"History and archaeology",
|
648
|
+
"subjectScheme"=>"Fields of Science and Technology (FOS)"},
|
649
|
+
{"classificationCode"=>"6.2",
|
650
|
+
"schemeUri"=>"http://www.oecd.org/science/inno/38235147.pdf",
|
651
|
+
"subject"=>"Languages and literature",
|
652
|
+
"subjectScheme"=>"Fields of Science and Technology (FOS)"},
|
653
|
+
{"classificationCode"=>"1.6",
|
654
|
+
"schemeUri"=>"http://www.oecd.org/science/inno/38235147.pdf",
|
655
|
+
"subject"=>"Biological sciences",
|
656
|
+
"subjectScheme"=>"Fields of Science and Technology (FOS)"},
|
657
|
+
{"classificationCode"=>"3.1",
|
658
|
+
"schemeUri"=>"http://www.oecd.org/science/inno/38235147.pdf",
|
659
|
+
"subject"=>"Basic medicine",
|
660
|
+
"subjectScheme"=>"Fields of Science and Technology (FOS)"}
|
661
|
+
])
|
662
|
+
end
|
663
|
+
|
664
|
+
|
665
|
+
end
|
617
666
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bolognese
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Fenner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: maremma
|
@@ -30,20 +30,6 @@ dependencies:
|
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '5'
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: faraday
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: 0.17.3
|
40
|
-
type: :runtime
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 0.17.3
|
47
33
|
- !ruby/object:Gem::Dependency
|
48
34
|
name: nokogiri
|
49
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -567,6 +553,7 @@ extra_rdoc_files:
|
|
567
553
|
files:
|
568
554
|
- ".github/workflows/build.yml"
|
569
555
|
- ".github/workflows/changelog.yml"
|
556
|
+
- ".github/workflows/ci.yml"
|
570
557
|
- ".github/workflows/pull-request.yml"
|
571
558
|
- ".github/workflows/release.yml"
|
572
559
|
- ".gitignore"
|
@@ -784,6 +771,7 @@ files:
|
|
784
771
|
- spec/fixtures/datacite-example-geolocation.xml
|
785
772
|
- spec/fixtures/datacite-example-nameIdentifier-with-schemeURI.xml
|
786
773
|
- spec/fixtures/datacite-example-polygon-v4.1.xml
|
774
|
+
- spec/fixtures/datacite-example-relateditems-with-attributes.xml
|
787
775
|
- spec/fixtures/datacite-example-relateditems.xml
|
788
776
|
- spec/fixtures/datacite-example-xs-string.xml
|
789
777
|
- spec/fixtures/datacite-formats-with-xs.xml
|
@@ -1288,7 +1276,7 @@ require_paths:
|
|
1288
1276
|
- lib
|
1289
1277
|
required_ruby_version: !ruby/object:Gem::Requirement
|
1290
1278
|
requirements:
|
1291
|
-
- - "
|
1279
|
+
- - ">="
|
1292
1280
|
- !ruby/object:Gem::Version
|
1293
1281
|
version: '2.3'
|
1294
1282
|
required_rubygems_version: !ruby/object:Gem::Requirement
|