jalc 2.0.1 → 2.1.2
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 +12 -0
- data/README.md +1 -0
- data/lib/jalc/registration/client.rb +12 -15
- 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 +6 -6
- 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: 2407227918e30a52acb05438fbb3b1713ee9cb2206000204d795030b78d7f265
|
4
|
+
data.tar.gz: 390b6c7e439ef7f487af098808cc717411610d1c07aeafe15b95404eeed7d954
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 275263f97587d4258f29d850d19378cdcfedf3ac502b3d13d52cb72b5c259e0f87159cb1a9d136c9fbb9d6c0b4a58b3f2d36ebb2007fe8fe6ca3af38793196ff
|
7
|
+
data.tar.gz: d09786ab3e4a994020e6e1f52d575e4bd18f57ce2728944bd8987682c93ec0104150d1a5133fbe3251acb05b55f1984731de23c0aabd313c5e6821a33dc12458
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [2.1.2] - 2022-04-13
|
4
|
+
|
5
|
+
- Fix the condition of log filtering
|
6
|
+
|
7
|
+
## [2.1.1] - 2022-04-08
|
8
|
+
|
9
|
+
- Fix a typo of a registration API parameter
|
10
|
+
|
11
|
+
## [2.1.0] - 2022-04-07
|
12
|
+
|
13
|
+
- Update the constructor arguments of REST::Client and Registration::Client
|
14
|
+
|
3
15
|
## [2.0.1] - 2022-03-06
|
4
16
|
|
5
17
|
- Make the registration error messages Japanese
|
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,16 +44,16 @@ 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,
|
59
|
-
logger.filter(/(
|
54
|
+
if config.logger
|
55
|
+
f.response :logger, config.logger, { headers: false } do |logger|
|
56
|
+
logger.filter(/(passwd=)([^&]+)/, '\1[REMOVED]')
|
60
57
|
end
|
61
58
|
end
|
62
59
|
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
@@ -5,8 +5,6 @@ module JaLC
|
|
5
5
|
VERSION: String
|
6
6
|
|
7
7
|
module Registration
|
8
|
-
BASE_URL: String
|
9
|
-
|
10
8
|
def self.configure: { (Config) -> void } -> void
|
11
9
|
def self.config: -> Config
|
12
10
|
|
@@ -27,12 +25,14 @@ module JaLC
|
|
27
25
|
end
|
28
26
|
type rexml_document = untyped
|
29
27
|
|
30
|
-
def initialize: (
|
28
|
+
def initialize: (Config config) -> void
|
31
29
|
def post: (_IO xml_file) -> rexml_document
|
32
30
|
def get_result: (Integer | String exec_id) -> rexml_document
|
33
31
|
end
|
34
32
|
|
35
33
|
class Config
|
34
|
+
DEFAULT_BASE_URL: String
|
35
|
+
|
36
36
|
attr_accessor id: String?
|
37
37
|
attr_accessor password: String?
|
38
38
|
attr_accessor logger: _Logger?
|
@@ -44,8 +44,6 @@ module JaLC
|
|
44
44
|
module REST
|
45
45
|
type response_body = Hash[String, untyped] | String | nil
|
46
46
|
|
47
|
-
BASE_URL: String
|
48
|
-
|
49
47
|
def self.configure: { (Config) -> void } -> void
|
50
48
|
def self.config: -> Config
|
51
49
|
|
@@ -74,13 +72,15 @@ module JaLC
|
|
74
72
|
end
|
75
73
|
|
76
74
|
class Client
|
77
|
-
def initialize: (
|
75
|
+
def initialize: (Config config) -> void
|
78
76
|
def prefixes: (?ra: String?, ?sort: String?, ?order: String?) -> response_body
|
79
77
|
def doilist: (String prefix, ?from: String?, ?to: String?, ?rows: Integer? | String?, ?page: Integer? | String?, ?sort: String?, ?order: String?) -> response_body
|
80
78
|
def doi: (String doi) -> response_body
|
81
79
|
end
|
82
80
|
|
83
81
|
class Config
|
82
|
+
DEFAULT_BASE_URL: String
|
83
|
+
|
84
84
|
attr_accessor logger: _Logger?
|
85
85
|
|
86
86
|
def initialize: -> void
|
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.2
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|