relaton-doi 1.17.0 → 1.18.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 +1 -1
- data/.github/workflows/release.yml +1 -1
- data/README.adoc +2 -0
- data/lib/relaton_doi/crossref.rb +29 -7
- data/lib/relaton_doi/processor.rb +6 -0
- data/lib/relaton_doi/version.rb +1 -1
- data/lib/relaton_doi.rb +4 -4
- data/relaton-doi.gemspec +6 -6
- metadata +13 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6165c455d9e93d58c276f6822b9f37d3c47b19a43daae5cbe9f4b13dafeb70e
|
4
|
+
data.tar.gz: fbe2077d29570724250addffd80a07d53073303eb55066e007caa2943e0932c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12d38b33fa066cf92cbecf2a0f4398aa264d941a0e6f09b8099c390e4eb31108ddec4862a395f60a031a3994090f7676ed54705a90d6e7f78ec4b2202f1f632c
|
7
|
+
data.tar.gz: d2174bd65dfc7e96e1e1a4c0ec08387a32dd82d3432d8ebb9d792b2d964d21b46468c325f7402345ec702fdd66d1fd430c3309f064781b692f84caa531bc88fc
|
data/.github/workflows/rake.yml
CHANGED
data/README.adoc
CHANGED
@@ -14,6 +14,8 @@ https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibli
|
|
14
14
|
You can use it to retrieve metadata of Standards from https://crossref.org, and
|
15
15
|
access such metadata through the `BibliographicItem` object.
|
16
16
|
|
17
|
+
To collect metadata this gem makes a few requests to the CrossRef API. It may take a few seconds to get the metadata.
|
18
|
+
|
17
19
|
== Installation
|
18
20
|
|
19
21
|
Add this line to your application's Gemfile:
|
data/lib/relaton_doi/crossref.rb
CHANGED
@@ -2,6 +2,10 @@ module RelatonDoi
|
|
2
2
|
module Crossref
|
3
3
|
extend self
|
4
4
|
|
5
|
+
HEADER = {
|
6
|
+
"User-Agent" => "Relaton/RelatonDoi (https://www.relaton.org/guides/doi/; mailto:open.source@ribose.com)"
|
7
|
+
}.freeze
|
8
|
+
|
5
9
|
#
|
6
10
|
# Get a document by DOI from the CrossRef API.
|
7
11
|
#
|
@@ -15,11 +19,13 @@ module RelatonDoi
|
|
15
19
|
Util.warn "(#{doi}) Fetching from search.crossref.org ..."
|
16
20
|
id = doi.sub(%r{^doi:}, "")
|
17
21
|
message = get_by_id id
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
if message
|
23
|
+
Util.warn "(#{doi}) Found: `#{message['DOI']}`"
|
24
|
+
Parser.parse message
|
25
|
+
else
|
26
|
+
Util.warn("(#{doi}) Not found.")
|
27
|
+
nil
|
28
|
+
end
|
23
29
|
end
|
24
30
|
|
25
31
|
#
|
@@ -30,8 +36,24 @@ module RelatonDoi
|
|
30
36
|
# @return [Hash] The document.
|
31
37
|
#
|
32
38
|
def get_by_id(id)
|
33
|
-
resp = Serrano.works ids: id
|
34
|
-
|
39
|
+
# resp = Serrano.works ids: id
|
40
|
+
n = 0
|
41
|
+
url = "https://api.crossref.org/works/#{ERB::Util.url_encode(id)}"
|
42
|
+
loop do
|
43
|
+
resp = Faraday.get url, nil, HEADER
|
44
|
+
case resp.status
|
45
|
+
when 200
|
46
|
+
work = JSON.parse resp.body
|
47
|
+
return work["message"] if work["status"] == "ok"
|
48
|
+
when 404 then return nil
|
49
|
+
end
|
50
|
+
|
51
|
+
if n > 1
|
52
|
+
raise RelatonBib::RequestError, "Crossref error: #{resp.body}"
|
53
|
+
end
|
54
|
+
n += 1
|
55
|
+
sleep resp.headers["x-rate-limit-interval"].to_i * n
|
56
|
+
end
|
35
57
|
end
|
36
58
|
end
|
37
59
|
end
|
data/lib/relaton_doi/version.rb
CHANGED
data/lib/relaton_doi.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "serrano"
|
3
|
+
# require "serrano"
|
4
4
|
require "relaton_bipm"
|
5
5
|
# require "relaton_iso_bib"
|
6
6
|
# require "relaton_w3c"
|
@@ -13,9 +13,9 @@ require_relative "relaton_doi/util"
|
|
13
13
|
require_relative "relaton_doi/parser"
|
14
14
|
require_relative "relaton_doi/crossref"
|
15
15
|
|
16
|
-
Serrano.configuration do |config|
|
17
|
-
|
18
|
-
end
|
16
|
+
# Serrano.configuration do |config|
|
17
|
+
# config.mailto = "open.source@ribose.com"
|
18
|
+
# end
|
19
19
|
|
20
20
|
module RelatonDoi
|
21
21
|
extend self
|
data/relaton-doi.gemspec
CHANGED
@@ -34,13 +34,13 @@ Gem::Specification.new do |spec|
|
|
34
34
|
# Uncomment to register a new dependency of your gem
|
35
35
|
# spec.add_dependency "example-gem", "~> 1.0"
|
36
36
|
|
37
|
-
spec.add_dependency "relaton-bib", "~> 1.
|
38
|
-
spec.add_dependency "relaton-bipm", "~> 1.
|
39
|
-
spec.add_dependency "relaton-ieee", "~> 1.
|
40
|
-
spec.add_dependency "relaton-ietf", "~> 1.
|
41
|
-
spec.add_dependency "relaton-nist", "~> 1.
|
37
|
+
spec.add_dependency "relaton-bib", "~> 1.18.0"
|
38
|
+
spec.add_dependency "relaton-bipm", "~> 1.18.0"
|
39
|
+
spec.add_dependency "relaton-ieee", "~> 1.18.0"
|
40
|
+
spec.add_dependency "relaton-ietf", "~> 1.18.0"
|
41
|
+
spec.add_dependency "relaton-nist", "~> 1.18.0"
|
42
42
|
# spec.add_dependency "relaton-w3c", "~> 1.10.0"
|
43
|
-
spec.add_dependency "serrano", "~> 1.4.0"
|
43
|
+
# spec.add_dependency "serrano", "~> 1.4.0"
|
44
44
|
|
45
45
|
# For more information and examples about making a new gem, checkout our
|
46
46
|
# guide at: https://bundler.io/guides/creating_gem.html
|
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.
|
4
|
+
version: 1.18.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:
|
11
|
+
date: 2024-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: relaton-bib
|
@@ -16,84 +16,70 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.18.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.18.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: relaton-bipm
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.18.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: 1.18.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: relaton-ieee
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 1.18.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: 1.18.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: relaton-ietf
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.18.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.18.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: relaton-nist
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.
|
75
|
+
version: 1.18.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: serrano
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 1.4.0
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 1.4.0
|
82
|
+
version: 1.18.0
|
97
83
|
description: 'RelatonDOI: retrieve Standards for bibliographic using DOI through Crossrefand
|
98
84
|
provide Relaton object.'
|
99
85
|
email:
|
@@ -142,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
128
|
- !ruby/object:Gem::Version
|
143
129
|
version: '0'
|
144
130
|
requirements: []
|
145
|
-
rubygems_version: 3.3.
|
131
|
+
rubygems_version: 3.3.27
|
146
132
|
signing_key:
|
147
133
|
specification_version: 4
|
148
134
|
summary: 'RelatonDOI: retrieve Standards for bibliographic using DOI through Crossrefand
|