bolognese 1.9.17 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd97b1d21783c57768cd25908cbd6be7d676c1f6993a0c242d5c3f254ad22b93
4
- data.tar.gz: 10a5d72f8291eb95773b0f65b3ebc161072c98ff62fd7ac7c90263fa1be63578
3
+ metadata.gz: 532586fba70709be6c7581b595a2c0d72ad1000c9c54b951ad5e4758715e81c1
4
+ data.tar.gz: 3029c21ac460e41479459df642e3d501b1195e6cc8a0e26d6a4ba5bba91ce13f
5
5
  SHA512:
6
- metadata.gz: 6d05090c57b150bf61a9111a57aab3432d7fceaf60b75949476571344b61838b25140a816d2b2bd3b052f071428193f3dc9bcfdc6a452552cf7af1212c97060b
7
- data.tar.gz: ebf7a1b66b48cfe38ab3cdd308c9c936638fffb64fd3b756ec0d5b51c89545bdb07c23e0443d9536c18d2761c16a9133e860c703e102e1b66b01ed2c40b153ad
6
+ metadata.gz: 3893a351e49ad8e8acb0ef5265fb3acdc149e67a99174de0d0855d594e7d9c16f09baeda4d9b1aba7235aef661135e7d1bd1ac401df81601c99217e155153395
7
+ data.tar.gz: f6225b13dae84dcc897fa1dda7aadb266e667f8bf6a3a2da2e3f6ad134f314f17c3c6613ef8c2dec54091d9f4b4f055023bdb00ace39baf018b1654820cf7eff
@@ -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 has been built.'
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
- build:
9
- runs-on: ubuntu-latest
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@v2
15
+ - uses: actions/checkout@v3
13
16
  - name: Set up Ruby 2.6
14
- uses: actions/setup-ruby@v1
17
+ uses: ruby/setup-ruby@v1
15
18
  with:
16
- ruby-version: 2.6.x
19
+ ruby-version: "2.6"
17
20
 
18
- - name: Build and test
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,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.10.0](https://github.com/datacite/bolognese/tree/1.10.0) (2022-10-14)
4
+
5
+ [Full Changelog](https://github.com/datacite/bolognese/compare/1.9.18...1.10.0)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Add DFG-to-FOS mappings utility function [\#147](https://github.com/datacite/bolognese/pull/147) ([jrhoads](https://github.com/jrhoads))
10
+
11
+ ## [1.9.18](https://github.com/datacite/bolognese/tree/1.9.18) (2022-10-11)
12
+
13
+ [Full Changelog](https://github.com/datacite/bolognese/compare/1.9.17...1.9.18)
14
+
15
+ **Fixed bugs:**
16
+
17
+ - Fix related items handling to not include elements when they are blank [\#140](https://github.com/datacite/bolognese/issues/140)
18
+ - Related Items error out if RelatedItemIdentifier is nil [\#139](https://github.com/datacite/bolognese/issues/139)
19
+
20
+ **Merged pull requests:**
21
+
22
+ - bump version number [\#145](https://github.com/datacite/bolognese/pull/145) ([digitaldogsbody](https://github.com/digitaldogsbody))
23
+ - Fix relatedItems handling [\#144](https://github.com/datacite/bolognese/pull/144) ([digitaldogsbody](https://github.com/digitaldogsbody))
24
+ - 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))
25
+ - 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))
26
+
27
+ ## [1.9.17](https://github.com/datacite/bolognese/tree/1.9.17) (2022-07-04)
28
+
29
+ [Full Changelog](https://github.com/datacite/bolognese/compare/1.9.16...1.9.17)
30
+
3
31
  ## [1.9.16](https://github.com/datacite/bolognese/tree/1.9.16) (2022-07-04)
4
32
 
5
33
  [Full Changelog](https://github.com/datacite/bolognese/compare/1.9.15...1.9.16)
@@ -36,7 +64,6 @@
36
64
  **Merged pull requests:**
37
65
 
38
66
  - update nokogiri to latest, including updating maremma [\#130](https://github.com/datacite/bolognese/pull/130) ([orangewolf](https://github.com/orangewolf))
39
- - mapping for DFG-to-OECD [\#125](https://github.com/datacite/bolognese/pull/125) ([kjgarza](https://github.com/kjgarza))
40
67
 
41
68
  ## [1.9.12](https://github.com/datacite/bolognese/tree/1.9.12) (2021-08-19)
42
69
 
@@ -52,6 +79,7 @@
52
79
 
53
80
  **Merged pull requests:**
54
81
 
82
+ - 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))
55
83
  - Allow Orcid URLs to have been issued from the sandbox [\#121](https://github.com/datacite/bolognese/pull/121) ([prdanelli](https://github.com/prdanelli))
56
84
 
57
85
  ## [1.9.10](https://github.com/datacite/bolognese/tree/1.9.10) (2021-07-20)
@@ -87,6 +115,7 @@
87
115
 
88
116
  **Merged pull requests:**
89
117
 
118
+ - mapping for DFG-to-OECD [\#125](https://github.com/datacite/bolognese/pull/125) ([kjgarza](https://github.com/kjgarza))
90
119
  - Fix missing affiliation identifier [\#117](https://github.com/datacite/bolognese/pull/117) ([richardhallett](https://github.com/richardhallett))
91
120
  - Add support for book title and additional metadata when reading Crossref Book Chapter DOI [\#115](https://github.com/datacite/bolognese/pull/115) ([prdanelli](https://github.com/prdanelli))
92
121
  - Valid Funder DOIs are being rejected for not starting with a 5 [\#114](https://github.com/datacite/bolognese/pull/114) ([prdanelli](https://github.com/prdanelli))
@@ -1360,15 +1389,15 @@
1360
1389
 
1361
1390
  ## [v.0.9.70](https://github.com/datacite/bolognese/tree/v.0.9.70) (2018-01-12)
1362
1391
 
1363
- [Full Changelog](https://github.com/datacite/bolognese/compare/v.0.6.69...v.0.9.70)
1392
+ [Full Changelog](https://github.com/datacite/bolognese/compare/v.0.9.69...v.0.9.70)
1364
1393
 
1365
- ## [v.0.6.69](https://github.com/datacite/bolognese/tree/v.0.6.69) (2018-01-11)
1394
+ ## [v.0.9.69](https://github.com/datacite/bolognese/tree/v.0.9.69) (2018-01-11)
1366
1395
 
1367
- [Full Changelog](https://github.com/datacite/bolognese/compare/v.0.9.69...v.0.6.69)
1396
+ [Full Changelog](https://github.com/datacite/bolognese/compare/v.0.6.69...v.0.9.69)
1368
1397
 
1369
- ## [v.0.9.69](https://github.com/datacite/bolognese/tree/v.0.9.69) (2018-01-11)
1398
+ ## [v.0.6.69](https://github.com/datacite/bolognese/tree/v.0.6.69) (2018-01-11)
1370
1399
 
1371
- [Full Changelog](https://github.com/datacite/bolognese/compare/v.0.9.68...v.0.9.69)
1400
+ [Full Changelog](https://github.com/datacite/bolognese/compare/v.0.9.68...v.0.6.69)
1372
1401
 
1373
1402
  ## [v.0.9.68](https://github.com/datacite/bolognese/tree/v.0.9.68) (2018-01-11)
1374
1403
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bolognese (1.9.17)
4
+ bolognese (1.10.0)
5
5
  activesupport (>= 4.2.5)
6
6
  benchmark_methods (~> 0.7)
7
7
  bibtex-ruby (>= 5.1.0)
@@ -30,7 +30,7 @@ PATH
30
30
  GEM
31
31
  remote: https://rubygems.org/
32
32
  specs:
33
- activesupport (6.1.6)
33
+ activesupport (6.1.7)
34
34
  concurrent-ruby (~> 1.0, >= 1.0.2)
35
35
  i18n (>= 1.6, < 2)
36
36
  minitest (>= 5.1)
@@ -67,7 +67,7 @@ GEM
67
67
  scanf (~> 1.0)
68
68
  sxp (~> 1.2)
69
69
  unicode-types (~> 1.7)
70
- edtf (3.0.8)
70
+ edtf (3.1.0)
71
71
  activesupport (>= 3.0, < 8.0)
72
72
  excon (0.71.1)
73
73
  faraday (0.17.5)
@@ -83,27 +83,27 @@ GEM
83
83
  tilt
84
84
  hashdiff (1.0.1)
85
85
  htmlentities (4.3.4)
86
- i18n (1.10.0)
86
+ i18n (1.12.0)
87
87
  concurrent-ruby (~> 1.0)
88
88
  iso8601 (0.9.1)
89
89
  json (2.6.2)
90
90
  json-canonicalization (0.3.0)
91
- json-ld (3.2.1)
91
+ json-ld (3.2.3)
92
92
  htmlentities (~> 4.3)
93
93
  json-canonicalization (~> 0.3)
94
94
  link_header (~> 0.0, >= 0.0.8)
95
95
  multi_json (~> 1.15)
96
96
  rack (~> 2.2)
97
- rdf (~> 3.2)
98
- json-ld-preloaded (3.2.0)
97
+ rdf (~> 3.2, >= 3.2.9)
98
+ json-ld-preloaded (3.2.1)
99
99
  json-ld (~> 3.2)
100
100
  rdf (~> 3.2)
101
101
  jsonlint (0.3.0)
102
102
  oj (~> 3)
103
103
  optimist (~> 3)
104
- latex-decode (0.3.2)
104
+ latex-decode (0.4.0)
105
105
  link_header (0.0.8)
106
- loofah (2.18.0)
106
+ loofah (2.19.0)
107
107
  crass (~> 1.0.2)
108
108
  nokogiri (>= 1.5.9)
109
109
  maremma (4.9.8)
@@ -119,14 +119,14 @@ GEM
119
119
  oj_mimic_json (~> 1.0, >= 1.0.1)
120
120
  matrix (0.4.2)
121
121
  mini_portile2 (2.8.0)
122
- minitest (5.16.2)
122
+ minitest (5.16.3)
123
123
  multi_json (1.15.0)
124
124
  multipart-post (2.2.3)
125
125
  namae (1.1.1)
126
126
  nokogiri (1.13.6)
127
127
  mini_portile2 (~> 2.8.0)
128
128
  racc (~> 1.4)
129
- oj (3.13.15)
129
+ oj (3.13.21)
130
130
  oj_mimic_json (1.0.1)
131
131
  optimist (3.0.1)
132
132
  postrank-uri (1.0.24)
@@ -139,7 +139,7 @@ GEM
139
139
  rack-test (0.8.3)
140
140
  rack (>= 1.0, < 3)
141
141
  rake (12.3.3)
142
- rdf (3.2.8)
142
+ rdf (3.2.9)
143
143
  link_header (~> 0.0, >= 0.0.8)
144
144
  rdf-aggregate-repo (3.2.1)
145
145
  rdf (~> 3.2)
@@ -158,7 +158,7 @@ GEM
158
158
  rdf-turtle (3.2.1)
159
159
  ebnf (~> 2.3)
160
160
  rdf (~> 3.2)
161
- rdf-vocab (3.2.1)
161
+ rdf-vocab (3.2.2)
162
162
  rdf (~> 3.2, >= 3.2.4)
163
163
  rdf-xsd (3.2.1)
164
164
  rdf (~> 3.2)
@@ -191,17 +191,17 @@ GEM
191
191
  rdf (~> 3.2)
192
192
  temple (0.8.2)
193
193
  thor (1.2.1)
194
- tilt (2.0.10)
195
- tzinfo (2.0.4)
194
+ tilt (2.0.11)
195
+ tzinfo (2.0.5)
196
196
  concurrent-ruby (~> 1.0)
197
- unicode-types (1.7.0)
197
+ unicode-types (1.8.0)
198
198
  unicode_utils (1.4.0)
199
199
  vcr (3.0.3)
200
200
  webmock (3.14.0)
201
201
  addressable (>= 2.8.0)
202
202
  crack (>= 0.3.2)
203
203
  hashdiff (>= 0.4.0, < 2.0.0)
204
- zeitwerk (2.6.0)
204
+ zeitwerk (2.6.1)
205
205
 
206
206
  PLATFORMS
207
207
  ruby
@@ -219,4 +219,4 @@ DEPENDENCIES
219
219
  webmock (~> 3.0, >= 3.0.1)
220
220
 
221
221
  BUNDLED WITH
222
- 2.3.17
222
+ 2.3.12
data/bolognese.gemspec CHANGED
@@ -13,7 +13,7 @@ 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 = '~> 2.3'
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'
@@ -35,15 +35,15 @@ module Bolognese
35
35
  "nameIdentifier" => normalize_orcid(ni["__content__"]),
36
36
  "schemeUri" => "https://orcid.org",
37
37
  "nameIdentifierScheme" => "ORCID" }.compact
38
- elsif ni["schemeURI"].present?
38
+ elsif ni["nameIdentifierScheme"] == "ROR"
39
39
  {
40
- "nameIdentifier" => ni["schemeURI"].to_s + ni["__content__"].to_s,
41
- "schemeUri" => ni["schemeURI"].to_s,
42
- "nameIdentifierScheme" => ni["nameIdentifierScheme"] }.compact
40
+ "nameIdentifier" => normalize_ror(ni["__content__"]),
41
+ "schemeUri" => "https://ror.org",
42
+ "nameIdentifierScheme" => "ROR" }.compact
43
43
  else
44
44
  {
45
45
  "nameIdentifier" => ni["__content__"],
46
- "schemeUri" => nil,
46
+ "schemeUri" => ni.fetch("schemeURI", nil),
47
47
  "nameIdentifierScheme" => ni["nameIdentifierScheme"] }.compact
48
48
  end
49
49
  end.presence
@@ -222,19 +222,23 @@ module Bolognese
222
222
 
223
223
  xml.relatedItem(related_item["relatedItem"], attributes) do
224
224
 
225
- xml.relatedItemIdentifier(related_item["relatedItemIdentifier"]['relatedItemIdentifier'],
226
- {
227
- 'relatedItemIdentifierType' => related_item["relatedItemIdentifier"]["relatedItemIdentifierType"],
228
- 'relatedMetadataScheme' => related_item["relatedItemIdentifier"]["relatedMetadataScheme"],
229
- 'schemeURI' => related_item["relatedItemIdentifier"]["schemeURI"],
230
- 'schemeType' => related_item["relatedItemIdentifier"]["schemeType"],
231
- }.compact
232
- )
233
-
234
- xml.creators do
235
- Array.wrap(related_item['creators']).each do |au|
236
- xml.creator do
237
- insert_person(xml, au, "creator")
225
+ if related_item["relatedItemIdentifier"].present?
226
+ xml.relatedItemIdentifier(related_item["relatedItemIdentifier"]['relatedItemIdentifier'],
227
+ {
228
+ 'relatedItemIdentifierType' => related_item["relatedItemIdentifier"]["relatedItemIdentifierType"],
229
+ 'relatedMetadataScheme' => related_item["relatedItemIdentifier"]["relatedMetadataScheme"],
230
+ 'schemeURI' => related_item["relatedItemIdentifier"]["schemeURI"],
231
+ 'schemeType' => related_item["relatedItemIdentifier"]["schemeType"],
232
+ }.compact
233
+ )
234
+ end
235
+
236
+ if related_item["creators"].present?
237
+ xml.creators do
238
+ Array.wrap(related_item['creators']).each do |au|
239
+ xml.creator do
240
+ insert_person(xml, au, "creator")
241
+ end
238
242
  end
239
243
  end
240
244
  end
@@ -253,19 +257,21 @@ module Bolognese
253
257
  end
254
258
  end
255
259
 
256
- xml.publicationYear(related_item['publicationYear'])
257
- xml.volume(related_item['volume'])
258
- xml.issue(related_item['issue'])
259
- xml.number(related_item['number'], {'numberType' => related_item['numberType']}.compact)
260
- xml.firstPage(related_item['firstPage'])
261
- xml.lastPage(related_item['lastPage'])
262
- xml.publisher(related_item['publisher'])
263
- xml.edition(related_item['edition'])
264
-
265
- xml.contributors do
266
- Array.wrap(related_item["contributors"]).each do |con|
267
- xml.contributor("contributorType" => con["contributorType"] || "Other") do
268
- insert_person(xml, con, "contributor")
260
+ xml.publicationYear(related_item['publicationYear']) if related_item["publicationYear"].present?
261
+ xml.volume(related_item['volume']) if related_item["volume"].present?
262
+ xml.issue(related_item['issue']) if related_item["issue"].present?
263
+ xml.number(related_item['number'], {'numberType' => related_item['numberType']}.compact) if related_item["number"].present?
264
+ xml.firstPage(related_item['firstPage']) if related_item["firstPage"].present?
265
+ xml.lastPage(related_item['lastPage']) if related_item["lastPage"].present?
266
+ xml.publisher(related_item['publisher']) if related_item["publisher"].present?
267
+ xml.edition(related_item['edition']) if related_item["edition"].present?
268
+
269
+ if related_item["contributors"].present?
270
+ xml.contributors do
271
+ Array.wrap(related_item["contributors"]).each do |con|
272
+ xml.contributor("contributorType" => con["contributorType"] || "Other") do
273
+ insert_person(xml, con, "contributor")
274
+ end
269
275
  end
270
276
  end
271
277
  end
@@ -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
@@ -157,14 +157,21 @@ module Bolognese
157
157
  scheme_uri = parse_attributes(fr["funderIdentifier"], content: "schemeURI")
158
158
  funder_identifier = parse_attributes(fr["funderIdentifier"])
159
159
  funder_identifier_type = parse_attributes(fr["funderIdentifier"], content: "funderIdentifierType")
160
- if funder_identifier_type != "Other"
161
- funder_identifier = !funder_identifier.to_s.start_with?("https://","http://") && scheme_uri.present? ? normalize_id(scheme_uri + funder_identifier) : normalize_id(funder_identifier)
160
+
161
+ if funder_identifier_type == "Crossref Funder ID"
162
+ funder_identifier = validate_funder_doi(funder_identifier)
163
+ elsif funder_identifier_type == "ROR"
164
+ funder_identifier = normalize_ror(funder_identifier)
165
+ scheme_uri = "https://ror.org"
166
+ else
167
+ funder_identifier = normalize_id(funder_identifier) ? normalize_id(funder_identifier) : funder_identifier
162
168
  end
163
169
 
164
170
  {
165
171
  "funderName" => fr["funderName"],
166
172
  "funderIdentifier" => funder_identifier,
167
173
  "funderIdentifierType" => funder_identifier_type,
174
+ "schemeUri" => scheme_uri,
168
175
  "awardNumber" => parse_attributes(fr["awardNumber"]),
169
176
  "awardUri" => parse_attributes(fr["awardNumber"], content: "awardURI"),
170
177
  "awardTitle" => fr["awardTitle"] }.compact
@@ -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)
@@ -578,6 +604,10 @@ module Bolognese
578
604
  orcid.gsub(/[[:space:]]/, "-") if orcid.present?
579
605
  end
580
606
 
607
+ def validate_ror(ror)
608
+ Array(/^(?:(?:(?:http|https):\/\/)?ror\.org\/)?(0\w{6}\d{2})$/.match(ror)).last
609
+ end
610
+
581
611
  def validate_orcid_scheme(orcid_scheme)
582
612
  Array(/\A(http|https):\/\/(www\.)?(orcid\.org)/.match(orcid_scheme)).last
583
613
  end
@@ -611,7 +641,7 @@ module Bolognese
611
641
  return nil unless id.present?
612
642
 
613
643
  # check for valid DOI
614
- doi = normalize_doi(id, options)
644
+ doi = DoiUtils::normalize_doi(id, options)
615
645
  return doi if doi.present?
616
646
 
617
647
  # check for valid HTTP uri
@@ -659,11 +689,19 @@ module Bolognese
659
689
  "https://orcid.org/" + Addressable::URI.encode(orcid)
660
690
  end
661
691
 
692
+ def normalize_ror(ror)
693
+ ror = validate_ror(ror)
694
+ return nil unless ror.present?
695
+
696
+ # turn ROR into URL
697
+ "https://ror.org/" + Addressable::URI.encode(ror)
698
+ end
699
+
662
700
  def normalize_ids(ids: nil, relation_type: nil)
663
701
  Array.wrap(ids).select { |idx| idx["@id"].present? }.map do |idx|
664
702
  id = normalize_id(idx["@id"])
665
- related_identifier_type = doi_from_url(id).present? ? "DOI" : "URL"
666
- 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
667
705
 
668
706
  { "relatedIdentifier" => id,
669
707
  "relationType" => relation_type,
@@ -1221,7 +1259,7 @@ module Bolognese
1221
1259
  end
1222
1260
 
1223
1261
  def name_to_spdx(name)
1224
- spdx = JSON.load(File.read(File.expand_path('../../../resources/spdx/licenses.json', __FILE__))).fetch("licenses")
1262
+ spdx = resource_json(:spdx).fetch("licenses")
1225
1263
  license = spdx.find { |l| l["name"] == name || l["licenseId"] == name || l["seeAlso"].first == normalize_cc_url(name) }
1226
1264
 
1227
1265
  if license
@@ -1237,7 +1275,7 @@ module Bolognese
1237
1275
  end
1238
1276
 
1239
1277
  def hsh_to_spdx(hsh)
1240
- spdx = JSON.load(File.read(File.expand_path('../../../resources/spdx/licenses.json', __FILE__))).fetch("licenses")
1278
+ spdx = resource_json(:spdx).fetch("licenses")
1241
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"]) }
1242
1280
 
1243
1281
  if license
@@ -1261,7 +1299,7 @@ module Bolognese
1261
1299
 
1262
1300
  def name_to_fos(name)
1263
1301
  # first find subject in Fields of Science (OECD)
1264
- fos = JSON.load(File.read(File.expand_path('../../../resources/oecd/fos-mappings.json', __FILE__))).fetch("fosFields")
1302
+ fos = resource_json(:fos).fetch("fosFields")
1265
1303
 
1266
1304
  subject = fos.find { |l| l["fosLabel"] == name || "FOS: " + l["fosLabel"] == name }
1267
1305
 
@@ -1277,7 +1315,7 @@ module Bolognese
1277
1315
 
1278
1316
  # if not found, look in Fields of Research (Australian and New Zealand Standard Research Classification)
1279
1317
  # and map to Fields of Science. Add an extra entry for the latter
1280
- fores = JSON.load(File.read(File.expand_path('../../../resources/oecd/for-mappings.json', __FILE__)))
1318
+ fores = resource_json(:for)
1281
1319
  for_fields = fores.fetch("forFields")
1282
1320
  for_disciplines = fores.fetch("forDisciplines")
1283
1321
 
@@ -1299,7 +1337,7 @@ module Bolognese
1299
1337
 
1300
1338
  def hsh_to_fos(hsh)
1301
1339
  # first find subject in Fields of Science (OECD)
1302
- fos = JSON.load(File.read(File.expand_path('../../../resources/oecd/fos-mappings.json', __FILE__))).fetch("fosFields")
1340
+ fos = resource_json(:fos).fetch("fosFields")
1303
1341
  subject = fos.find { |l| l["fosLabel"] == hsh["__content__"] || "FOS: " + l["fosLabel"] == hsh["__content__"] || l["fosLabel"] == hsh["subject"]}
1304
1342
 
1305
1343
  if subject
@@ -1318,7 +1356,7 @@ module Bolognese
1318
1356
 
1319
1357
  # if not found, look in Fields of Research (Australian and New Zealand Standard Research Classification)
1320
1358
  # and map to Fields of Science. Add an extra entry for the latter
1321
- fores = JSON.load(File.read(File.expand_path('../../../resources/oecd/for-mappings.json', __FILE__)))
1359
+ fores = resource_json(:for)
1322
1360
  for_fields = fores.fetch("forFields")
1323
1361
  for_disciplines = fores.fetch("forDisciplines")
1324
1362
 
@@ -1357,5 +1395,20 @@ module Bolognese
1357
1395
  "lang" => hsh["lang"] }.compact]
1358
1396
  end
1359
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
1360
1413
  end
1361
1414
  end
@@ -1,3 +1,3 @@
1
1
  module Bolognese
2
- VERSION = "1.9.17"
2
+ VERSION = "1.10.0"
3
3
  end