kapellmeister 0.4.0 → 0.4.2

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: e5fcb6e234ddb4ca3414b4814bd755dc7d6c214888517c4ed4e15652b8458a33
4
- data.tar.gz: 140a4e2b046bb24aa0226f5508f3eafa738657d2e98eaec4d8b0848c2996356c
3
+ metadata.gz: 2c2bf7cc575b579cafe9ff8f500407e25275220340498dea77ff27d18ec73e35
4
+ data.tar.gz: 36476a2563dfcac9ad129188b050b3fc212b3cd8ff9b5b5546ee10afc845ebd6
5
5
  SHA512:
6
- metadata.gz: 8021c7f2c2ecf8aef282c9f8d71f482c989ea8db5461b3245b3690b1dba5db65eba5c3f29b2d28ed41f7f945f461e058c78f8d80a0eeaa2acb1fb73f94f706d5
7
- data.tar.gz: 2ff95fc397012c30faae716c48418ef31f8195912aa26010dc56c1a33fc3a1b26b302ae4fdeb6e891ab39b8cf1423d762ff71797b4a25ed5698a88f2ddb81ccb
6
+ metadata.gz: b62e680f94423d0822ff0a784702b023712ebf313bb40b38634808a4eb2e2d03affb5027e3d064942ba5fa475068ec42d746a9ac053d14d975923a3f85960fba
7
+ data.tar.gz: bca17d751f762904131e458423e342eea9e56b521ef6ab869d45d5ff8746aa0519c8dc501d9cf76e4372df8be6205f8559f119c6de8c4ab07ba7b0745f36126c
data/README.md CHANGED
@@ -7,7 +7,7 @@ This template-service allows you to define http requests to a third party throug
7
7
  Add kapellmeister to your Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'kapellmeister', '~> 0.0.1', require: false
10
+ gem 'kapellmeister', '~> 0.4.1'
11
11
  ```
12
12
 
13
13
  ### Add new third party configuration:
@@ -1,5 +1,5 @@
1
1
  class <%= class_name %>::Configuration
2
- attr_accessor <%= [*initialize_signatures, :path, :logger].map { |k| ":#{k}" }.join(', ') %>
2
+ attr_accessor <%= [*initialize_signatures, :ssl, :path, :logger].map { |k| ":#{k}" }.join(', ') %>
3
3
 
4
4
  def initialize
5
5
  @path = ''
@@ -0,0 +1,30 @@
1
+ class <%= class_name %>::Responder
2
+ Result = Struct.new(:success?, :response, :payload)
3
+ attr_reader :response, :payload
4
+
5
+ delegate :body, :status, to: :response
6
+
7
+ def initialize(response, **args)
8
+ @response = response
9
+ @payload = args
10
+ end
11
+
12
+ def result
13
+ error = !/2\d{2}/.match?(status.to_s)
14
+
15
+ Result.new(!error, parsed_body, { status: }.merge(payload))
16
+ rescue JSON::ParserError => e
17
+ Result.new(false, e)
18
+ end
19
+
20
+ private
21
+
22
+ def parsed_body
23
+ return body if body.length.zero?
24
+
25
+ case body
26
+ when Hash then body
27
+ else JSON.parse(body, symbolize_names: true, quirks_mode: true)
28
+ end
29
+ end
30
+ end
@@ -4,11 +4,10 @@ module <%= class_name %>
4
4
  class << self
5
5
  include ::Kapellmeister::Base
6
6
 
7
- <%- initialize_signatures.each do |attr| -%>
8
- <%= "def #{attr}" %>
9
- <%= "@#{attr} ||= configuration.#{attr}" %>
10
- <%= "end" %>
7
+ delegate <%= initialize_signatures.map { |k| ":#{k}" }.join(', ') %>, to: :configuration
11
8
 
12
- <%- end -%>
9
+ def ssl
10
+ @ssl ||= true
11
+ end
13
12
  end
14
13
  end
@@ -44,7 +44,6 @@ class Kapellmeister::Dispatcher
44
44
  ::Faraday.new(url: configuration.url,
45
45
  headers: headers_generate(**additional_headers),
46
46
  request: requests_generate(**requests_data)) do |faraday|
47
- faraday.request :authorization, *authorization
48
47
  faraday.request :json, content_type: 'application/json'
49
48
  faraday.request :multipart
50
49
  faraday.response :logger, logger
@@ -12,7 +12,7 @@ class Kapellmeister::Responder
12
12
  def result
13
13
  error = !/2\d{2}/.match?(status.to_s)
14
14
 
15
- Result.new(!error, parsed_body, { status: status }.merge(payload))
15
+ Result.new(!error, parsed_body, { status: }.merge(payload))
16
16
  rescue JSON::ParserError => e
17
17
  Result.new(false, e)
18
18
  end
@@ -20,7 +20,7 @@ class Kapellmeister::Responder
20
20
  private
21
21
 
22
22
  def parsed_body
23
- return body if body.length == 0
23
+ return body if body.empty?
24
24
 
25
25
  case body
26
26
  when Hash then body
@@ -1,3 +1,3 @@
1
1
  module Kapellmeister
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.4.2'.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.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - DarkWater
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-29 00:00:00.000000000 Z
11
+ date: 2022-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday