jalc 2.0.1 → 2.1.0
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/CHANGELOG.md +4 -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.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 +2 -2
- 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: a5925914098939b17ec3a6743ea89d5c4ffd2d0eee02a6953f82154b2c16f5fe
|
4
|
+
data.tar.gz: 4cd2066ea1a7c87959bb69ac6daa04dee66eaec8510a496630b06f4b33f4f55b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef5428a39e9a9164678f47f53ec0db79c15523f8f09d6f0e066f24d0071655834adb68476c120a262f2a9f24424235b03bce0462ab28193f7484f04aac91c77a
|
7
|
+
data.tar.gz: 907e630e36856c8624da546b67971c9e37937b68b560415dfb2309efb448de5ab7376b41d61ed82f97b25bdce4bf152a1cb9175dd3bd5526573409b038f3a81f
|
data/CHANGELOG.md
CHANGED
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
|
-
login_password: Faraday::Multipart::ParamPart.new(
|
23
|
+
login_id: Faraday::Multipart::ParamPart.new(config.id, 'text/plain'),
|
24
|
+
login_password: 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
|
-
login_password:
|
35
|
+
login_id: config.id,
|
36
|
+
login_password: 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)
|
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,7 +74,7 @@ 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
79
|
def doilist: (String prefix, ?from: String?, ?to: String?, ?rows: Integer? | String?, ?page: Integer? | String?, ?sort: String?, ?order: String?) -> response_body
|
80
80
|
def doi: (String doi) -> response_body
|
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.0
|
4
|
+
version: 2.1.0
|
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-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|