kapellmeister 0.7.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kapellmeister/dispatcher.rb +7 -4
- data/lib/kapellmeister/requests_extension.rb +18 -4
- data/lib/kapellmeister/version.rb +1 -1
- 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: fd1dc825909c7f1c1e835cba745c39389588c47842b66a29df5005d825fe14db
|
4
|
+
data.tar.gz: 4d39fae366656ee67ed4a286ccff9e999c546fd02ca0a4f64e32c85e69c5df68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d182a6941061d482629a104e637e5fb1df1f7726eac3bf6655386fb84408a86e678fa97a2c2541b54a57f2d3e3dff4496ea9c74ddb5a55462bbd041325db66d
|
7
|
+
data.tar.gz: 8e206010678f4c49a25f7aa30fb7e951aea7cfea898845b96a4a3e280964ebb7b6470768845d70c251ffc9f501386074638ad9030d430013980856a8b3334e45
|
@@ -2,11 +2,13 @@ require 'faraday_middleware'
|
|
2
2
|
require_relative './requests_extension'
|
3
3
|
|
4
4
|
class Kapellmeister::Dispatcher
|
5
|
-
|
6
|
-
|
5
|
+
def self.new(**args)
|
6
|
+
main_klass = self.module_parent.name.delete('::')
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
self.module_parent.requests.each do |request|
|
9
|
+
self.include Kapellmeister::RequestsExtension.request_processing(main_klass, request)
|
10
|
+
end
|
11
|
+
super(**args)
|
10
12
|
end
|
11
13
|
|
12
14
|
def self.inherited(base)
|
@@ -58,6 +60,7 @@ class Kapellmeister::Dispatcher
|
|
58
60
|
faraday.request :multipart
|
59
61
|
faraday.response :logger, logger
|
60
62
|
faraday.response :json, content_type: 'application/json; charset=utf-8'
|
63
|
+
faraday.use FaradayMiddleware::FollowRedirects, limit: 5
|
61
64
|
faraday.adapter :typhoeus do |http|
|
62
65
|
http.timeout = 20
|
63
66
|
end
|
@@ -1,12 +1,19 @@
|
|
1
1
|
module Kapellmeister::RequestsExtension
|
2
|
-
def self.request_processing
|
3
|
-
|
2
|
+
def self.request_processing(klass, (name, request_data))
|
3
|
+
mod = if Object.const_defined?("#{self}::#{klass}InstanceMethods")
|
4
|
+
const_get("#{self}::#{klass}InstanceMethods")
|
5
|
+
else
|
6
|
+
const_set("#{klass}InstanceMethods", Module.new)
|
7
|
+
end
|
8
|
+
|
9
|
+
mod.module_eval do
|
4
10
|
define_method name do |data = {}|
|
5
|
-
proc { |method:, path
|
11
|
+
proc { |method:, path: nil, body: {}, query_params: {}, mock: ''|
|
6
12
|
if (Rails.try(:env) || ENV.fetch('APP_ENV', nil)) == 'test'
|
7
13
|
return ::Kapellmeister::Base.routes_scheme_parse(mock)
|
8
14
|
end
|
9
15
|
|
16
|
+
data = query_params.compact_blank.merge(data)
|
10
17
|
valid_body?(data, body)
|
11
18
|
valid_query?(data, query_params)
|
12
19
|
|
@@ -16,6 +23,8 @@ module Kapellmeister::RequestsExtension
|
|
16
23
|
}.call(**request_data)
|
17
24
|
end
|
18
25
|
end
|
26
|
+
|
27
|
+
mod
|
19
28
|
rescue NoMethodError
|
20
29
|
raise "You need to define #{self} class with connection_by method"
|
21
30
|
end
|
@@ -23,10 +32,15 @@ end
|
|
23
32
|
|
24
33
|
def generate_full_path(original_path, data)
|
25
34
|
path = generate_path(original_path, data)
|
26
|
-
|
35
|
+
query = data.delete(:query_params)&.to_query
|
36
|
+
return "?#{query}" unless path
|
37
|
+
|
38
|
+
[path, query].compact_blank!.join('?')
|
27
39
|
end
|
28
40
|
|
29
41
|
def generate_path(original_path, data)
|
42
|
+
return nil unless original_path
|
43
|
+
|
30
44
|
original_path.split('/').map do |part|
|
31
45
|
next part unless part.include? '%<'
|
32
46
|
|
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.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DarkWater
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-schema
|