jalc 2.0.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +1 -0
- data/lib/jalc/registration/client.rb +11 -14
- data/lib/jalc/registration/config.rb +4 -1
- data/lib/jalc/registration/middleware/raise_error.rb +3 -3
- data/lib/jalc/registration.rb +1 -5
- data/lib/jalc/rest/client.rb +6 -7
- data/lib/jalc/rest/config.rb +4 -1
- data/lib/jalc/rest.rb +1 -1
- data/lib/jalc/version.rb +1 -1
- data/sig/jalc.rbs +4 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eccd488a68365b574a6545965ead9f49c4f49102d4296be4d2dc01ca05201035
|
4
|
+
data.tar.gz: 369a77d191d672afae36aa01d404d0bfc7b79a89ea71225c84b8754cd8e8ad3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a6a6882a2855ea1887600d6980419900a329c3ee9594704ae6ab8fbac0f0e60516475fe6d994975159e440afa6e6185be4e249cc462511a3acb39471998c94c
|
7
|
+
data.tar.gz: 20cc3fd0dae75d85d173b8be824421d3bf641ab154c4c7026d252380211b9b46adfb23c7e7fc23ebb24c5484d7b1dcf7cbda8dc809fe7e90c6dc4c007f0ff90b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [2.1.1] - 2022-04-08
|
4
|
+
|
5
|
+
- Fix a typo of a registration API parameter
|
6
|
+
|
7
|
+
## [2.1.0] - 2022-04-07
|
8
|
+
|
9
|
+
- Update the constructor arguments of REST::Client and Registration::Client
|
10
|
+
|
11
|
+
## [2.0.1] - 2022-03-06
|
12
|
+
|
13
|
+
- Make the registration error messages Japanese
|
14
|
+
|
3
15
|
## [2.0.0] - 2022-01-10
|
4
16
|
|
5
17
|
- Change the return values from `Faraday::Response` to its `#body`
|
data/README.md
CHANGED
@@ -50,6 +50,7 @@ See https://japanlinkcenter.org/top/doc/JaLC_tech_interface_doc.pdf for API deta
|
|
50
50
|
require 'jalc'
|
51
51
|
|
52
52
|
JaLC::Registration.configure do |config|
|
53
|
+
config.base_url = 'https://japanlinkcenter.org' # default
|
53
54
|
config.id = 'sankichi92'
|
54
55
|
config.password = ENV['JALC_PASSWORD']
|
55
56
|
config.logger = nil
|
@@ -9,22 +9,19 @@ require_relative 'middleware/raise_error'
|
|
9
9
|
|
10
10
|
module JaLC
|
11
11
|
module Registration
|
12
|
-
BASE_URL = 'https://japanlinkcenter.org'
|
13
|
-
|
14
12
|
class Client
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
@
|
19
|
-
@base_url = base_url
|
13
|
+
attr_reader :config
|
14
|
+
|
15
|
+
def initialize(config)
|
16
|
+
@config = config
|
20
17
|
end
|
21
18
|
|
22
19
|
def post(xml_file)
|
23
20
|
response = conn.post(
|
24
21
|
'/jalc/infoRegistry/registDataReceive/index',
|
25
22
|
{
|
26
|
-
login_id: Faraday::Multipart::ParamPart.new(
|
27
|
-
|
23
|
+
login_id: Faraday::Multipart::ParamPart.new(config.id, 'text/plain'),
|
24
|
+
login_passwd: Faraday::Multipart::ParamPart.new(config.password, 'text/plain'),
|
28
25
|
fname: Faraday::Multipart::FilePart.new(xml_file, 'text/xml'),
|
29
26
|
},
|
30
27
|
)
|
@@ -35,8 +32,8 @@ module JaLC
|
|
35
32
|
response = conn.get(
|
36
33
|
'/jalc/infoRegistry/registDataResult/index',
|
37
34
|
{
|
38
|
-
login_id:
|
39
|
-
|
35
|
+
login_id: config.id,
|
36
|
+
login_passwd: config.password,
|
40
37
|
exec_id: exec_id,
|
41
38
|
},
|
42
39
|
)
|
@@ -47,15 +44,15 @@ module JaLC
|
|
47
44
|
|
48
45
|
def conn
|
49
46
|
@conn ||= Faraday.new(
|
50
|
-
url:
|
47
|
+
url: config.base_url,
|
51
48
|
headers: { 'User-Agent' => "jalc-ruby v#{VERSION}" },
|
52
49
|
) do |f|
|
53
50
|
f.request :multipart
|
54
51
|
f.use Middleware::RaiseError
|
55
52
|
f.use Middleware::ParseXML
|
56
53
|
f.response :raise_error
|
57
|
-
if
|
58
|
-
f.response :logger,
|
54
|
+
if config.logger
|
55
|
+
f.response :logger, config.logger, { headers: false } do |logger|
|
59
56
|
logger.filter(/(password=)\w+/, '\1[FILTERED]')
|
60
57
|
end
|
61
58
|
end
|
@@ -5,9 +5,12 @@ require 'logger'
|
|
5
5
|
module JaLC
|
6
6
|
module Registration
|
7
7
|
class Config
|
8
|
-
|
8
|
+
DEFAULT_BASE_URL = 'https://japanlinkcenter.org'
|
9
|
+
|
10
|
+
attr_accessor :base_url, :id, :password, :logger
|
9
11
|
|
10
12
|
def initialize
|
13
|
+
@base_url = DEFAULT_BASE_URL
|
11
14
|
@id = nil
|
12
15
|
@password = nil
|
13
16
|
@logger = ::Logger.new($stdout)
|
@@ -12,11 +12,11 @@ module JaLC
|
|
12
12
|
case env.body.root.elements['head/errcd']&.text
|
13
13
|
when '*'
|
14
14
|
raise AuthenticationError,
|
15
|
-
'
|
15
|
+
'IDとパスワードの組合せが間違っているか、アクセス元のIPアドレスがJaLCに登録されているIPアドレスと異なっている可能性があります (errcd=*)'
|
16
16
|
when '#'
|
17
|
-
raise InvalidXMLError, 'XML
|
17
|
+
raise InvalidXMLError, 'XMLファイルの構造に誤りがあるか、login_id、login_passwd、fnameのパラメータに未設定のものがある可能性があります (errcd=#)'
|
18
18
|
when '+'
|
19
|
-
raise RegistrationError, '
|
19
|
+
raise RegistrationError, 'fnameで指定したファイルがXMLファイルでないか、XMLファイルの文字コードがUTF-8でない可能性があります (errcd=+)'
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/jalc/registration.rb
CHANGED
data/lib/jalc/rest/client.rb
CHANGED
@@ -9,12 +9,11 @@ require_relative '../version'
|
|
9
9
|
|
10
10
|
module JaLC
|
11
11
|
module REST
|
12
|
-
BASE_URL = 'https://api.japanlinkcenter.org'
|
13
|
-
|
14
12
|
class Client
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
attr_reader :config
|
14
|
+
|
15
|
+
def initialize(config)
|
16
|
+
@config = config
|
18
17
|
end
|
19
18
|
|
20
19
|
def prefixes(ra: nil, sort: nil, order: nil)
|
@@ -54,12 +53,12 @@ module JaLC
|
|
54
53
|
|
55
54
|
def conn
|
56
55
|
@conn ||= Faraday.new(
|
57
|
-
url:
|
56
|
+
url: config.base_url,
|
58
57
|
headers: { 'User-Agent' => "jalc-ruby v#{VERSION}" },
|
59
58
|
) do |f|
|
60
59
|
f.use Middleware::RaiseError
|
61
60
|
f.response :json
|
62
|
-
f.response :logger,
|
61
|
+
f.response :logger, config.logger, { headers: false } if config.logger
|
63
62
|
end
|
64
63
|
rescue Faraday::Error => e
|
65
64
|
raise e unless e.message.match?(/is not registered/)
|
data/lib/jalc/rest/config.rb
CHANGED
@@ -5,9 +5,12 @@ require 'logger'
|
|
5
5
|
module JaLC
|
6
6
|
module REST
|
7
7
|
class Config
|
8
|
-
|
8
|
+
DEFAULT_BASE_URL = 'https://api.japanlinkcenter.org'
|
9
|
+
|
10
|
+
attr_accessor :base_url, :logger
|
9
11
|
|
10
12
|
def initialize
|
13
|
+
@base_url = DEFAULT_BASE_URL
|
11
14
|
@logger = ::Logger.new($stdout)
|
12
15
|
end
|
13
16
|
end
|
data/lib/jalc/rest.rb
CHANGED
data/lib/jalc/version.rb
CHANGED
data/sig/jalc.rbs
CHANGED
@@ -27,7 +27,7 @@ module JaLC
|
|
27
27
|
end
|
28
28
|
type rexml_document = untyped
|
29
29
|
|
30
|
-
def initialize: (
|
30
|
+
def initialize: (Config config) -> void
|
31
31
|
def post: (_IO xml_file) -> rexml_document
|
32
32
|
def get_result: (Integer | String exec_id) -> rexml_document
|
33
33
|
end
|
@@ -74,10 +74,10 @@ module JaLC
|
|
74
74
|
end
|
75
75
|
|
76
76
|
class Client
|
77
|
-
def initialize: (
|
77
|
+
def initialize: (Config config) -> void
|
78
78
|
def prefixes: (?ra: String?, ?sort: String?, ?order: String?) -> response_body
|
79
|
-
def doilist: (String, ?from: String?, ?to: String?, ?rows: Integer? | String?, ?page: Integer? | String?, ?sort: String?, ?order: String?) -> response_body
|
80
|
-
def doi: (String) -> response_body
|
79
|
+
def doilist: (String prefix, ?from: String?, ?to: String?, ?rows: Integer? | String?, ?page: Integer? | String?, ?sort: String?, ?order: String?) -> response_body
|
80
|
+
def doi: (String doi) -> response_body
|
81
81
|
end
|
82
82
|
|
83
83
|
class Config
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jalc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takahiro Miyoshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
|
-
rubygems_version: 3.3.
|
117
|
+
rubygems_version: 3.3.7
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: JaLC (Japan Link Center) API Client
|