bolognese 1.9.2 → 1.9.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06d651b8877944fead2a1d1ba18ec5847ea327a4c835ace217dffe544e9f04e1
4
- data.tar.gz: 4c7af71d22ae44861acac86d234deb81561ed83327e6e39adebac01af44ab21d
3
+ metadata.gz: a01fe4851a13d779fd983f0fd3dc3c3e14a9374ddee6f9802f305e11c802156e
4
+ data.tar.gz: 49d2105471c6bc0270c5e6c326f4564503668537a7ffc26a241293ca2f0ae877
5
5
  SHA512:
6
- metadata.gz: bd4d06c35507d50add44947a5c26e66ecdd8f593c2e984b772add2126bf42a162d6861ff2af027b4fbe0d78c7ddf1b17693a8f5f47d217bc86aca498efcdd96b
7
- data.tar.gz: bd81ea7482839d1c87afa18b64ba08f85e237faca63a4bda1ec827cc44a261a601fa20610d0806cc758011265dd92d2ffb43ca040a9c26f89a5a21825de52a54
6
+ metadata.gz: 6e6d56a5bb01f18d4bc5812520828d73c19ec9f52f5a3650d31ba9c58f7a19715b59161c8f4bfdfe1cdaf565a94bfc9963b928a1587d86c4cd17ee0579f9b77a
7
+ data.tar.gz: 0ca356314c8b16aadb0e9d0f30ebc21e77ee13baf2e73d90a9b8437e83201fa56f3091d6df802824bde0e3b900cc3aa09166caac75c6131378dccc48551de3b1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,51 @@
1
1
  # Changelog
2
2
 
3
+ ## [Unreleased](https://github.com/datacite/bolognese/tree/HEAD)
4
+
5
+ [Full Changelog](https://github.com/datacite/bolognese/compare/1.9.5...HEAD)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Missing affiliationIdentiifer when used with schemaURI raises an error [\#116](https://github.com/datacite/bolognese/issues/116)
10
+ - Optional numberType being treated as required generating error [\#112](https://github.com/datacite/bolognese/issues/112)
11
+
12
+ **Closed issues:**
13
+
14
+ - Book metadata seems to be ignored [\#113](https://github.com/datacite/bolognese/issues/113)
15
+ - Namespaced XML Tags [\#109](https://github.com/datacite/bolognese/issues/109)
16
+
17
+ **Merged pull requests:**
18
+
19
+ - Fix missing affiliation identifier [\#117](https://github.com/datacite/bolognese/pull/117) ([richardhallett](https://github.com/richardhallett))
20
+
21
+ ## [1.9.5](https://github.com/datacite/bolognese/tree/1.9.5) (2021-04-20)
22
+
23
+ [Full Changelog](https://github.com/datacite/bolognese/compare/1.9.4...1.9.5)
24
+
25
+ ## [1.9.4](https://github.com/datacite/bolognese/tree/1.9.4) (2021-04-13)
26
+
27
+ [Full Changelog](https://github.com/datacite/bolognese/compare/1.9.3...1.9.4)
28
+
29
+ **Implemented enhancements:**
30
+
31
+ - Should we resolve the Namespace URL for schema [\#62](https://github.com/datacite/bolognese/issues/62)
32
+
33
+ **Fixed bugs:**
34
+
35
+ - Singular geoLocationPolygons are wrapped in additional array [\#110](https://github.com/datacite/bolognese/issues/110)
36
+
37
+ **Merged pull requests:**
38
+
39
+ - Support returning single geoLocationPolygon [\#111](https://github.com/datacite/bolognese/pull/111) ([richardhallett](https://github.com/richardhallett))
40
+
41
+ ## [1.9.3](https://github.com/datacite/bolognese/tree/1.9.3) (2021-03-26)
42
+
43
+ [Full Changelog](https://github.com/datacite/bolognese/compare/1.9.2...1.9.3)
44
+
45
+ ## [1.9.2](https://github.com/datacite/bolognese/tree/1.9.2) (2021-03-25)
46
+
47
+ [Full Changelog](https://github.com/datacite/bolognese/compare/1.9.1...1.9.2)
48
+
3
49
  ## [1.9.1](https://github.com/datacite/bolognese/tree/1.9.1) (2021-03-25)
4
50
 
5
51
  [Full Changelog](https://github.com/datacite/bolognese/compare/1.9...1.9.1)
@@ -973,14 +1019,14 @@
973
1019
 
974
1020
  [Full Changelog](https://github.com/datacite/bolognese/compare/v.0.11.15...v.0.11.16)
975
1021
 
976
- ## [v.0.11.15](https://github.com/datacite/bolognese/tree/v.0.11.15) (2018-08-01)
977
-
978
- [Full Changelog](https://github.com/datacite/bolognese/compare/v.0.11.14...v.0.11.15)
979
-
980
1022
  **Fixed bugs:**
981
1023
 
982
1024
  - Handle xs:string attribute [\#32](https://github.com/datacite/bolognese/issues/32)
983
1025
 
1026
+ ## [v.0.11.15](https://github.com/datacite/bolognese/tree/v.0.11.15) (2018-08-01)
1027
+
1028
+ [Full Changelog](https://github.com/datacite/bolognese/compare/v.0.11.14...v.0.11.15)
1029
+
984
1030
  ## [v.0.11.14](https://github.com/datacite/bolognese/tree/v.0.11.14) (2018-07-28)
985
1031
 
986
1032
  [Full Changelog](https://github.com/datacite/bolognese/compare/v.0.11.3...v.0.11.14)
@@ -1462,8 +1508,10 @@
1462
1508
  **Closed issues:**
1463
1509
 
1464
1510
  - Fix error handling alternate names in ris writer [\#14](https://github.com/datacite/bolognese/issues/14)
1511
+ - Error displaying container-title [\#13](https://github.com/datacite/bolognese/issues/13)
1465
1512
  - Error parsing funding information [\#12](https://github.com/datacite/bolognese/issues/12)
1466
1513
  - crossref author id to orcid id? [\#10](https://github.com/datacite/bolognese/issues/10)
1514
+ - Support funding information [\#7](https://github.com/datacite/bolognese/issues/7)
1467
1515
  - datacite: support subjectScheme and subjectURI [\#4](https://github.com/datacite/bolognese/issues/4)
1468
1516
 
1469
1517
  ## [v.0.9.21](https://github.com/datacite/bolognese/tree/v.0.9.21) (2017-06-03)
@@ -1472,10 +1520,8 @@
1472
1520
 
1473
1521
  **Closed issues:**
1474
1522
 
1475
- - Error displaying container-title [\#13](https://github.com/datacite/bolognese/issues/13)
1476
1523
  - Abstract should be a string in Citeproc writer [\#11](https://github.com/datacite/bolognese/issues/11)
1477
1524
  - the Bolognese gem doesn't properly handle the optional language attribute. [\#8](https://github.com/datacite/bolognese/issues/8)
1478
- - Support funding information [\#7](https://github.com/datacite/bolognese/issues/7)
1479
1525
  - datacite: support xml:lang in title [\#3](https://github.com/datacite/bolognese/issues/3)
1480
1526
 
1481
1527
  ## [v.0.9.20](https://github.com/datacite/bolognese/tree/v.0.9.20) (2017-05-13)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bolognese (1.9.2)
4
+ bolognese (1.9.7)
5
5
  activesupport (>= 4.2.5)
6
6
  benchmark_methods (~> 0.7)
7
7
  bibtex-ruby (>= 5.1.0)
@@ -19,7 +19,7 @@ PATH
19
19
  loofah (~> 2.0, >= 2.0.3)
20
20
  maremma (>= 4.7, < 5)
21
21
  namae (~> 1.0)
22
- nokogiri (~> 1.10.4)
22
+ nokogiri (~> 1.11.2)
23
23
  oj (~> 3.10)
24
24
  oj_mimic_json (~> 1.0, >= 1.0.1)
25
25
  postrank-uri (~> 1.0, >= 1.0.18)
@@ -30,7 +30,7 @@ PATH
30
30
  GEM
31
31
  remote: https://rubygems.org/
32
32
  specs:
33
- activesupport (6.1.3)
33
+ activesupport (6.1.3.2)
34
34
  concurrent-ruby (~> 1.0, >= 1.0.2)
35
35
  i18n (>= 1.6, < 2)
36
36
  minitest (>= 5.1)
@@ -38,6 +38,7 @@ GEM
38
38
  zeitwerk (~> 2.3)
39
39
  addressable (2.7.0)
40
40
  public_suffix (>= 2.0.2, < 5.0)
41
+ amazing_print (1.3.0)
41
42
  benchmark_methods (0.7)
42
43
  bibtex-ruby (6.0.0)
43
44
  latex-decode (~> 0.0)
@@ -54,15 +55,17 @@ GEM
54
55
  crass (1.0.6)
55
56
  csl (1.5.2)
56
57
  namae (~> 1.0)
57
- csl-styles (1.0.1.10)
58
+ csl-styles (1.0.1.11)
58
59
  csl (~> 1.0)
59
60
  diff-lcs (1.4.4)
60
61
  docile (1.3.5)
61
- ebnf (2.1.2)
62
+ ebnf (2.1.3)
63
+ amazing_print (~> 1.2)
62
64
  htmlentities (~> 4.3)
63
65
  rdf (~> 3.1)
64
66
  scanf (~> 1.0)
65
67
  sxp (~> 1.1)
68
+ unicode-types (~> 1.6)
66
69
  edtf (3.0.6)
67
70
  activesupport (>= 3.0, < 7.0)
68
71
  excon (0.71.1)
@@ -81,7 +84,7 @@ GEM
81
84
  concurrent-ruby (~> 1.0)
82
85
  hashdiff (1.0.1)
83
86
  htmlentities (4.3.4)
84
- i18n (1.8.9)
87
+ i18n (1.8.10)
85
88
  concurrent-ruby (~> 1.0)
86
89
  iso8601 (0.9.1)
87
90
  json (2.5.1)
@@ -101,10 +104,10 @@ GEM
101
104
  optimist (~> 3)
102
105
  latex-decode (0.3.2)
103
106
  link_header (0.0.8)
104
- loofah (2.9.0)
107
+ loofah (2.9.1)
105
108
  crass (~> 1.0.2)
106
109
  nokogiri (>= 1.5.9)
107
- maremma (4.7.2)
110
+ maremma (4.7.4)
108
111
  activesupport (>= 4.2.5)
109
112
  addressable (>= 2.3.6)
110
113
  builder (~> 3.2, >= 3.2.2)
@@ -112,17 +115,18 @@ GEM
112
115
  faraday (~> 0.17.3)
113
116
  faraday-encoding (~> 0.0.4)
114
117
  faraday_middleware (~> 0.14.0)
115
- nokogiri (~> 1.10.4)
118
+ nokogiri (~> 1.11.2)
116
119
  oj (>= 2.8.3)
117
120
  oj_mimic_json (~> 1.0, >= 1.0.1)
118
- mini_portile2 (2.4.0)
121
+ mini_portile2 (2.5.0)
119
122
  minitest (5.14.4)
120
123
  multi_json (1.15.0)
121
124
  multipart-post (2.1.1)
122
125
  namae (1.1.1)
123
- nokogiri (1.10.10)
124
- mini_portile2 (~> 2.4.0)
125
- oj (3.11.3)
126
+ nokogiri (1.11.2)
127
+ mini_portile2 (~> 2.5.0)
128
+ racc (~> 1.4)
129
+ oj (3.11.5)
126
130
  oj_mimic_json (1.0.1)
127
131
  optimist (3.0.1)
128
132
  postrank-uri (1.0.24)
@@ -130,6 +134,7 @@ GEM
130
134
  nokogiri (>= 1.8.0)
131
135
  public_suffix (>= 2.0.0, < 2.1)
132
136
  public_suffix (2.0.5)
137
+ racc (1.5.2)
133
138
  rack (2.2.3)
134
139
  rack-test (0.8.3)
135
140
  rack (>= 1.0, < 3)
@@ -154,7 +159,7 @@ GEM
154
159
  rdf-turtle (3.1.3)
155
160
  ebnf (~> 2.1)
156
161
  rdf (~> 3.1, >= 3.1.8)
157
- rdf-vocab (3.1.12)
162
+ rdf-vocab (3.1.13)
158
163
  rdf (~> 3.1, >= 3.1.12)
159
164
  rdf-xsd (3.1.1)
160
165
  rdf (~> 3.1)
@@ -189,6 +194,7 @@ GEM
189
194
  tilt (2.0.10)
190
195
  tzinfo (2.0.4)
191
196
  concurrent-ruby (~> 1.0)
197
+ unicode-types (1.6.0)
192
198
  unicode_utils (1.4.0)
193
199
  vcr (3.0.3)
194
200
  webmock (3.12.1)
@@ -213,4 +219,4 @@ DEPENDENCIES
213
219
  webmock (~> 3.0, >= 3.0.1)
214
220
 
215
221
  BUNDLED WITH
216
- 2.2.15
222
+ 2.2.18
data/bolognese.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  # Declare dependencies here, rather than in the Gemfile
19
19
  s.add_dependency 'maremma', '>= 4.7', '< 5'
20
20
  s.add_dependency 'faraday', '~> 0.17.3'
21
- s.add_dependency 'nokogiri', '~> 1.10.4'
21
+ s.add_dependency 'nokogiri', '~> 1.11.2'
22
22
  s.add_dependency 'loofah', '~> 2.0', '>= 2.0.3'
23
23
  s.add_dependency 'builder', '~> 3.2', '>= 3.2.2'
24
24
  s.add_dependency 'activesupport', '>= 4.2.5'
@@ -138,14 +138,19 @@ module Bolognese
138
138
 
139
139
  def get_affiliations(affiliations)
140
140
  Array.wrap(affiliations).map do |a|
141
+ affiliation_identifier = nil
141
142
  if a.is_a?(String)
142
143
  name = a.squish
143
- affiliation_identifier = nil
144
144
  affiliation_identifier_scheme = nil
145
145
  scheme_uri = nil
146
146
  else
147
- affiliation_identifier = a["affiliationIdentifier"]
148
- affiliation_identifier = !affiliation_identifier.to_s.start_with?("https://") && a["schemeURI"].present? ? normalize_id(a["schemeURI"] + affiliation_identifier) : normalize_id(affiliation_identifier)
147
+ if a["affiliationIdentifier"].present?
148
+ affiliation_identifier = a["affiliationIdentifier"]
149
+ if a["schemeURI"].present?
150
+ schemeURI = a["schemeURI"].end_with?("/") ? a["schemeURI"] : a["schemeURI"] + "/"
151
+ end
152
+ affiliation_identifier = !affiliation_identifier.to_s.start_with?("https://") && schemeURI.present? ? normalize_id(schemeURI + affiliation_identifier) : normalize_id(affiliation_identifier)
153
+ end
149
154
  name = a["__content__"].to_s.squish.presence
150
155
  affiliation_identifier_scheme = a["affiliationIdentifierScheme"]
151
156
  scheme_uri = a["SchemeURI"]
@@ -9,10 +9,11 @@ module Bolognese
9
9
  end
10
10
 
11
11
  def validate_funder_doi(doi)
12
- doi = Array(/\A(?:(http|https):\/(\/)?(dx\.)?(doi.org|handle.test.datacite.org)\/)?(doi:)?(10\.13039\/)?(5.+)\z/.match(doi)).last
12
+ doi = Array(/\A(?:(http|https):\/(\/)?(dx\.)?(doi.org|handle.test.datacite.org)\/)?(doi:)?(10\.13039\/)?([1-9]\d+)\z/.match(doi)).last
13
+
13
14
  # remove non-printing whitespace and downcase
14
15
  if doi.present?
15
- doi.delete("\u200B").downcase
16
+ doi.delete("\u200B").downcase
16
17
  "https://doi.org/10.13039/#{doi}"
17
18
  end
18
19
  end
@@ -56,10 +56,10 @@ module Bolognese
56
56
  # book_series_metadata.dig("publisher", "publisher_name")
57
57
  # end
58
58
  when "conference"
59
- event_metadata = meta.dig("crossref", "conference", "event_metadata") || {}
59
+ event_metadata = meta.dig("crossref", "conference", "event_metadata") || {}
60
60
  bibliographic_metadata = meta.dig("crossref", "conference", "conference_paper").to_h
61
61
  when "journal"
62
- journal_metadata = meta.dig("crossref", "journal", "journal_metadata") || {}
62
+ journal_metadata = meta.dig("crossref", "journal", "journal_metadata") || {}
63
63
  journal_issue = meta.dig("crossref", "journal", "journal_issue") || {}
64
64
  journal_article = meta.dig("crossref", "journal", "journal_article") || {}
65
65
  bibliographic_metadata = journal_article.presence || journal_issue.presence || journal_metadata
@@ -140,7 +140,8 @@ module Bolognese
140
140
  state = meta.present? || read_options.present? ? "findable" : "not_found"
141
141
 
142
142
  related_identifiers = Array.wrap(crossref_is_part_of(journal_metadata)) + Array.wrap(crossref_references(bibliographic_metadata))
143
- container = if journal_metadata.present? || book_metadata.present?
143
+
144
+ container = if journal_metadata.present?
144
145
  issn = normalize_issn(journal_metadata.to_h.fetch("issn", nil))
145
146
 
146
147
  { "type" => "Journal",
@@ -151,6 +152,19 @@ module Bolognese
151
152
  "issue" => parse_attributes(journal_issue.dig("issue")),
152
153
  "firstPage" => bibliographic_metadata.dig("pages", "first_page") || parse_attributes(journal_article.to_h.dig("publisher_item", "item_number"), first: true),
153
154
  "lastPage" => bibliographic_metadata.dig("pages", "last_page") }.compact
155
+
156
+ # By using book_metadata, we can account for where resource_type is `BookChapter` and not assume its a whole book
157
+ elsif book_metadata.present?
158
+ identifiers = crossref_alternate_identifiers(book_metadata)
159
+
160
+ {
161
+ "type" => "Book",
162
+ "title" => book_metadata.dig("titles", "title"),
163
+ "firstPage" => bibliographic_metadata.dig("pages", "first_page"),
164
+ "lastPage" => bibliographic_metadata.dig("pages", "last_page"),
165
+ "identifiers" => identifiers,
166
+ }.compact
167
+
154
168
  elsif book_series_metadata.to_h.fetch("series_metadata", nil).present?
155
169
  issn = normalize_issn(book_series_metadata.dig("series_metadata", "issn"))
156
170
 
@@ -162,7 +176,10 @@ module Bolognese
162
176
  end
163
177
 
164
178
  id = normalize_doi(options[:doi] || options[:id] || bibliographic_metadata.dig("doi_data", "doi"))
165
- identifiers = crossref_alternate_identifiers(bibliographic_metadata)
179
+
180
+ # Let sections override this in case of alternative metadata structures, such as book chapters, which
181
+ # have their meta inside `content_item`, but the main book indentifers inside of `book_metadata`
182
+ identifiers ||= crossref_alternate_identifiers(bibliographic_metadata)
166
183
 
167
184
  { "id" => id,
168
185
  "types" => types,
@@ -203,6 +203,15 @@ module Bolognese
203
203
  "schemeType" => rii["schemeType"]
204
204
  }.compact
205
205
 
206
+ number = ri["number"]
207
+ if number.is_a?(String)
208
+ number = number
209
+ numberType = nil
210
+ else
211
+ number = ri.dig("number", "__content__")
212
+ numberType = ri.dig("number", "numberType")
213
+ end
214
+
206
215
  {
207
216
  "relationType" => ri["relationType"],
208
217
  "relatedItemType" => ri["relatedItemType"],
@@ -212,8 +221,8 @@ module Bolognese
212
221
  "publicationYear" => ri["publicationYear"],
213
222
  "volume" => ri["volume"],
214
223
  "issue" => ri["issue"],
215
- "number" => ri.dig("number", "__content__"),
216
- "numberType" => ri.dig("number", "numberType"),
224
+ "number" => number,
225
+ "numberType" => numberType,
217
226
  "firstPage" => ri["firstPage"],
218
227
  "lastPage" => ri["lastPage"],
219
228
  "publisher" => ri["publisher"],
@@ -226,6 +235,19 @@ module Bolognese
226
235
  if !gl.is_a?(Hash) || gl["geoLocationPoint"].is_a?(String) || gl["geoLocationBox"].is_a?(String) || gl["geoLocationPolygon"].is_a?(String)
227
236
  nil
228
237
  else
238
+
239
+ # Handle scenario where multiple geoLocationPolygons are allowed within a single geoLocation
240
+ # we want to return an array if it's already an array (i.e. multiple geoLocationPolygons)
241
+ # vs if it's singular just return the object
242
+ # This is for backwards compatability to allow both scenarios.
243
+ if gl.dig("geoLocationPolygon").kind_of?(Array)
244
+ geoLocationPolygon = gl.dig("geoLocationPolygon").map do |glp|
245
+ Array.wrap(glp.dig("polygonPoint")).map { |glpp| { "polygonPoint" => glpp } }.compact.presence
246
+ end.compact.presence
247
+ else
248
+ geoLocationPolygon = Array.wrap(gl.dig("geoLocationPolygon", "polygonPoint")).map { |glp| { "polygonPoint" => glp } }.compact.presence
249
+ end
250
+
229
251
  {
230
252
  "geoLocationPoint" => {
231
253
  "pointLatitude" => gl.dig("geoLocationPoint", "pointLatitude"),
@@ -237,9 +259,7 @@ module Bolognese
237
259
  "southBoundLatitude" => gl.dig("geoLocationBox", "southBoundLatitude"),
238
260
  "northBoundLatitude" => gl.dig("geoLocationBox", "northBoundLatitude")
239
261
  }.compact.presence,
240
- "geoLocationPolygon" => Array.wrap(gl.dig("geoLocationPolygon")).map do |glp|
241
- Array.wrap(glp.dig("polygonPoint")).map { |glpp| { "polygonPoint" => glpp } }.compact.presence
242
- end.compact.presence,
262
+ "geoLocationPolygon" => geoLocationPolygon,
243
263
  "geoLocationPlace" => parse_attributes(gl["geoLocationPlace"], first: true).to_s.strip.presence
244
264
  }.compact
245
265
  end
@@ -1306,8 +1306,8 @@ module Bolognese
1306
1306
  return [{
1307
1307
  "subject" => sanitize(hsh["__content__"] || hsh["subject"]),
1308
1308
  "subjectScheme" => hsh["subjectScheme"],
1309
- "schemeUri" => hsh["schemeURI"],
1310
- "valueUri" => hsh["valueURI"],
1309
+ "schemeUri" => hsh["schemeURI"] || hsh["schemeUri"],
1310
+ "valueUri" => hsh["valueURI"] || hsh["valueUri"],
1311
1311
  "classificationCode" => hsh["classificationCode"],
1312
1312
  "lang" => hsh["lang"] }.compact,
1313
1313
  {
@@ -1339,8 +1339,8 @@ module Bolognese
1339
1339
  "subject" => sanitize(hsh["__content__"] || hsh["subject"]),
1340
1340
  "subjectScheme" => hsh["subjectScheme"],
1341
1341
  "classificationCode" => hsh["classificationCode"],
1342
- "schemeUri" => hsh["schemeURI"],
1343
- "valueUri" => hsh["valueURI"],
1342
+ "schemeUri" => hsh["schemeURI"] || hsh["schemeUri"],
1343
+ "valueUri" => hsh["valueURI"] || hsh["valueUri"],
1344
1344
  "lang" => hsh["lang"] }.compact,
1345
1345
  {
1346
1346
  "subject" => "FOS: " + subject["fosLabel"],
@@ -1352,8 +1352,8 @@ module Bolognese
1352
1352
  "subject" => sanitize(hsh["__content__"] || hsh["subject"]),
1353
1353
  "subjectScheme" => hsh["subjectScheme"],
1354
1354
  "classificationCode" => hsh["classificationCode"],
1355
- "schemeUri" => hsh["schemeURI"],
1356
- "valueUri" => hsh["valueURI"],
1355
+ "schemeUri" => hsh["schemeURI"] || hsh["schemeUri"],
1356
+ "valueUri" => hsh["valueURI"] || hsh["valueUri"],
1357
1357
  "lang" => hsh["lang"] }.compact]
1358
1358
  end
1359
1359
  end
@@ -1,3 +1,3 @@
1
1
  module Bolognese
2
- VERSION = "1.9.2"
2
+ VERSION = "1.9.7"
3
3
  end
@@ -76,7 +76,9 @@ module Bolognese
76
76
  end
77
77
 
78
78
  def insert_source(xml)
79
- if is_article? || is_data? || is_chapter?
79
+ if is_chapter?
80
+ xml.source(publisher)
81
+ elsif is_article? || is_data?
80
82
  xml.source(container && container["title"] || publisher)
81
83
  else
82
84
  xml.source(parse_attributes(titles, content: "title", first: true))
@@ -272,6 +272,18 @@ describe Bolognese::Metadata, vcr: true do
272
272
  response = subject.validate_funder_doi(doi)
273
273
  expect(response).to be_nil
274
274
  end
275
+
276
+ it { expect(subject.validate_funder_doi("10.13039/100000050")).to eq "https://doi.org/10.13039/100000050" }
277
+ it { expect(subject.validate_funder_doi("10.13039/100006492")).to eq "https://doi.org/10.13039/100006492" }
278
+ it { expect(subject.validate_funder_doi('http://handle.test.datacite.org/10.13039/100000080')).to eq "https://doi.org/10.13039/100000080" }
279
+ it { expect(subject.validate_funder_doi('https://doi.org/10.13039/100000001')).to eq "https://doi.org/10.13039/100000001" }
280
+ it { expect(subject.validate_funder_doi('http://doi.org/10.13039/501100001711')).to eq "https://doi.org/10.13039/501100001711" }
281
+ it { expect(subject.validate_funder_doi('https://dx.doi.org/10.13039/501100001711')).to eq "https://doi.org/10.13039/501100001711" }
282
+ it { expect(subject.validate_funder_doi('doi:10.13039/501100001711')).to eq "https://doi.org/10.13039/501100001711" }
283
+ it { expect(subject.validate_funder_doi('10.13039/501100001711')).to eq "https://doi.org/10.13039/501100001711" }
284
+ it { expect(subject.validate_funder_doi('501100001711')).to eq "https://doi.org/10.13039/501100001711" }
285
+ it { expect(subject.validate_funder_doi("https://doi.org/10.13039/5monkeymonkey")).to be_nil }
286
+ it { expect(subject.validate_funder_doi('10.13039/5monkeymonkey')).to be_nil }
275
287
  end
276
288
 
277
289
  context "validate prefix" do
@@ -52,5 +52,25 @@
52
52
  </polygonPoint>
53
53
  </geoLocationPolygon>
54
54
  </geoLocation>
55
+ <geoLocation>
56
+ <geoLocationPolygon>
57
+ <polygonPoint>
58
+ <pointLongitude>65</pointLongitude>
59
+ <pointLatitude>80</pointLatitude>
60
+ </polygonPoint>
61
+ <polygonPoint>
62
+ <pointLongitude>55</pointLongitude>
63
+ <pointLatitude>75</pointLatitude>
64
+ </polygonPoint>
65
+ <polygonPoint>
66
+ <pointLongitude>45</pointLongitude>
67
+ <pointLatitude>73</pointLatitude>
68
+ </polygonPoint>
69
+ <polygonPoint>
70
+ <pointLongitude>65</pointLongitude>
71
+ <pointLatitude>80</pointLatitude>
72
+ </polygonPoint>
73
+ </geoLocationPolygon>
74
+ </geoLocation>
55
75
  </geoLocations>
56
76
  </resource>
@@ -153,7 +153,7 @@ describe Bolognese::Metadata, vcr: true do
153
153
  it "missing_comma" do
154
154
  json = IO.read(fixture_path + "datacite_software_missing_comma.json")
155
155
  response = subject.jsonlint(json)
156
- expect(response).to eq(["expected comma, not a string (after doi) at line 4, column 11 [parse.c:364]"])
156
+ expect(response).to eq(["expected comma, not a string (after doi) at line 4, column 11 [parse.c:388]"])
157
157
  end
158
158
 
159
159
  it "overlapping_keys" do
@@ -372,6 +372,11 @@ describe Bolognese::Metadata, vcr: true do
372
372
  expect(subject.publication_year).to eq("2015")
373
373
  expect(subject.publisher).to eq("Springer Science and Business Media LLC")
374
374
  expect(subject.agency).to eq("crossref")
375
+ expect(subject.container["type"]).to eq("Book")
376
+ expect(subject.container["title"]).to eq("Shoulder Stiffness")
377
+ expect(subject.container["firstPage"]).to eq("155")
378
+ expect(subject.container["lastPage"]).to eq("158")
379
+ expect(subject.container["identifiers"]).to eq([{"identifier"=>"978-3-662-46369-7", "identifierType"=>"ISBN"}])
375
380
  end
376
381
 
377
382
  it "another book chapter" do
@@ -387,6 +392,10 @@ describe Bolognese::Metadata, vcr: true do
387
392
  expect(subject.publication_year).to eq("2018")
388
393
  expect(subject.publisher).to eq("Springer Science and Business Media LLC")
389
394
  expect(subject.agency).to eq("crossref")
395
+ expect(subject.container["type"]).to eq("Book Series")
396
+ expect(subject.container["title"]).to eq("SpringerBriefs in Medical Earth Sciences")
397
+ expect(subject.container["identifier"]).to eq("2523-3629")
398
+ expect(subject.container["identifierType"]).to eq("ISSN")
390
399
  end
391
400
 
392
401
  it "yet another book chapter" do
@@ -402,6 +411,11 @@ describe Bolognese::Metadata, vcr: true do
402
411
  expect(subject.publication_year).to eq("2012")
403
412
  expect(subject.publisher).to eq("IGI Global")
404
413
  expect(subject.agency).to eq("crossref")
414
+ expect(subject.container["type"]).to eq("Book")
415
+ expect(subject.container["title"]).to eq("Graph-Based Methods in Computer Vision")
416
+ expect(subject.container["firstPage"]).to eq("72")
417
+ expect(subject.container["lastPage"]).to eq("94")
418
+ expect(subject.container["identifiers"]).to eq([{"identifier"=>"9781466618916", "identifierType"=>"ISBN"}])
405
419
  end
406
420
 
407
421
  it "missing creator" do
@@ -46,7 +46,7 @@ describe Bolognese::Metadata, vcr: true do
46
46
  input = fixture_path + "datacite_software_missing_comma.json"
47
47
  subject = Bolognese::Metadata.new(input: input, from: "datacite_json", show_errors: true)
48
48
  expect(subject.valid?).to be false
49
- expect(subject.errors).to eq(["expected comma, not a string (after doi) at line 4, column 11 [parse.c:364]"])
49
+ expect(subject.errors).to eq(["expected comma, not a string (after doi) at line 4, column 11 [parse.c:388]"])
50
50
  expect(subject.codemeta).to be_nil
51
51
  end
52
52
 
@@ -1314,7 +1314,7 @@ describe Bolognese::Metadata, vcr: true do
1314
1314
  expect(subject.agency).to eq("datacite")
1315
1315
  expect(subject.schema_version).to eq("http://datacite.org/schema/kernel-4")
1316
1316
  expect(subject.geo_locations.first["geoLocationPlace"]).to eq("Zandmotor, sand suppletion area on the Dutch coast.")
1317
- expect(subject.geo_locations.first["geoLocationPolygon"][0].first).to eq("polygonPoint"=>{"pointLatitude"=>"52.03913926329928", "pointLongitude"=>"4.1738852605822"})
1317
+ expect(subject.geo_locations.first["geoLocationPolygon"].first).to eq("polygonPoint"=>{"pointLatitude"=>"52.03913926329928", "pointLongitude"=>"4.1738852605822"})
1318
1318
  end
1319
1319
 
1320
1320
  it "Schema 4.4 from string" do
@@ -1562,7 +1562,15 @@ describe Bolognese::Metadata, vcr: true do
1562
1562
  {"polygonPoint"=>{"pointLatitude"=>"73", "pointLongitude"=>"45"}},
1563
1563
  {"polygonPoint"=>{"pointLatitude"=>"80", "pointLongitude"=>"65"}}
1564
1564
  ]
1565
- ] }
1565
+ ] },
1566
+ { "geoLocationPolygon"=>
1567
+ [
1568
+ {"polygonPoint"=>{"pointLatitude"=>"80", "pointLongitude"=>"65"}},
1569
+ {"polygonPoint"=>{"pointLatitude"=>"75", "pointLongitude"=>"55"}},
1570
+ {"polygonPoint"=>{"pointLatitude"=>"73", "pointLongitude"=>"45"}},
1571
+ {"polygonPoint"=>{"pointLatitude"=>"80", "pointLongitude"=>"65"}}
1572
+ ]
1573
+ }
1566
1574
  ]
1567
1575
  )
1568
1576
  end
data/spec/utils_spec.rb CHANGED
@@ -539,7 +539,7 @@ describe Bolognese::Metadata, vcr: true do
539
539
  expect(response).to eq({"rightsUri"=>"info:eu-repo/semantics/openAccess"})
540
540
  end
541
541
  end
542
-
542
+
543
543
  context "fos" do
544
544
  it "name_to_fos match" do
545
545
  name = "Biological sciences"
@@ -583,10 +583,23 @@ describe Bolognese::Metadata, vcr: true do
583
583
  "subjectScheme"=>"Fields of Science and Technology (FOS)"}])
584
584
  end
585
585
 
586
+ it "hsh_to_fos for with schemeUri in hash" do
587
+ hsh = {
588
+ "subject" => "FOS: Computer and information sciences",
589
+ "subjectScheme" => "Fields of Science and Technology (FOS)",
590
+ "schemeUri" => "http://www.oecd.org/science/inno/38235147.pdf"}
591
+ response = subject.hsh_to_fos(hsh)
592
+ expect(response).to eq([{
593
+ "subject" => "FOS: Computer and information sciences",
594
+ "subjectScheme" => "Fields of Science and Technology (FOS)",
595
+ "schemeUri" => "http://www.oecd.org/science/inno/38235147.pdf"}])
596
+ end
597
+
586
598
  it "hsh_to_fos no match" do
587
599
  hsh = { "__content__"=>"Random tag" }
588
600
  response = subject.hsh_to_fos(hsh)
589
601
  expect(response).to eq([{"subject"=>"Random tag"}])
590
602
  end
603
+
591
604
  end
592
605
  end
@@ -281,7 +281,7 @@ describe Bolognese::Metadata, vcr: true do
281
281
  expect(json["name"]).to eq("Meteo measurements at the Sand Motor")
282
282
  expect(json["author"]).to eq("@type"=>"Person", "familyName"=>"Den Heijer", "givenName"=>"C", "name"=>"C Den Heijer")
283
283
  expect(json["includedInDataCatalog"]).to be_nil
284
- expect(json["spatialCoverage"].dig("geo", "polygon")[0].length).to eq(34)
284
+ expect(json["spatialCoverage"].dig("geo", "polygon").length).to eq(34)
285
285
  expect(json["spatialCoverage"].dig("geo", "polygon")[0].first).to eq(["4.1738852605822", "52.03913926329928"])
286
286
  end
287
287
 
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.9.2
4
+ version: 1.9.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-25 00:00:00.000000000 Z
11
+ date: 2021-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: maremma
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: 1.10.4
53
+ version: 1.11.2
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 1.10.4
60
+ version: 1.11.2
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: loofah
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -1274,7 +1274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1274
1274
  - !ruby/object:Gem::Version
1275
1275
  version: '0'
1276
1276
  requirements: []
1277
- rubygems_version: 3.0.3
1277
+ rubygems_version: 3.0.3.1
1278
1278
  signing_key:
1279
1279
  specification_version: 4
1280
1280
  summary: Ruby client library for conversion of DOI Metadata