relaton-doi 1.14.0 → 1.14.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +0 -1
- data/lib/relaton_doi/crossref.rb +86 -6
- 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/.github/workflows/rake.yml
CHANGED
data/lib/relaton_doi/crossref.rb
CHANGED
@@ -110,9 +110,16 @@ module RelatonDoi
|
|
110
110
|
doctype: @message["type"],
|
111
111
|
place: create_place,
|
112
112
|
relation: create_relation,
|
113
|
+
extent: create_extent,
|
114
|
+
series: create_series,
|
113
115
|
}
|
114
116
|
end
|
115
117
|
|
118
|
+
#
|
119
|
+
# Parse the document type.
|
120
|
+
#
|
121
|
+
# @return [String] The document type.
|
122
|
+
#
|
116
123
|
def parse_type
|
117
124
|
TYPES[@message["type"]] || @message["type"]
|
118
125
|
end
|
@@ -169,9 +176,17 @@ module RelatonDoi
|
|
169
176
|
# @return [Array<RelatonBib::TypedUri>] The link.
|
170
177
|
#
|
171
178
|
def create_link
|
172
|
-
|
179
|
+
links = []
|
180
|
+
if @message["URL"]
|
181
|
+
links << RelatonBib::TypedUri.new(type: "DOI", content: @message["URL"])
|
182
|
+
end
|
183
|
+
return links unless @message["link"]&.any?
|
173
184
|
|
174
|
-
|
185
|
+
link = @message["link"].first
|
186
|
+
if link["URL"].match?(/\.pdf$/)
|
187
|
+
links << RelatonBib::TypedUri.new(type: "pdf", content: link["URL"])
|
188
|
+
end
|
189
|
+
links
|
175
190
|
end
|
176
191
|
|
177
192
|
#
|
@@ -194,7 +209,7 @@ module RelatonDoi
|
|
194
209
|
#
|
195
210
|
# @return [Array<RelatonBib::ContributionInfo>] The contributors.
|
196
211
|
#
|
197
|
-
def create_contributors
|
212
|
+
def create_contributors # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
198
213
|
contribs = %w[author editor translator].each_with_object([]) do |type, obj|
|
199
214
|
@message[type]&.each do |contrib|
|
200
215
|
obj << contributor(person(contrib), type)
|
@@ -355,12 +370,77 @@ module RelatonDoi
|
|
355
370
|
#
|
356
371
|
# @return [Array<RelatonBib::DocumentRelation>] The relations.
|
357
372
|
#
|
358
|
-
def create_relation
|
359
|
-
|
373
|
+
def create_relation # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
374
|
+
rels = []
|
375
|
+
@message["container-title"]&.each do |ct|
|
376
|
+
contrib = included_in_editors(ct)
|
377
|
+
bib = RelatonBib::BibliographicItem.new(title: [content: ct], contributor: contrib)
|
378
|
+
rels << RelatonBib::DocumentRelation.new(type: "includedIn", bibitem: bib)
|
379
|
+
end
|
380
|
+
@message["relation"].each_with_object(rels) do |(k, v), a|
|
360
381
|
fref = RelatonBib::FormattedRef.new(content: v["id"])
|
361
382
|
bib = create_bibitem v["id"], formattedref: fref
|
362
383
|
type = REALATION_TYPES[k] || k
|
363
|
-
RelatonBib::DocumentRelation.new(type: type, bibitem: bib)
|
384
|
+
a << RelatonBib::DocumentRelation.new(type: type, bibitem: bib)
|
385
|
+
end
|
386
|
+
end
|
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
|
+
|
417
|
+
#
|
418
|
+
# Create an extent from the message hash.
|
419
|
+
#
|
420
|
+
# @return [Array<RelatonBib::Locality>] The extent.
|
421
|
+
#
|
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
|
432
|
+
|
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
|
364
444
|
end
|
365
445
|
end
|
366
446
|
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.'
|