relaton-doi 1.14.1 → 1.14.2
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 +4 -4
- data/lib/relaton_doi/crossref.rb +54 -23
- data/lib/relaton_doi/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d39addcfe400051b6cfadb759265bee674ace775bff92dab29a1c7f80891cd48
|
4
|
+
data.tar.gz: e24fa98bbfbff44bcb9b6b200c79750fe2f72ece457f67162a62324742a56cee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33bf3eabe2d1786be51d05960ad0aff732dc3ebceed3bde02979cb6e01790c2c2f65f221ca5d1f1567b73be3b28ceab9bb2ec4b8303e7165881a7c9d88b3f9ae
|
7
|
+
data.tar.gz: d3e180ade463b3e94785c271dd795b440b645426cecf914a6684b67eadd2313b22155eb31860d4602407c38e8266b031c962cd7affad9947c98361553109a4c8
|
data/lib/relaton_doi/crossref.rb
CHANGED
@@ -111,6 +111,7 @@ module RelatonDoi
|
|
111
111
|
place: create_place,
|
112
112
|
relation: create_relation,
|
113
113
|
extent: create_extent,
|
114
|
+
series: create_series,
|
114
115
|
}
|
115
116
|
end
|
116
117
|
|
@@ -214,27 +215,9 @@ module RelatonDoi
|
|
214
215
|
obj << contributor(person(contrib), type)
|
215
216
|
end
|
216
217
|
end
|
217
|
-
contribs += fetch_editors if contribs.none? { |e| e.role.any? { |r| r.type == "editor" } }
|
218
218
|
contribs << contributor(org_publisher, "publisher")
|
219
219
|
end
|
220
220
|
|
221
|
-
#
|
222
|
-
# Fetch editors from Crossref.
|
223
|
-
#
|
224
|
-
# @return [Array<RelatonBib::ContributionInfo>] The editors.
|
225
|
-
#
|
226
|
-
def fetch_editors # rubocop:disable Metrics/AbcSize
|
227
|
-
title = @message["container-title"].first
|
228
|
-
year = (@message["published"] || @message["approved"])["date-parts"][0][0]
|
229
|
-
query = "#{title}, #{@message['publisher']}, #{@message['publisher-location']}, #{year}"
|
230
|
-
resp = Faraday.get %{http://api.crossref.org/works?query.bibliographic="#{query}"&rows=5&filter=type:book}
|
231
|
-
json = JSON.parse resp.body
|
232
|
-
item = json["message"]["items"].detect { |i| i["title"].include?(title) && i["editor"] }
|
233
|
-
return [] unless item
|
234
|
-
|
235
|
-
item["editor"].map { |a| contributor(person(a), "editor") }
|
236
|
-
end
|
237
|
-
|
238
221
|
#
|
239
222
|
# Cerate an organization publisher from the message hash.
|
240
223
|
#
|
@@ -390,7 +373,8 @@ module RelatonDoi
|
|
390
373
|
def create_relation # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
391
374
|
rels = []
|
392
375
|
@message["container-title"]&.each do |ct|
|
393
|
-
|
376
|
+
contrib = included_in_editors(ct)
|
377
|
+
bib = RelatonBib::BibliographicItem.new(title: [content: ct], contributor: contrib)
|
394
378
|
rels << RelatonBib::DocumentRelation.new(type: "includedIn", bibitem: bib)
|
395
379
|
end
|
396
380
|
@message["relation"].each_with_object(rels) do |(k, v), a|
|
@@ -401,16 +385,63 @@ module RelatonDoi
|
|
401
385
|
end
|
402
386
|
end
|
403
387
|
|
388
|
+
#
|
389
|
+
# Fetch included in editors.
|
390
|
+
#
|
391
|
+
# @param [String] title container-title
|
392
|
+
#
|
393
|
+
# @return [Array<RelatonBib::ContributionInfo>] The editors contribution info.
|
394
|
+
#
|
395
|
+
def included_in_editors(title)
|
396
|
+
item = fetch_included_in title
|
397
|
+
return [] unless item
|
398
|
+
|
399
|
+
item["editor"].map { |e| contributor(person(e), "editor") }
|
400
|
+
end
|
401
|
+
|
402
|
+
#
|
403
|
+
# Fetch included in relation.
|
404
|
+
#
|
405
|
+
# @param [String] title container-title
|
406
|
+
#
|
407
|
+
# @return [Hash] The included in relation item.
|
408
|
+
#
|
409
|
+
def fetch_included_in(title) # rubocop:disable Metrics/AbcSize
|
410
|
+
year = (@message["published"] || @message["approved"])["date-parts"][0][0]
|
411
|
+
query = "#{title}, #{@message['publisher']}, #{@message['publisher-location']}, #{year}"
|
412
|
+
resp = Faraday.get %{http://api.crossref.org/works?query.bibliographic="#{query}"&rows=5&filter=type:book}
|
413
|
+
json = JSON.parse resp.body
|
414
|
+
json["message"]["items"].detect { |i| i["title"].include?(title) && i["editor"] }
|
415
|
+
end
|
416
|
+
|
404
417
|
#
|
405
418
|
# Create an extent from the message hash.
|
406
419
|
#
|
407
420
|
# @return [Array<RelatonBib::Locality>] The extent.
|
408
421
|
#
|
409
|
-
def create_extent
|
410
|
-
|
422
|
+
def create_extent # rubocop:disable Metrics/AbcSize
|
423
|
+
extent = []
|
424
|
+
extent << RelatonBib::Locality.new("volume", @message["volume"]) if @message["volume"]
|
425
|
+
extent << RelatonBib::Locality.new("issue", @message["issue"]) if @message["issue"]
|
426
|
+
if @message["page"]
|
427
|
+
from, to = @message["page"].split("-")
|
428
|
+
extent << RelatonBib::Locality.new("page", from, to)
|
429
|
+
end
|
430
|
+
extent.any? ? [RelatonBib::LocalityStack.new(extent)] : []
|
431
|
+
end
|
411
432
|
|
412
|
-
|
413
|
-
|
433
|
+
#
|
434
|
+
# Create a series from the message hash.
|
435
|
+
#
|
436
|
+
# @return [Arrey<RelatonBib::Series>] The series.
|
437
|
+
#
|
438
|
+
def create_series
|
439
|
+
return [] unless @message["container-title"]
|
440
|
+
|
441
|
+
@message["container-title"].map do |ct|
|
442
|
+
title = RelatonBib::TypedTitleString.new content: ct
|
443
|
+
RelatonBib::Series.new title: title
|
444
|
+
end
|
414
445
|
end
|
415
446
|
end
|
416
447
|
end
|
data/lib/relaton_doi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-doi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.14.
|
4
|
+
version: 1.14.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|
@@ -208,7 +208,7 @@ licenses:
|
|
208
208
|
- BSD-2-Clause
|
209
209
|
metadata:
|
210
210
|
homepage_uri: https://github.com/relaton/relaton-doi
|
211
|
-
post_install_message:
|
211
|
+
post_install_message:
|
212
212
|
rdoc_options: []
|
213
213
|
require_paths:
|
214
214
|
- lib
|
@@ -223,8 +223,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
223
|
- !ruby/object:Gem::Version
|
224
224
|
version: '0'
|
225
225
|
requirements: []
|
226
|
-
rubygems_version: 3.
|
227
|
-
signing_key:
|
226
|
+
rubygems_version: 3.2.3
|
227
|
+
signing_key:
|
228
228
|
specification_version: 4
|
229
229
|
summary: 'RelatonDOI: retrieve Standards for bibliographic using DOI through Crossrefand
|
230
230
|
provide Relaton object.'
|