relaton-doi 1.14.0 → 1.14.1
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 +55 -6
- data/lib/relaton_doi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53cd51733991e0f69cc3d0323cd9dff42122523c3a8f2d8e2738b1408da5321b
|
4
|
+
data.tar.gz: 7de2c0a2b3fa4369a832eaf1d655349bfe1682d86fc833da07be0243fadb7602
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4981dfeb396011af9fa1773f565009306664828231709d0e9d8ffa939f8e6f170dd09b4fe0793a5abbbcea07d024444737359a21e4e433c1b191f97fa245fc24
|
7
|
+
data.tar.gz: d599da84e5f7a0468decc094d449e7223dd63b5ff4a615993f34c882f43572fa9bb2287411228de21fc60c37c8c1b3572ae207b142335d4f618c6f8ad0d748c8
|
data/.github/workflows/rake.yml
CHANGED
data/lib/relaton_doi/crossref.rb
CHANGED
@@ -110,9 +110,15 @@ module RelatonDoi
|
|
110
110
|
doctype: @message["type"],
|
111
111
|
place: create_place,
|
112
112
|
relation: create_relation,
|
113
|
+
extent: create_extent,
|
113
114
|
}
|
114
115
|
end
|
115
116
|
|
117
|
+
#
|
118
|
+
# Parse the document type.
|
119
|
+
#
|
120
|
+
# @return [String] The document type.
|
121
|
+
#
|
116
122
|
def parse_type
|
117
123
|
TYPES[@message["type"]] || @message["type"]
|
118
124
|
end
|
@@ -169,9 +175,17 @@ module RelatonDoi
|
|
169
175
|
# @return [Array<RelatonBib::TypedUri>] The link.
|
170
176
|
#
|
171
177
|
def create_link
|
172
|
-
|
178
|
+
links = []
|
179
|
+
if @message["URL"]
|
180
|
+
links << RelatonBib::TypedUri.new(type: "DOI", content: @message["URL"])
|
181
|
+
end
|
182
|
+
return links unless @message["link"]&.any?
|
173
183
|
|
174
|
-
|
184
|
+
link = @message["link"].first
|
185
|
+
if link["URL"].match?(/\.pdf$/)
|
186
|
+
links << RelatonBib::TypedUri.new(type: "pdf", content: link["URL"])
|
187
|
+
end
|
188
|
+
links
|
175
189
|
end
|
176
190
|
|
177
191
|
#
|
@@ -194,15 +208,33 @@ module RelatonDoi
|
|
194
208
|
#
|
195
209
|
# @return [Array<RelatonBib::ContributionInfo>] The contributors.
|
196
210
|
#
|
197
|
-
def create_contributors
|
211
|
+
def create_contributors # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
198
212
|
contribs = %w[author editor translator].each_with_object([]) do |type, obj|
|
199
213
|
@message[type]&.each do |contrib|
|
200
214
|
obj << contributor(person(contrib), type)
|
201
215
|
end
|
202
216
|
end
|
217
|
+
contribs += fetch_editors if contribs.none? { |e| e.role.any? { |r| r.type == "editor" } }
|
203
218
|
contribs << contributor(org_publisher, "publisher")
|
204
219
|
end
|
205
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
|
+
|
206
238
|
#
|
207
239
|
# Cerate an organization publisher from the message hash.
|
208
240
|
#
|
@@ -355,13 +387,30 @@ module RelatonDoi
|
|
355
387
|
#
|
356
388
|
# @return [Array<RelatonBib::DocumentRelation>] The relations.
|
357
389
|
#
|
358
|
-
def create_relation
|
359
|
-
|
390
|
+
def create_relation # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
391
|
+
rels = []
|
392
|
+
@message["container-title"]&.each do |ct|
|
393
|
+
bib = RelatonBib::BibliographicItem.new(title: [content: ct])
|
394
|
+
rels << RelatonBib::DocumentRelation.new(type: "includedIn", bibitem: bib)
|
395
|
+
end
|
396
|
+
@message["relation"].each_with_object(rels) do |(k, v), a|
|
360
397
|
fref = RelatonBib::FormattedRef.new(content: v["id"])
|
361
398
|
bib = create_bibitem v["id"], formattedref: fref
|
362
399
|
type = REALATION_TYPES[k] || k
|
363
|
-
RelatonBib::DocumentRelation.new(type: type, bibitem: bib)
|
400
|
+
a << RelatonBib::DocumentRelation.new(type: type, bibitem: bib)
|
364
401
|
end
|
365
402
|
end
|
403
|
+
|
404
|
+
#
|
405
|
+
# Create an extent from the message hash.
|
406
|
+
#
|
407
|
+
# @return [Array<RelatonBib::Locality>] The extent.
|
408
|
+
#
|
409
|
+
def create_extent
|
410
|
+
return [] unless @message["page"]
|
411
|
+
|
412
|
+
from, to = @message["page"].split("-")
|
413
|
+
[RelatonBib::Locality.new("page", from, to)]
|
414
|
+
end
|
366
415
|
end
|
367
416
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|