cheminee 0.1.34 → 0.1.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +19 -7
- data/README.md +4 -4
- data/cheminee.gemspec +3 -1
- data/lib/cheminee/api_client.rb +133 -89
- data/lib/cheminee/configuration.rb +106 -22
- data/lib/cheminee/version.rb +1 -1
- data/pkg/cheminee-0.1.35.gem +0 -0
- metadata +37 -9
- data/pkg/cheminee-0.1.34.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b489a78e92999967bac81cd48a4b6470ecbc181bead072db956d786f4b684289
|
4
|
+
data.tar.gz: '02818840a73cb71be8e156cd231aafcf6756b2d969bb027bb2e1b3b9a011db7b'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 362e1a903b2bfcda17583fd21ebb5833f44266f84d72bc9a8a5afdc505e9d0a7337af2c0c0535525c1a67836618375c159cd55de04bac6b30216d4e810b3ae2b
|
7
|
+
data.tar.gz: 23497cef82cb992182ef2c632998163513d280aeb9d17a35dc0108c3d36b09d6c1fc7c316a9b88653aff7584c08c4dc247dc8575f53fc8902be95d1ad0ef5ed3
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cheminee (0.1.
|
5
|
-
|
4
|
+
cheminee (0.1.35)
|
5
|
+
faraday (>= 1.0.1, < 3.0)
|
6
|
+
faraday-multipart
|
7
|
+
marcel
|
6
8
|
|
7
9
|
GEM
|
8
10
|
remote: https://rubygems.org/
|
@@ -11,11 +13,22 @@ GEM
|
|
11
13
|
byebug (11.1.3)
|
12
14
|
coderay (1.1.3)
|
13
15
|
diff-lcs (1.5.1)
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
faraday (2.12.0)
|
17
|
+
faraday-net_http (>= 2.0, < 3.4)
|
18
|
+
json
|
19
|
+
logger
|
20
|
+
faraday-multipart (1.0.4)
|
21
|
+
multipart-post (~> 2)
|
22
|
+
faraday-net_http (3.3.0)
|
23
|
+
net-http
|
17
24
|
jaro_winkler (1.5.6)
|
25
|
+
json (2.7.2)
|
26
|
+
logger (1.6.1)
|
27
|
+
marcel (1.0.4)
|
18
28
|
method_source (1.1.0)
|
29
|
+
multipart-post (2.4.1)
|
30
|
+
net-http (0.4.1)
|
31
|
+
uri
|
19
32
|
parallel (1.26.3)
|
20
33
|
parser (3.3.5.0)
|
21
34
|
ast (~> 2.4.1)
|
@@ -54,9 +67,8 @@ GEM
|
|
54
67
|
unicode-display_width (>= 1.4.0, < 1.6)
|
55
68
|
ruby-progressbar (1.13.0)
|
56
69
|
stringio (3.1.1)
|
57
|
-
typhoeus (1.4.1)
|
58
|
-
ethon (>= 0.9.0)
|
59
70
|
unicode-display_width (1.5.0)
|
71
|
+
uri (0.13.1)
|
60
72
|
|
61
73
|
PLATFORMS
|
62
74
|
x86_64-linux
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ Cheminée: The Chemical Structure Search Engine
|
|
7
7
|
This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
8
8
|
|
9
9
|
- API version: 1.0
|
10
|
-
- Package version: 0.1.
|
10
|
+
- Package version: 0.1.35
|
11
11
|
- Generator version: 7.9.0-SNAPSHOT
|
12
12
|
- Build package: org.openapitools.codegen.languages.RubyClientCodegen
|
13
13
|
For more information, please visit [https://github.com/rdkit-rs/cheminee](https://github.com/rdkit-rs/cheminee)
|
@@ -25,16 +25,16 @@ gem build cheminee.gemspec
|
|
25
25
|
Then either install the gem locally:
|
26
26
|
|
27
27
|
```shell
|
28
|
-
gem install ./cheminee-0.1.
|
28
|
+
gem install ./cheminee-0.1.35.gem
|
29
29
|
```
|
30
30
|
|
31
|
-
(for development, run `gem install --dev ./cheminee-0.1.
|
31
|
+
(for development, run `gem install --dev ./cheminee-0.1.35.gem` to install the development dependencies)
|
32
32
|
|
33
33
|
or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
|
34
34
|
|
35
35
|
Finally add this to the Gemfile:
|
36
36
|
|
37
|
-
gem 'cheminee', '~> 0.1.
|
37
|
+
gem 'cheminee', '~> 0.1.35'
|
38
38
|
|
39
39
|
### Install from Git
|
40
40
|
|
data/cheminee.gemspec
CHANGED
@@ -28,7 +28,9 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.required_ruby_version = ">= 3.0"
|
29
29
|
s.metadata = {}
|
30
30
|
|
31
|
-
s.add_runtime_dependency '
|
31
|
+
s.add_runtime_dependency 'faraday', '>= 1.0.1', '< 3.0'
|
32
|
+
s.add_runtime_dependency 'faraday-multipart'
|
33
|
+
s.add_runtime_dependency 'marcel'
|
32
34
|
|
33
35
|
s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
|
34
36
|
|
data/lib/cheminee/api_client.rb
CHANGED
@@ -15,7 +15,9 @@ require 'json'
|
|
15
15
|
require 'logger'
|
16
16
|
require 'tempfile'
|
17
17
|
require 'time'
|
18
|
-
require '
|
18
|
+
require 'faraday'
|
19
|
+
require 'faraday/multipart' if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
|
20
|
+
require 'marcel'
|
19
21
|
|
20
22
|
|
21
23
|
module Cheminee
|
@@ -46,39 +48,45 @@ module Cheminee
|
|
46
48
|
# Call an API with given options.
|
47
49
|
#
|
48
50
|
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
49
|
-
# the data deserialized from response body (
|
51
|
+
# the data deserialized from response body (could be nil), response status code and response headers.
|
50
52
|
def call_api(http_method, path, opts = {})
|
51
|
-
|
52
|
-
|
53
|
-
|
53
|
+
stream = nil
|
54
|
+
begin
|
55
|
+
response = connection(opts).public_send(http_method.to_sym.downcase) do |req|
|
56
|
+
request = build_request(http_method, path, req, opts)
|
57
|
+
stream = download_file(request) if opts[:return_type] == 'File' || opts[:return_type] == 'Binary'
|
58
|
+
end
|
54
59
|
|
55
|
-
|
56
|
-
|
57
|
-
|
60
|
+
if config.debugging
|
61
|
+
config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
|
62
|
+
end
|
58
63
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
response.status_message
|
64
|
+
unless response.success?
|
65
|
+
if response.status == 0 && response.respond_to?(:return_message)
|
66
|
+
# Errors from libcurl will be made visible here
|
67
|
+
fail ApiError.new(code: 0,
|
68
|
+
message: response.return_message)
|
69
|
+
else
|
70
|
+
fail ApiError.new(code: response.status,
|
71
|
+
response_headers: response.headers,
|
72
|
+
response_body: response.body),
|
73
|
+
response.reason_phrase
|
74
|
+
end
|
71
75
|
end
|
76
|
+
rescue Faraday::TimeoutError
|
77
|
+
fail ApiError.new('Connection timed out')
|
78
|
+
rescue Faraday::ConnectionFailed
|
79
|
+
fail ApiError.new('Connection failed')
|
72
80
|
end
|
73
81
|
|
74
|
-
if opts[:return_type] == 'File'
|
75
|
-
data =
|
82
|
+
if opts[:return_type] == 'File' || opts[:return_type] == 'Binary'
|
83
|
+
data = deserialize_file(response, stream)
|
76
84
|
elsif opts[:return_type]
|
77
85
|
data = deserialize(response, opts[:return_type])
|
78
86
|
else
|
79
87
|
data = nil
|
80
88
|
end
|
81
|
-
return data, response.
|
89
|
+
return data, response.status, response.headers
|
82
90
|
end
|
83
91
|
|
84
92
|
# Builds the HTTP request
|
@@ -89,46 +97,33 @@ module Cheminee
|
|
89
97
|
# @option opts [Hash] :query_params Query parameters
|
90
98
|
# @option opts [Hash] :form_params Query parameters
|
91
99
|
# @option opts [Object] :body HTTP body (JSON/XML)
|
92
|
-
# @return [
|
93
|
-
def build_request(http_method, path, opts = {})
|
100
|
+
# @return [Faraday::Request] A Faraday Request
|
101
|
+
def build_request(http_method, path, request, opts = {})
|
94
102
|
url = build_request_url(path, opts)
|
95
103
|
http_method = http_method.to_sym.downcase
|
96
104
|
|
97
105
|
header_params = @default_headers.merge(opts[:header_params] || {})
|
98
106
|
query_params = opts[:query_params] || {}
|
99
107
|
form_params = opts[:form_params] || {}
|
100
|
-
follow_location = opts[:follow_location] || true
|
101
|
-
|
102
|
-
|
103
|
-
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
104
|
-
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
|
105
|
-
|
106
|
-
req_opts = {
|
107
|
-
:method => http_method,
|
108
|
-
:headers => header_params,
|
109
|
-
:params => query_params,
|
110
|
-
:params_encoding => @config.params_encoding,
|
111
|
-
:timeout => @config.timeout,
|
112
|
-
:ssl_verifypeer => @config.verify_ssl,
|
113
|
-
:ssl_verifyhost => _verify_ssl_host,
|
114
|
-
:sslcert => @config.cert_file,
|
115
|
-
:sslkey => @config.key_file,
|
116
|
-
:verbose => @config.debugging,
|
117
|
-
:followlocation => follow_location
|
118
|
-
}
|
119
108
|
|
120
|
-
|
121
|
-
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
|
109
|
+
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
122
110
|
|
123
111
|
if [:post, :patch, :put, :delete].include?(http_method)
|
124
112
|
req_body = build_request_body(header_params, form_params, opts[:body])
|
125
|
-
|
126
|
-
|
127
|
-
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
|
113
|
+
if config.debugging
|
114
|
+
config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
|
128
115
|
end
|
129
116
|
end
|
117
|
+
request.headers = header_params
|
118
|
+
request.body = req_body
|
130
119
|
|
131
|
-
|
120
|
+
# Overload default options only if provided
|
121
|
+
request.options.params_encoder = config.params_encoder if config.params_encoder
|
122
|
+
request.options.timeout = config.timeout if config.timeout
|
123
|
+
|
124
|
+
request.url url
|
125
|
+
request.params = query_params
|
126
|
+
request
|
132
127
|
end
|
133
128
|
|
134
129
|
# Builds the HTTP request body
|
@@ -139,13 +134,16 @@ module Cheminee
|
|
139
134
|
# @return [String] HTTP body data in the form of string
|
140
135
|
def build_request_body(header_params, form_params, body)
|
141
136
|
# http form
|
142
|
-
if header_params['Content-Type'] == 'application/x-www-form-urlencoded'
|
143
|
-
|
137
|
+
if header_params['Content-Type'] == 'application/x-www-form-urlencoded'
|
138
|
+
data = URI.encode_www_form(form_params)
|
139
|
+
elsif header_params['Content-Type'] == 'multipart/form-data'
|
144
140
|
data = {}
|
145
141
|
form_params.each do |key, value|
|
146
142
|
case value
|
147
|
-
when ::File, ::
|
148
|
-
|
143
|
+
when ::File, ::Tempfile
|
144
|
+
data[key] = Faraday::FilePart.new(value.path, Marcel::MimeType.for(Pathname.new(value.path)))
|
145
|
+
when ::Array, nil
|
146
|
+
# let Faraday handle Array and nil parameters
|
149
147
|
data[key] = value
|
150
148
|
else
|
151
149
|
data[key] = value.to_s
|
@@ -159,49 +157,95 @@ module Cheminee
|
|
159
157
|
data
|
160
158
|
end
|
161
159
|
|
162
|
-
# Save response body into a file in (the defined) temporary folder, using the filename
|
163
|
-
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
164
|
-
# The response body is written to the file in chunks in order to handle files which
|
165
|
-
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
166
|
-
# process can use.
|
167
|
-
#
|
168
|
-
# @see Configuration#temp_folder_path
|
169
|
-
#
|
170
|
-
# @return [Tempfile] the tempfile generated
|
171
160
|
def download_file(request)
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
178
|
-
prefix = sanitize_filename(filename)
|
179
|
-
else
|
180
|
-
prefix = 'download-'
|
181
|
-
end
|
182
|
-
prefix = prefix + '-' unless prefix.end_with?('-')
|
183
|
-
encoding = response.body.encoding
|
184
|
-
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
185
|
-
end
|
186
|
-
request.on_body do |chunk|
|
187
|
-
chunk.force_encoding(encoding)
|
188
|
-
tempfile.write(chunk)
|
161
|
+
stream = []
|
162
|
+
|
163
|
+
# handle streaming Responses
|
164
|
+
request.options.on_data = Proc.new do |chunk, overall_received_bytes|
|
165
|
+
stream << chunk
|
189
166
|
end
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
167
|
+
|
168
|
+
stream
|
169
|
+
end
|
170
|
+
|
171
|
+
def deserialize_file(response, stream)
|
172
|
+
body = response.body
|
173
|
+
encoding = body.encoding
|
174
|
+
|
175
|
+
# reconstruct content
|
176
|
+
content = stream.join
|
177
|
+
content = content.unpack('m').join if response.headers['Content-Transfer-Encoding'] == 'binary'
|
178
|
+
content = content.force_encoding(encoding)
|
179
|
+
|
180
|
+
# return byte stream
|
181
|
+
return content if @config.return_binary_data == true
|
182
|
+
|
183
|
+
# return file instead of binary data
|
184
|
+
content_disposition = response.headers['Content-Disposition']
|
185
|
+
if content_disposition && content_disposition =~ /filename=/i
|
186
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
187
|
+
prefix = sanitize_filename(filename)
|
198
188
|
else
|
199
|
-
|
189
|
+
prefix = 'download-'
|
200
190
|
end
|
191
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
192
|
+
|
193
|
+
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
194
|
+
tempfile.write(content)
|
195
|
+
tempfile.close
|
201
196
|
|
197
|
+
config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
198
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
199
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
200
|
+
"explicitly with `tempfile.delete`"
|
202
201
|
tempfile
|
203
202
|
end
|
204
203
|
|
204
|
+
def connection(opts)
|
205
|
+
opts[:header_params]['Content-Type'] == 'multipart/form-data' ? connection_multipart : connection_regular
|
206
|
+
end
|
207
|
+
|
208
|
+
def connection_multipart
|
209
|
+
@connection_multipart ||= build_connection do |conn|
|
210
|
+
conn.request :multipart
|
211
|
+
conn.request :url_encoded
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def connection_regular
|
216
|
+
@connection_regular ||= build_connection
|
217
|
+
end
|
218
|
+
|
219
|
+
def build_connection
|
220
|
+
Faraday.new(url: config.base_url, ssl: ssl_options, proxy: config.proxy) do |conn|
|
221
|
+
basic_auth(conn)
|
222
|
+
config.configure_middleware(conn)
|
223
|
+
yield(conn) if block_given?
|
224
|
+
conn.adapter(Faraday.default_adapter)
|
225
|
+
config.configure_connection(conn)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def ssl_options
|
230
|
+
{
|
231
|
+
ca_file: config.ssl_ca_file,
|
232
|
+
verify: config.ssl_verify,
|
233
|
+
verify_mode: config.ssl_verify_mode,
|
234
|
+
client_cert: config.ssl_client_cert,
|
235
|
+
client_key: config.ssl_client_key
|
236
|
+
}
|
237
|
+
end
|
238
|
+
|
239
|
+
def basic_auth(conn)
|
240
|
+
if config.username && config.password
|
241
|
+
if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
|
242
|
+
conn.request(:authorization, :basic, config.username, config.password)
|
243
|
+
else
|
244
|
+
conn.request(:basic_auth, config.username, config.password)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
205
249
|
# Check if the given MIME is a JSON MIME.
|
206
250
|
# JSON MIME examples:
|
207
251
|
# application/json
|
@@ -116,40 +116,39 @@ module Cheminee
|
|
116
116
|
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
117
117
|
#
|
118
118
|
# @return [true, false]
|
119
|
-
attr_accessor :
|
119
|
+
attr_accessor :ssl_verify
|
120
120
|
|
121
121
|
### TLS/SSL setting
|
122
|
-
#
|
123
|
-
# Default to true.
|
122
|
+
# Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html)
|
124
123
|
#
|
125
124
|
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
126
125
|
#
|
127
|
-
|
128
|
-
attr_accessor :verify_ssl_host
|
126
|
+
attr_accessor :ssl_verify_mode
|
129
127
|
|
130
128
|
### TLS/SSL setting
|
131
129
|
# Set this to customize the certificate file to verify the peer.
|
132
130
|
#
|
133
131
|
# @return [String] the path to the certificate file
|
134
|
-
|
135
|
-
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
|
136
|
-
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
|
137
|
-
attr_accessor :ssl_ca_cert
|
132
|
+
attr_accessor :ssl_ca_file
|
138
133
|
|
139
134
|
### TLS/SSL setting
|
140
135
|
# Client certificate file (for client certificate)
|
141
|
-
attr_accessor :
|
136
|
+
attr_accessor :ssl_client_cert
|
142
137
|
|
143
138
|
### TLS/SSL setting
|
144
139
|
# Client private key file (for client certificate)
|
145
|
-
attr_accessor :
|
140
|
+
attr_accessor :ssl_client_key
|
141
|
+
|
142
|
+
### Proxy setting
|
143
|
+
# HTTP Proxy settings
|
144
|
+
attr_accessor :proxy
|
146
145
|
|
147
|
-
# Set this to customize parameters
|
148
|
-
# Default to nil.
|
146
|
+
# Set this to customize parameters encoder of array parameter.
|
147
|
+
# Default to nil. Faraday uses NestedParamsEncoder when nil.
|
149
148
|
#
|
150
|
-
# @see The
|
151
|
-
# https://github.com/
|
152
|
-
attr_accessor :
|
149
|
+
# @see The params_encoder option of Faraday. Related source code:
|
150
|
+
# https://github.com/lostisland/faraday/tree/main/lib/faraday/encoders
|
151
|
+
attr_accessor :params_encoder
|
153
152
|
|
154
153
|
|
155
154
|
attr_accessor :inject_format
|
@@ -167,12 +166,17 @@ module Cheminee
|
|
167
166
|
@api_key = {}
|
168
167
|
@api_key_prefix = {}
|
169
168
|
@client_side_validation = true
|
170
|
-
@
|
171
|
-
@
|
172
|
-
@
|
173
|
-
@
|
174
|
-
@
|
175
|
-
@
|
169
|
+
@ssl_verify = true
|
170
|
+
@ssl_verify_mode = nil
|
171
|
+
@ssl_ca_file = nil
|
172
|
+
@ssl_client_cert = nil
|
173
|
+
@ssl_client_key = nil
|
174
|
+
@middlewares = Hash.new { |h, k| h[k] = [] }
|
175
|
+
@configure_connection_blocks = []
|
176
|
+
@timeout = 60
|
177
|
+
# return data as binary instead of file
|
178
|
+
@return_binary_data = false
|
179
|
+
@params_encoder = nil
|
176
180
|
@debugging = false
|
177
181
|
@ignore_operation_servers = false
|
178
182
|
@inject_format = false
|
@@ -296,6 +300,86 @@ module Cheminee
|
|
296
300
|
url
|
297
301
|
end
|
298
302
|
|
303
|
+
# Configure Faraday connection directly.
|
304
|
+
#
|
305
|
+
# ```
|
306
|
+
# c.configure_faraday_connection do |conn|
|
307
|
+
# conn.use Faraday::HttpCache, shared_cache: false, logger: logger
|
308
|
+
# conn.response :logger, nil, headers: true, bodies: true, log_level: :debug do |logger|
|
309
|
+
# logger.filter(/(Authorization: )(.*)/, '\1[REDACTED]')
|
310
|
+
# end
|
311
|
+
# end
|
312
|
+
#
|
313
|
+
# c.configure_faraday_connection do |conn|
|
314
|
+
# conn.adapter :typhoeus
|
315
|
+
# end
|
316
|
+
# ```
|
317
|
+
#
|
318
|
+
# @param block [Proc] `#call`able object that takes one arg, the connection
|
319
|
+
def configure_faraday_connection(&block)
|
320
|
+
@configure_connection_blocks << block
|
321
|
+
end
|
322
|
+
|
323
|
+
def configure_connection(conn)
|
324
|
+
@configure_connection_blocks.each do |block|
|
325
|
+
block.call(conn)
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
# Adds middleware to the stack
|
330
|
+
def use(*middleware)
|
331
|
+
set_faraday_middleware(:use, *middleware)
|
332
|
+
end
|
333
|
+
|
334
|
+
# Adds request middleware to the stack
|
335
|
+
def request(*middleware)
|
336
|
+
set_faraday_middleware(:request, *middleware)
|
337
|
+
end
|
338
|
+
|
339
|
+
# Adds response middleware to the stack
|
340
|
+
def response(*middleware)
|
341
|
+
set_faraday_middleware(:response, *middleware)
|
342
|
+
end
|
343
|
+
|
344
|
+
# Adds Faraday middleware setting information to the stack
|
345
|
+
#
|
346
|
+
# @example Use the `set_faraday_middleware` method to set middleware information
|
347
|
+
# config.set_faraday_middleware(:request, :retry, max: 3, methods: [:get, :post], retry_statuses: [503])
|
348
|
+
# config.set_faraday_middleware(:response, :logger, nil, { bodies: true, log_level: :debug })
|
349
|
+
# config.set_faraday_middleware(:use, Faraday::HttpCache, store: Rails.cache, shared_cache: false)
|
350
|
+
# config.set_faraday_middleware(:insert, 0, FaradayMiddleware::FollowRedirects, { standards_compliant: true, limit: 1 })
|
351
|
+
# config.set_faraday_middleware(:swap, 0, Faraday::Response::Logger)
|
352
|
+
# config.set_faraday_middleware(:delete, Faraday::Multipart::Middleware)
|
353
|
+
#
|
354
|
+
# @see https://github.com/lostisland/faraday/blob/v2.3.0/lib/faraday/rack_builder.rb#L92-L143
|
355
|
+
def set_faraday_middleware(operation, key, *args, &block)
|
356
|
+
unless [:request, :response, :use, :insert, :insert_before, :insert_after, :swap, :delete].include?(operation)
|
357
|
+
fail ArgumentError, "Invalid faraday middleware operation #{operation}. Must be" \
|
358
|
+
" :request, :response, :use, :insert, :insert_before, :insert_after, :swap or :delete."
|
359
|
+
end
|
360
|
+
|
361
|
+
@middlewares[operation] << [key, args, block]
|
362
|
+
end
|
363
|
+
ruby2_keywords(:set_faraday_middleware) if respond_to?(:ruby2_keywords, true)
|
364
|
+
|
365
|
+
# Set up middleware on the connection
|
366
|
+
def configure_middleware(connection)
|
367
|
+
return if @middlewares.empty?
|
368
|
+
|
369
|
+
[:request, :response, :use, :insert, :insert_before, :insert_after, :swap].each do |operation|
|
370
|
+
next unless @middlewares.key?(operation)
|
371
|
+
|
372
|
+
@middlewares[operation].each do |key, args, block|
|
373
|
+
connection.builder.send(operation, key, *args, &block)
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
if @middlewares.key?(:delete)
|
378
|
+
@middlewares[:delete].each do |key, _args, _block|
|
379
|
+
connection.builder.delete(key)
|
380
|
+
end
|
381
|
+
end
|
382
|
+
end
|
299
383
|
|
300
384
|
end
|
301
385
|
end
|
data/lib/cheminee/version.rb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,35 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cheminee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xavier Lange
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.1
|
20
|
+
- - "<"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
22
|
+
version: '3.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
20
27
|
- - ">="
|
21
28
|
- !ruby/object:Gem::Version
|
22
29
|
version: 1.0.1
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: faraday-multipart
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
23
40
|
type: :runtime
|
24
41
|
prerelease: false
|
25
42
|
version_requirements: !ruby/object:Gem::Requirement
|
26
43
|
requirements:
|
27
|
-
- - "
|
44
|
+
- - ">="
|
28
45
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: marcel
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
30
51
|
- - ">="
|
31
52
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
33
61
|
- !ruby/object:Gem::Dependency
|
34
62
|
name: rspec
|
35
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,7 +154,7 @@ files:
|
|
126
154
|
- lib/cheminee/version.rb
|
127
155
|
- openapi-generator-config.json
|
128
156
|
- openapi.json
|
129
|
-
- pkg/cheminee-0.1.
|
157
|
+
- pkg/cheminee-0.1.35.gem
|
130
158
|
- spec/api/default_api_spec.rb
|
131
159
|
- spec/api_client_spec.rb
|
132
160
|
- spec/configuration_spec.rb
|
data/pkg/cheminee-0.1.34.gem
DELETED
Binary file
|