kapellmeister 0.9.9.rc2 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d59e28eecf6117e627cd0108f64e27db9331837d972d8ae9911041e7dd1c03f
4
- data.tar.gz: 6717303f7fbce49b91927ab5021312f3fe2ea761a8dcd07883d290cd91839d87
3
+ metadata.gz: eb7b158329d4dfbb447e55ad06cc9ec60c133fbb20f3fa8de4974e5f807c32af
4
+ data.tar.gz: 8e0a71af6badbb6f41327893c18a8eee1fcff3e0638b2823be50233bd30ef756
5
5
  SHA512:
6
- metadata.gz: 3296052e14e0aaf0b0553930be4ad02e8ffa102a13968fde326c1bd358274940b4afbfe2abc28a3bfc5e4cb6a60fa723d7739a1d0a332e4e303514bff2c41c44
7
- data.tar.gz: d2d0a331dc45c3e084f9c46c5fb36f75dd067d6ec140c2f00a5f7f0e9f6676bc15e5100d192e23242163e4b954fa53c92506b9e96b1ae6c2fe39fd61f1a73df0
6
+ metadata.gz: 4d79f2670f5e910f6288b5e891e7cba1901cb975307f58f01410a8a611d8e73215c073db52add6d566fe8142bdc88190ad16b816cde61bfd2f7ae7f5c92e2978
7
+ data.tar.gz: 11b6fdd130aac37875a597db56df1064ecb94ed61393325c807f1ac4a7868c68939fdfed2fd28caefd3f1c04bbbee4714dc2d6cd917b0986ea2e76f8b8836d86
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gemspec
7
7
  gem 'dry-schema'
8
8
  gem 'faraday'
9
9
  gem 'faraday-follow_redirects'
10
- gem 'faraday-cookie_jar'
10
+ gem 'faraday-multipart'
11
11
  gem 'faraday-typhoeus'
12
12
 
13
13
  # debug
data/README.md CHANGED
@@ -4,9 +4,9 @@
4
4
  ## Использование
5
5
 
6
6
  Добавьте kapellmeister в свой Gemfile:
7
- На данный момент послденяя версия 0.9.8 (Проект находится в стадии тестирования работоспособности, beta-test)
7
+ На данный момент последняя версия 0.10.0 (Проект находится в стадии тестирования работоспособности, beta-test)
8
8
  ```ruby
9
- gem 'kapellmeister', '~> 0.9.8'
9
+ gem 'kapellmeister', '~> 0.10.0'
10
10
  ```
11
11
 
12
12
  ### Добавьте новую конфигурацию для стороннего API:
@@ -58,7 +58,10 @@ foo: => Обёртка для метода
58
58
  bar: => Наименование метода
59
59
  scheme: => Описание схемы
60
60
  method: POST => Тип запроса (* обязательный параметр!)
61
- use_wrapper: true => Обёрнуть ли метод для обеспечения уникальности. По умолчанию true
61
+ wrappers: => Обёрнуть ли имя метода и/или реальный путь для обеспечения уникальности. По умолчанию true для метода, и false для пути
62
+ all: true => Можно передать ключ all, который отработает и за обёртку метода и за обёртку пути с одним значением
63
+ name: true => Этот ключ отвечает за обёртку имени метода, приоритетней над all (по умолчанию true)
64
+ path: false => Этот ключ отвечает за обёртку пути, приоритетней над all (по умолчанию false)
62
65
  path: buz => Настоящий путь (роут). Если параметра нет, то путь будет взят из наименования метода.
63
66
  body: => Dry-scheme (из набора гемов DRY) для проверки параметров. Если параметра нет, то проверки не будет.
64
67
  query_params: => Описание query-параметров. Если параметра нет, то подстановки параметров не будет.
@@ -82,7 +85,7 @@ body: DrySchema
82
85
  `query_params` — Если для запроса требуется query-параметры.
83
86
  Работают как массивы, так и руби-хэши.
84
87
  Если этот ключ не существует, то подстановки параметров и их проверки не будет.
85
- For example:
88
+ Пример:
86
89
 
87
90
  ```yaml
88
91
  query_params:
@@ -134,9 +137,9 @@ This template-service allows you to define http requests to a third party throug
134
137
  ## Usage
135
138
 
136
139
  Add kapellmeister to your Gemfile:
137
- At the moment, the latest version is 0.9.8 (The project is in the stage of performance testing, beta-test)
140
+ At the moment, the latest version is 0.10.0 (The project is in the stage of performance testing, beta-test)
138
141
  ```ruby
139
- gem 'kapellmeister', '~> 0.9.6'
142
+ gem 'kapellmeister', '~> 0.10.0'
140
143
  ```
141
144
 
142
145
  ### Add a new configuration for the third-party API:
@@ -186,7 +189,10 @@ foo: => Wrapper of the method
186
189
  bar: => Name of the method
187
190
  scheme: => Description of the scheme
188
191
  method: POST => Request type (* required)
189
- use_wrapper: true => Whether to wrap the method to ensure uniqueness. By default, true
192
+ wrappers: => Whether to wrap the method name and/or the actual path to ensure uniqueness. By default, true for the method, and false for the path
193
+ all: true => You can pass the 'all' key, which will work for both the method wrapper and the path wrapper with one value
194
+ name: true => This key is responsible for wrapping the method name, which takes precedence over 'all' key (true by default)
195
+ path: false => This key is responsible for wrapping the path, taking precedence over 'all' key (false by default)
190
196
  path: buz => The real path (route). If there is no parameter, the path will be taken from the method name.
191
197
  body: => Dry-scheme (from the set of DRY gems) to check the parameters. If there is no parameter, then there'll be no verification.
192
198
  query_params: => Description of the query parameters. If there is no parameter, then there'll be no parameter substitution.
@@ -260,4 +266,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
260
266
 
261
267
  ## Copyright
262
268
 
263
- Copyright (c) 2022 Denis Arushanov aka DarkWater
269
+ Copyright (c) 2024 Denis Arushanov aka DarkWater
@@ -29,6 +29,7 @@ Gem::Specification.new do |gem|
29
29
  gem.add_dependency 'faraday', '~> 2.10'
30
30
  gem.add_dependency 'faraday-cookie_jar', '~> 0.0.7'
31
31
  gem.add_dependency 'faraday-follow_redirects', '~> 0.3.0'
32
+ gem.add_dependency 'faraday-multipart', '~> 1.0.0'
32
33
  gem.add_dependency 'faraday-typhoeus', '~> 1.1.0'
33
34
 
34
35
  gem.add_development_dependency 'bundler', '~> 2.0', '>= 2.0.2'
@@ -47,14 +47,35 @@ end
47
47
 
48
48
  def mapping(deep_key, deep_value, key, scheme)
49
49
  old_path = deep_value[:path].presence || deep_key.to_s
50
- name = old_path.split('/').map { |part| part.gsub(/%<.*?>/, '') }.reject(&:empty?)
51
- deep_value[:path] = [key, old_path].join('/')
50
+ name = old_path.to_s.split('/').map { |part| part.gsub(/%<.*?>/, '') }.reject(&:empty?)
51
+ use_name_wrapper, use_path_wrapper = use_wrappers?(deep_value.delete(:wrappers))
52
52
 
53
- use_wrapper = deep_value.key?(:use_wrapper) ? deep_value[:use_wrapper] : true
54
- new_key = if name.size == 1
53
+ deep_value[:path] = use_path_wrapper ? [key, old_path].join('/') : old_path
54
+ new_key = if name.size == 1 && !use_name_wrapper
55
55
  deep_key
56
56
  else
57
- use_wrapper ? [name.first.presence || key, deep_key].join('_').to_sym : deep_key
57
+ use_name_wrapper ? [key, deep_key].join('_').to_sym : deep_key
58
58
  end
59
59
  scheme[new_key] = deep_value
60
60
  end
61
+
62
+ def use_wrappers?(wrappers)
63
+ default = [true, false]
64
+ return default if wrappers.nil?
65
+
66
+ if wrappers.key?(:all)
67
+ all = to_bool!(wrappers[:all])
68
+ default = [all, all]
69
+ else
70
+ default = [to_bool!(wrappers[:name]), default[1]] if wrappers.key?(:name)
71
+ default = [default[0], to_bool!(wrappers[:path])] if wrappers.key?(:path)
72
+ end
73
+
74
+ default
75
+ end
76
+
77
+ def to_bool!(value)
78
+ convert_options = { 'true' => true, true => true, 'false' => false, false => false }
79
+
80
+ convert_options[value]
81
+ end
@@ -1,4 +1,6 @@
1
1
  require 'faraday/follow_redirects'
2
+ require 'faraday/typhoeus'
3
+ require 'faraday/multipart'
2
4
  require_relative 'requests_extension'
3
5
 
4
6
  class Kapellmeister::Dispatcher
@@ -40,6 +42,7 @@ class Kapellmeister::Dispatcher
40
42
  additional_headers = data.delete(:headers) || {}
41
43
  requests_data = data.delete(:request) || {}
42
44
  data_json = data.blank? ? '' : data.to_json
45
+ additional_headers['Content-Length'] = requests_data.merge(data).to_s.bytesize
43
46
 
44
47
  generated_connection = connection(additional_headers: additional_headers, requests_data: requests_data) # rubocop:disable Style/HashSyntax (for support ruby 2.4+)
45
48
 
@@ -53,9 +56,9 @@ class Kapellmeister::Dispatcher
53
56
  end
54
57
 
55
58
  def connection(additional_headers:, requests_data:)
56
- @connection ||= ::Faraday.new(url: configuration.url,
57
- headers: headers_generate(**additional_headers),
58
- request: requests_generate(**requests_data)) do |faraday|
59
+ request = requests_generate(**requests_data)
60
+ headers = headers_generate(**additional_headers)
61
+ @connection ||= ::Faraday.new(url: configuration.url, headers: headers, request: request) do |faraday| # rubocop:disable Style/HashSyntax (for support ruby 2.4+)
59
62
  faraday.request :json, content_type: 'application/json; charset=utf-8'
60
63
  faraday.request :multipart
61
64
  faraday.response :logger, logger
@@ -1,3 +1,3 @@
1
1
  module Kapellmeister
2
- VERSION = '0.9.9.rc2'.freeze
2
+ VERSION = '0.10.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kapellmeister
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9.rc2
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DarkWater
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-15 00:00:00.000000000 Z
11
+ date: 2024-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-schema
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.3.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday-multipart
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.0.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.0.0
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: faraday-typhoeus
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -217,9 +231,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
231
  version: 2.4.2
218
232
  required_rubygems_version: !ruby/object:Gem::Requirement
219
233
  requirements:
220
- - - ">"
234
+ - - ">="
221
235
  - !ruby/object:Gem::Version
222
- version: 1.3.1
236
+ version: '0'
223
237
  requirements: []
224
238
  rubygems_version: 3.3.7
225
239
  signing_key: