evil-client 3.0.4 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +44 -0
- data/.rubocop.yml +12 -2
- data/CHANGELOG.md +12 -0
- data/README.md +0 -3
- data/evil-client.gemspec +10 -10
- data/lib/evil/client/builder/operation.rb +1 -1
- data/lib/evil/client/builder/scope.rb +1 -1
- data/lib/evil/client/chaining.rb +2 -2
- data/lib/evil/client/connection.rb +2 -4
- data/lib/evil/client/container/operation.rb +0 -2
- data/lib/evil/client/container/scope.rb +3 -4
- data/lib/evil/client/container.rb +1 -1
- data/lib/evil/client/dictionary.rb +2 -2
- data/lib/evil/client/formatter/form.rb +2 -2
- data/lib/evil/client/formatter.rb +3 -3
- data/lib/evil/client/model.rb +4 -4
- data/lib/evil/client/names.rb +1 -0
- data/lib/evil/client/resolver.rb +2 -2
- data/lib/evil/client/schema/operation.rb +1 -1
- data/lib/evil/client/schema/scope.rb +3 -3
- data/lib/evil/client/schema.rb +1 -1
- data/lib/evil/client/settings.rb +3 -3
- data/lib/evil/client.rb +3 -3
- data/spec/features/custom_connection_spec.rb +1 -1
- data/spec/features/operation/options_spec.rb +1 -1
- data/spec/features/scope/options_spec.rb +1 -1
- data/spec/fixtures/test_client.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/builder/operation_spec.rb +3 -3
- data/spec/unit/builder/scope_spec.rb +3 -3
- data/spec/unit/client_spec.rb +2 -2
- data/spec/unit/container/operation_spec.rb +1 -1
- data/spec/unit/container/scope_spec.rb +1 -1
- data/spec/unit/container_spec.rb +1 -1
- data/spec/unit/model_spec.rb +3 -3
- data/spec/unit/rspec/stub_client_operation_spec.rb +1 -1
- data/spec/unit/settings_spec.rb +3 -3
- metadata +28 -34
- data/.travis.yml +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0f1bb73ada583b985d01256b290b26feee4bc0d27b941d860ea6b206a402f56
|
4
|
+
data.tar.gz: 9fd1634babc9613f9be5ad1b07557516ecacce23267a231a5f7306e3749303fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdf9bd8680b72312d25a3d32ea3fc70095709cb09e0ab469d30e918ba63f213910d986110cbe700e5fbcc6a8d3cc8d3129969c900cf17db04889d2fe06fba76a
|
7
|
+
data.tar.gz: 0b4ad9dc417c68949a5bb1383e8d63752c6705a9f42a298822038195f93ee17b80c83436b1c6fdcc024e1330ba4b54871fea2c84b39a518c91807514ae20ace4
|
@@ -0,0 +1,44 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- "*"
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
build:
|
13
|
+
name: Ruby ${{ matrix.ruby }}
|
14
|
+
|
15
|
+
strategy:
|
16
|
+
fail-fast: true
|
17
|
+
matrix:
|
18
|
+
ruby:
|
19
|
+
- "2.6.0"
|
20
|
+
- "3.0.0"
|
21
|
+
- "head"
|
22
|
+
|
23
|
+
runs-on: ubuntu-latest
|
24
|
+
|
25
|
+
steps:
|
26
|
+
- name: Checkout
|
27
|
+
uses: actions/checkout@v2
|
28
|
+
|
29
|
+
- name: Install dependent libraries
|
30
|
+
run: sudo apt-get install libpq-dev
|
31
|
+
|
32
|
+
- name: Install Ruby ${{ matrix.ruby }}
|
33
|
+
uses: ruby/setup-ruby@v1.61.1
|
34
|
+
with:
|
35
|
+
ruby-version: ${{ matrix.ruby }}
|
36
|
+
bundler-cache: true # 'bundle install' and cache
|
37
|
+
|
38
|
+
- name: Check code style
|
39
|
+
run: bundle exec rubocop
|
40
|
+
continue-on-error: false
|
41
|
+
|
42
|
+
- name: Run tests
|
43
|
+
run: bundle exec rake --trace
|
44
|
+
continue-on-error: false
|
data/.rubocop.yml
CHANGED
@@ -1,18 +1,25 @@
|
|
1
1
|
---
|
2
2
|
AllCops:
|
3
3
|
DisplayCopNames: true
|
4
|
-
TargetRubyVersion: 2.
|
4
|
+
TargetRubyVersion: 2.6
|
5
5
|
|
6
6
|
Lint/AmbiguousBlockAssociation:
|
7
7
|
Enabled: false
|
8
8
|
|
9
|
+
Lint/ConstantDefinitionInBlock:
|
10
|
+
Exclude:
|
11
|
+
- 'spec/**/*'
|
12
|
+
|
9
13
|
Naming/FileName:
|
10
14
|
Exclude:
|
11
15
|
- lib/evil-client.rb
|
12
16
|
|
13
|
-
Naming/
|
17
|
+
Naming/MethodParameterName:
|
14
18
|
MinNameLength: 2
|
15
19
|
|
20
|
+
Naming/VariableNumber:
|
21
|
+
Enabled: false
|
22
|
+
|
16
23
|
Metrics/BlockLength:
|
17
24
|
Enabled: false
|
18
25
|
|
@@ -28,6 +35,9 @@ Style/DateTime:
|
|
28
35
|
Style/FrozenStringLiteralComment:
|
29
36
|
Enabled: false
|
30
37
|
|
38
|
+
Style/HashSyntax:
|
39
|
+
Enabled: false
|
40
|
+
|
31
41
|
Style/ModuleFunction:
|
32
42
|
Enabled: false
|
33
43
|
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog], and this project adheres
|
5
5
|
to [Semantic Versioning].
|
6
6
|
|
7
|
+
## [3.1.0] [2022-07-04]
|
8
|
+
|
9
|
+
### Added
|
10
|
+
- Support for Ruby 3+ (@HolyWalley)
|
11
|
+
|
12
|
+
## [3.0.5] [2022-01-20]
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
- Don't remove public_send method from Scope (@mrexox)
|
16
|
+
|
7
17
|
## [3.0.4] [2019-07-10]
|
8
18
|
|
9
19
|
### Added
|
@@ -490,3 +500,5 @@ formats will be added.
|
|
490
500
|
[3.0.2]: https://github.com/evilmartians/evil-client/compare/v3.0.1...v3.0.2
|
491
501
|
[3.0.3]: https://github.com/evilmartians/evil-client/compare/v3.0.2...v3.0.3
|
492
502
|
[3.0.4]: https://github.com/evilmartians/evil-client/compare/v3.0.3...v3.0.4
|
503
|
+
[3.0.5]: https://github.com/evilmartians/evil-client/compare/v3.0.4...v3.0.5
|
504
|
+
[3.1.0]: https://github.com/evilmartians/evil-client/compare/v3.0.5...v3.1.0
|
data/README.md
CHANGED
@@ -6,7 +6,6 @@ Human-friendly DSL for writing HTTP(s) clients in Ruby
|
|
6
6
|
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
|
7
7
|
|
8
8
|
[![Gem Version][gem-badger]][gem]
|
9
|
-
[![Build Status][travis-badger]][travis]
|
10
9
|
[![Inline docs][inch-badger]][inch]
|
11
10
|
[![Documentation Status][readthedocs-badger]][readthedocs]
|
12
11
|
|
@@ -114,7 +113,5 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
114
113
|
[inch-badger]: http://inch-ci.org/github/evilmartians/evil-client.svg
|
115
114
|
[inch]: https://inch-ci.org/github/evilmartians/evil-client
|
116
115
|
[swagger]: http://swagger.io
|
117
|
-
[travis-badger]: https://img.shields.io/travis/evilmartians/evil-client/master.svg?style=flat
|
118
|
-
[travis]: https://travis-ci.org/evilmartians/evil-client
|
119
116
|
[readthedocs-badger]: https://readthedocs.org/projects/evilclient/badge/?version=latest
|
120
117
|
[readthedocs]: http://evilclient.readthedocs.io/en/latest
|
data/evil-client.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = "evil-client"
|
3
|
-
gem.version = "3.0
|
3
|
+
gem.version = "3.1.0"
|
4
4
|
gem.author = ["Andrew Kozin (nepalez)", "Ravil Bairamgalin (brainopia)"]
|
5
5
|
gem.email = ["andrew.kozin@gmail.com", "nepalez@evilmartians.com"]
|
6
6
|
gem.homepage = "https://github.com/evilmartians/evil-client"
|
@@ -11,17 +11,17 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.test_files = gem.files.grep(/^spec/)
|
12
12
|
gem.extra_rdoc_files = Dir["README.md", "LICENSE", "CHANGELOG.md"]
|
13
13
|
|
14
|
-
gem.required_ruby_version = "
|
14
|
+
gem.required_ruby_version = ">= 2.6"
|
15
15
|
|
16
|
-
gem.add_runtime_dependency "dry-initializer", ">= 2.1"
|
17
|
-
gem.add_runtime_dependency "mime-types", "
|
18
|
-
gem.add_runtime_dependency "rack", "
|
16
|
+
gem.add_runtime_dependency "dry-initializer", ">= 2.1"
|
17
|
+
gem.add_runtime_dependency "mime-types", ">= 3.1"
|
18
|
+
gem.add_runtime_dependency "rack", ">= 2"
|
19
19
|
gem.add_runtime_dependency "tram-policy", ">= 0.3.1", "< 3"
|
20
20
|
|
21
21
|
gem.add_development_dependency "rake", ">= 10"
|
22
|
-
gem.add_development_dependency "rspec", "
|
23
|
-
gem.add_development_dependency "rspec-its"
|
24
|
-
gem.add_development_dependency "rubocop"
|
25
|
-
gem.add_development_dependency "timecop"
|
26
|
-
gem.add_development_dependency "webmock"
|
22
|
+
gem.add_development_dependency "rspec", ">= 3.0"
|
23
|
+
gem.add_development_dependency "rspec-its"
|
24
|
+
gem.add_development_dependency "rubocop"
|
25
|
+
gem.add_development_dependency "timecop"
|
26
|
+
gem.add_development_dependency "webmock"
|
27
27
|
end
|
@@ -23,7 +23,7 @@ class Evil::Client
|
|
23
23
|
# @return [Evil::Client::Container::Operation]
|
24
24
|
#
|
25
25
|
def new(**options)
|
26
|
-
Container::Operation.new schema, parent.options.merge(options)
|
26
|
+
Container::Operation.new schema, **parent.options.merge(options)
|
27
27
|
end
|
28
28
|
|
29
29
|
# @!method call(options)
|
@@ -23,7 +23,7 @@ class Evil::Client
|
|
23
23
|
# @return [Evil::Client::Container::Scope]
|
24
24
|
#
|
25
25
|
def new(**options)
|
26
|
-
Container::Scope.new schema, parent.options.merge(options)
|
26
|
+
Container::Scope.new schema, **parent.options.merge(options)
|
27
27
|
end
|
28
28
|
alias_method :call, :new
|
29
29
|
alias_method :[], :new
|
data/lib/evil/client/chaining.rb
CHANGED
@@ -11,10 +11,10 @@ class Evil::Client
|
|
11
11
|
operations[name] || scopes[name]
|
12
12
|
end
|
13
13
|
|
14
|
-
def method_missing(name, *args, &block)
|
14
|
+
def method_missing(name, *args, **kwargs, &block)
|
15
15
|
return super unless respond_to_missing? name
|
16
16
|
|
17
|
-
(operations[name] || scopes[name]).call(*args)
|
17
|
+
(operations[name] || scopes[name]).call(*args, **kwargs)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -25,10 +25,8 @@ class Evil::Client
|
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
-
def open_http_connection_for(req)
|
29
|
-
Net::HTTP.start req.host, req.port, use_ssl: req.ssl
|
30
|
-
yield(http)
|
31
|
-
end
|
28
|
+
def open_http_connection_for(req, &block)
|
29
|
+
Net::HTTP.start req.host, req.port, use_ssl: req.ssl?, &block
|
32
30
|
end
|
33
31
|
|
34
32
|
def build_from(request)
|
@@ -8,7 +8,6 @@ class Evil::Client
|
|
8
8
|
#
|
9
9
|
# @return [Array]
|
10
10
|
#
|
11
|
-
# rubocop: disable Metrics/AbcSize
|
12
11
|
def call
|
13
12
|
request = Resolver::Request.call(schema, settings)
|
14
13
|
middleware = Resolver::Middleware.call(schema, settings)
|
@@ -18,6 +17,5 @@ class Evil::Client
|
|
18
17
|
|
19
18
|
Resolver::Response.call schema, settings, response
|
20
19
|
end
|
21
|
-
# rubocop: enable Metrics/AbcSize
|
22
20
|
end
|
23
21
|
end
|
@@ -9,10 +9,9 @@ class Evil::Client
|
|
9
9
|
# The collection of named sub-scope constructors
|
10
10
|
# @return [Hash<Symbol, Evil::Client::Container::Scope::Builder>]
|
11
11
|
def scopes
|
12
|
-
@scopes ||=
|
13
|
-
|
14
|
-
|
15
|
-
end
|
12
|
+
@scopes ||= schema.scopes.transform_values do |sub_schema|
|
13
|
+
Builder::Scope.new(sub_schema, settings)
|
14
|
+
end
|
16
15
|
end
|
17
16
|
|
18
17
|
# The collection of named operations constructors
|
@@ -20,8 +20,8 @@ class Evil::Client
|
|
20
20
|
|
21
21
|
# Iterates by dictionary items
|
22
22
|
# @return [Enumerator<Evil::Client::Dictionary>]
|
23
|
-
def each
|
24
|
-
block_given? ? all.each
|
23
|
+
def each(&block)
|
24
|
+
block_given? ? all.each(&block) : all.to_enum
|
25
25
|
end
|
26
26
|
|
27
27
|
# Calls the item and raises when it is not in the dictionary
|
@@ -26,9 +26,9 @@ module Evil::Client::Formatter
|
|
26
26
|
|
27
27
|
def normalize(value, *keys)
|
28
28
|
case value
|
29
|
-
when Hash
|
29
|
+
when Hash
|
30
30
|
value.flat_map { |key, val| normalize(val, *keys, key) }.join("&")
|
31
|
-
when Array
|
31
|
+
when Array
|
32
32
|
value.flat_map { |val| normalize(val, *keys, nil) }.join("&")
|
33
33
|
else
|
34
34
|
finalize(value, *keys)
|
@@ -22,7 +22,7 @@ class Evil::Client
|
|
22
22
|
return to_form(source) if format == :form
|
23
23
|
return to_text(source) if format == :text
|
24
24
|
|
25
|
-
to_multipart(source, opts)
|
25
|
+
to_multipart(source, **opts)
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
@@ -43,8 +43,8 @@ class Evil::Client
|
|
43
43
|
Form.call source
|
44
44
|
end
|
45
45
|
|
46
|
-
def to_multipart(source, opts)
|
47
|
-
Multipart.call [source], opts
|
46
|
+
def to_multipart(source, **opts)
|
47
|
+
Multipart.call [source], **opts
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/lib/evil/client/model.rb
CHANGED
@@ -91,9 +91,9 @@ class Evil::Client
|
|
91
91
|
# @param [Hash] op Model options
|
92
92
|
# @return [Evil::Client::Model]
|
93
93
|
#
|
94
|
-
def new(op
|
95
|
-
op = Hash(op).
|
96
|
-
super(op).tap { |item| in_english { policy[item].validate! } }
|
94
|
+
def new(**op)
|
95
|
+
op = Hash(op).transform_keys(&:to_sym)
|
96
|
+
super(**op).tap { |item| in_english { policy[item].validate! } }
|
97
97
|
end
|
98
98
|
alias call new
|
99
99
|
alias [] call
|
@@ -116,7 +116,7 @@ class Evil::Client
|
|
116
116
|
|
117
117
|
def extend_model(other)
|
118
118
|
other.dry_initializer.options.each do |definition|
|
119
|
-
option definition.source, definition.options
|
119
|
+
option definition.source, **definition.options
|
120
120
|
end
|
121
121
|
|
122
122
|
other.lets.each { |key, block| let(key, &block) }
|
data/lib/evil/client/names.rb
CHANGED
data/lib/evil/client/resolver.rb
CHANGED
@@ -69,11 +69,11 @@ class Evil::Client
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def __symbolize_keys__(hash)
|
72
|
-
hash.
|
72
|
+
hash.transform_keys(&:to_sym)
|
73
73
|
end
|
74
74
|
|
75
75
|
def __stringify_keys__(hash)
|
76
|
-
hash.
|
76
|
+
hash.transform_keys(&:to_s)
|
77
77
|
end
|
78
78
|
|
79
79
|
def respond_to_missing?(name, *)
|
@@ -158,7 +158,7 @@ class Evil::Client
|
|
158
158
|
# @param [Proc] block
|
159
159
|
# @return [self]
|
160
160
|
#
|
161
|
-
def response(*codes, &block)
|
161
|
+
def response(*codes, **_kwargs, &block)
|
162
162
|
codes.flatten.map(&:to_i).each do |code|
|
163
163
|
definitions[:responses][code] = block || proc { |*response| response }
|
164
164
|
end
|
@@ -20,7 +20,7 @@ class Evil::Client
|
|
20
20
|
#
|
21
21
|
# @return [Hash<Symbol, Class>]
|
22
22
|
#
|
23
|
-
def scopes
|
23
|
+
def scopes(*_args)
|
24
24
|
@__children__.reject { |_, child| child.leaf? }
|
25
25
|
end
|
26
26
|
|
@@ -28,7 +28,7 @@ class Evil::Client
|
|
28
28
|
#
|
29
29
|
# @return [Hash<[Symbol, nil], Class>]
|
30
30
|
#
|
31
|
-
def operations
|
31
|
+
def operations(*_args)
|
32
32
|
@__children__.select { |_, child| child.leaf? }
|
33
33
|
end
|
34
34
|
|
@@ -38,7 +38,7 @@ class Evil::Client
|
|
38
38
|
# @param [Proc] block The block containing definition for the subscope
|
39
39
|
# @return [self]
|
40
40
|
#
|
41
|
-
def scope(name, &block)
|
41
|
+
def scope(name, **_kwargs, &block)
|
42
42
|
key = NameError.check!(name)
|
43
43
|
TypeError.check! self, key, :scope
|
44
44
|
@__children__[key] ||= self.class.new(self, key)
|
data/lib/evil/client/schema.rb
CHANGED
data/lib/evil/client/settings.rb
CHANGED
@@ -50,9 +50,9 @@ class Evil::Client
|
|
50
50
|
# @param [Hash<#to_sym, Object>, nil] opts
|
51
51
|
# @return [Evil::Client::Settings]
|
52
52
|
#
|
53
|
-
def new(logger, op
|
53
|
+
def new(logger, **op)
|
54
54
|
logger&.debug(self) { "initializing with options #{op}..." }
|
55
|
-
super(op).tap do |item|
|
55
|
+
super(**op).tap do |item|
|
56
56
|
item.logger = logger
|
57
57
|
logger&.debug(item) { "initialized" }
|
58
58
|
end
|
@@ -93,7 +93,7 @@ class Evil::Client
|
|
93
93
|
# @return [String]
|
94
94
|
#
|
95
95
|
def inspect
|
96
|
-
number = super.match(
|
96
|
+
number = super.match(/>:([^ ]+) /)[1]
|
97
97
|
params = options.map { |k, v| "@#{k}=#{v}" }.join(", ")
|
98
98
|
number ? "#<#{self.class}:#{number} #{params}>" : super
|
99
99
|
end
|
data/lib/evil/client.rb
CHANGED
@@ -78,8 +78,8 @@ module Evil
|
|
78
78
|
schema.respond_to? name
|
79
79
|
end
|
80
80
|
|
81
|
-
def method_missing(*args, &block)
|
82
|
-
respond_to_missing?(*args) ? schema.send(*args, &block) : super
|
81
|
+
def method_missing(*args, **kwargs, &block)
|
82
|
+
respond_to_missing?(*args) ? schema.send(*args, **kwargs, &block) : super
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
@@ -152,7 +152,7 @@ module Evil
|
|
152
152
|
private
|
153
153
|
|
154
154
|
def initialize(**options)
|
155
|
-
@scope = Container::Scope.new self.class.send(:schema), options
|
155
|
+
@scope = Container::Scope.new self.class.send(:schema), **options
|
156
156
|
end
|
157
157
|
end
|
158
158
|
end
|
@@ -2,7 +2,7 @@ RSpec.describe "custom connection" do
|
|
2
2
|
let(:conn) { double call: response }
|
3
3
|
let(:response) { [200, { "Foo" => "Bar" }, ["Hello!"]] }
|
4
4
|
let(:params) { { subdomain: "europe", user: "andy", token: "foo" } }
|
5
|
-
let(:users) { Test::Client.new(params).crm(version: 4).users }
|
5
|
+
let(:users) { Test::Client.new(**params).crm(version: 4).users }
|
6
6
|
|
7
7
|
before do
|
8
8
|
load "spec/fixtures/test_client.rb"
|
@@ -2,7 +2,7 @@ RSpec.describe "operation options" do
|
|
2
2
|
before { load "spec/fixtures/test_client.rb" }
|
3
3
|
|
4
4
|
let(:params) { { subdomain: "europe", user: "andy", token: "foo", foo: 0 } }
|
5
|
-
let(:users) { Test::Client.new(params).crm(version: 4).users }
|
5
|
+
let(:users) { Test::Client.new(**params).crm(version: 4).users }
|
6
6
|
|
7
7
|
shared_examples :valid_client do |details = "properly"|
|
8
8
|
it "[assigns operation options #{details}]" do
|
@@ -2,7 +2,7 @@ RSpec.describe "scope options" do
|
|
2
2
|
before { load "spec/fixtures/test_client.rb" }
|
3
3
|
|
4
4
|
let(:params) { { subdomain: "europe", user: "andy", token: "foo", foo: 0 } }
|
5
|
-
let(:client) { Test::Client.new(params) }
|
5
|
+
let(:client) { Test::Client.new(**params) }
|
6
6
|
let(:crm) { client.crm(version: 4) }
|
7
7
|
|
8
8
|
shared_examples :valid_client do |details = "properly"|
|
@@ -29,7 +29,7 @@ module Test
|
|
29
29
|
validate { errors.add :filter_given unless name || id || email }
|
30
30
|
|
31
31
|
http_method :get
|
32
|
-
response(200) { |*res| res.last.flat_map { |item| JSON.parse(item) } }
|
32
|
+
response(200) { |*res| res.last.flat_map { |item| item&.!=("") ? JSON.parse(item) : [] } }
|
33
33
|
end
|
34
34
|
|
35
35
|
operation :fetch do
|
data/spec/spec_helper.rb
CHANGED
@@ -53,7 +53,7 @@ RSpec.describe Evil::Client::Builder::Operation do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
describe "#new" do
|
56
|
-
subject { builder.new
|
56
|
+
subject { builder.new(**options) }
|
57
57
|
|
58
58
|
it "creates operation with inherited options accepted by settings" do
|
59
59
|
expect(subject).to be_a Evil::Client::Container::Operation
|
@@ -66,7 +66,7 @@ RSpec.describe Evil::Client::Builder::Operation do
|
|
66
66
|
let(:operation) { double call: "success" }
|
67
67
|
|
68
68
|
before { allow(builder).to receive(:new) { operation } }
|
69
|
-
subject { builder.call
|
69
|
+
subject { builder.call(**options) }
|
70
70
|
|
71
71
|
it "builds and calls the operation at once" do
|
72
72
|
expect(builder).to receive(:new).with options
|
@@ -79,7 +79,7 @@ RSpec.describe Evil::Client::Builder::Operation do
|
|
79
79
|
let(:operation) { double call: "success" }
|
80
80
|
|
81
81
|
before { allow(builder).to receive(:new) { operation } }
|
82
|
-
subject { builder[options] }
|
82
|
+
subject { builder[**options] }
|
83
83
|
|
84
84
|
it "is an alias for #call" do
|
85
85
|
expect(builder).to receive(:new).with options
|
@@ -53,7 +53,7 @@ RSpec.describe Evil::Client::Builder::Scope do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
describe "#new" do
|
56
|
-
subject { builder.new
|
56
|
+
subject { builder.new(**options) }
|
57
57
|
|
58
58
|
it "creates scope with inherited options accepted by settings" do
|
59
59
|
expect(subject).to be_a Evil::Client::Container::Scope
|
@@ -63,7 +63,7 @@ RSpec.describe Evil::Client::Builder::Scope do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
describe "#call" do
|
66
|
-
subject { builder.call
|
66
|
+
subject { builder.call(**options) }
|
67
67
|
|
68
68
|
it "creates scope with inherited options accepted by settings" do
|
69
69
|
expect(subject).to be_a Evil::Client::Container::Scope
|
@@ -73,7 +73,7 @@ RSpec.describe Evil::Client::Builder::Scope do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
describe "#[]" do
|
76
|
-
subject { builder[options] }
|
76
|
+
subject { builder[**options] }
|
77
77
|
|
78
78
|
it "creates scope with inherited options accepted by settings" do
|
79
79
|
expect(subject).to be_a Evil::Client::Container::Scope
|
data/spec/unit/client_spec.rb
CHANGED
@@ -44,7 +44,7 @@ RSpec.describe Evil::Client do
|
|
44
44
|
subject { klass.scope(:users) {} }
|
45
45
|
|
46
46
|
it "updates root schema scopes" do
|
47
|
-
expect(klass.schema).to receive(:scope).with
|
47
|
+
expect(klass.schema).to receive(:scope).with(:users, any_args)
|
48
48
|
|
49
49
|
subject
|
50
50
|
end
|
@@ -54,7 +54,7 @@ RSpec.describe Evil::Client do
|
|
54
54
|
subject { klass.operation(:users) {} }
|
55
55
|
|
56
56
|
it "updates root schema scopes" do
|
57
|
-
expect(klass.schema).to receive(:operation).with
|
57
|
+
expect(klass.schema).to receive(:operation).with(:users, any_args)
|
58
58
|
|
59
59
|
subject
|
60
60
|
end
|
@@ -8,7 +8,7 @@ RSpec.describe Evil::Client::Container::Operation do
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
let(:operation) { described_class.new
|
11
|
+
let(:operation) { described_class.new(schema, nil, **opts) }
|
12
12
|
let(:connection) { Evil::Client::Connection }
|
13
13
|
let(:schema) do
|
14
14
|
double :schema,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
RSpec.describe Evil::Client::Container::Scope do
|
2
|
-
let(:scope) { described_class.new schema, nil, opts }
|
2
|
+
let(:scope) { described_class.new schema, nil, **opts }
|
3
3
|
let(:opts) { { token: "qux", id: 7, language: "en_US", name: "Joe", age: 9 } }
|
4
4
|
let(:update_schema) { double :update_schema, name: :update }
|
5
5
|
let(:admins_schema) { double :admins_schema, name: :admins }
|
data/spec/unit/container_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
RSpec.describe Evil::Client::Container do
|
2
2
|
let(:klass) { double :class }
|
3
|
-
let(:container) { described_class.new schema, logger, opts }
|
3
|
+
let(:container) { described_class.new schema, logger, **opts }
|
4
4
|
let(:logger) { Logger.new log }
|
5
5
|
let(:log) { StringIO.new }
|
6
6
|
let(:opts) do
|
data/spec/unit/model_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
RSpec.describe Evil::Client::Model do
|
2
2
|
before { class Test::Model < described_class; end }
|
3
3
|
|
4
|
-
let(:model) { klass.new(options) }
|
4
|
+
let(:model) { klass.new(**options) }
|
5
5
|
let(:klass) { Test::Model }
|
6
|
-
let(:options) { {
|
6
|
+
let(:options) { { id: 42, name: "Andrew" } }
|
7
7
|
let(:dsl_methods) do
|
8
8
|
%i[options datetime logger scope basic_auth key_auth token_auth]
|
9
9
|
end
|
@@ -64,7 +64,7 @@ RSpec.describe Evil::Client::Model do
|
|
64
64
|
klass.validate { errors.add :name_present if name.to_s == "" }
|
65
65
|
end
|
66
66
|
|
67
|
-
let(:options) { {
|
67
|
+
let(:options) { { name: "" } }
|
68
68
|
|
69
69
|
it "adds validation for an instance" do
|
70
70
|
# see spec/fixtures/locale/en.yml
|
@@ -24,7 +24,7 @@ RSpec.describe Evil::Client::RSpec, "#stub_client_operation" do
|
|
24
24
|
it "stubs the call with the original implementation" do
|
25
25
|
stub_client_operation(klass).to_call_original
|
26
26
|
|
27
|
-
expect(perform).to eq [200, {}, []]
|
27
|
+
expect(perform).to eq [200, {}, [""]]
|
28
28
|
end
|
29
29
|
|
30
30
|
it "stubs the call with StandardError" do
|
data/spec/unit/settings_spec.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
RSpec.describe Evil::Client::Settings do
|
2
|
-
let(:settings) { klass.new(logger, options) }
|
2
|
+
let(:settings) { klass.new(logger, **options) }
|
3
3
|
let(:log) { StringIO.new }
|
4
4
|
let(:logger) { Logger.new log }
|
5
5
|
let(:schema) { double :schema, to_s: "Test::Api.users.update" }
|
6
6
|
let(:klass) { described_class.for(schema) }
|
7
|
-
let(:options) { {
|
7
|
+
let(:options) { { id: 42, name: "Andrew" } }
|
8
8
|
let(:dsl_methods) do
|
9
9
|
%i[options datetime logger scope basic_auth key_auth token_auth]
|
10
10
|
end
|
@@ -93,7 +93,7 @@ RSpec.describe Evil::Client::Settings do
|
|
93
93
|
klass.validate { errors.add :name_present if name.to_s == "" }
|
94
94
|
end
|
95
95
|
|
96
|
-
let(:options) { {
|
96
|
+
let(:options) { { name: "" } }
|
97
97
|
|
98
98
|
it "adds validation for an instance" do
|
99
99
|
# see spec/fixtures/locale/en.yml
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evil-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kozin (nepalez)
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-07-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dry-initializer
|
@@ -18,9 +18,6 @@ dependencies:
|
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '2.1'
|
21
|
-
- - "<"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: '4'
|
24
21
|
type: :runtime
|
25
22
|
prerelease: false
|
26
23
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -28,35 +25,32 @@ dependencies:
|
|
28
25
|
- - ">="
|
29
26
|
- !ruby/object:Gem::Version
|
30
27
|
version: '2.1'
|
31
|
-
- - "<"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '4'
|
34
28
|
- !ruby/object:Gem::Dependency
|
35
29
|
name: mime-types
|
36
30
|
requirement: !ruby/object:Gem::Requirement
|
37
31
|
requirements:
|
38
|
-
- - "
|
32
|
+
- - ">="
|
39
33
|
- !ruby/object:Gem::Version
|
40
34
|
version: '3.1'
|
41
35
|
type: :runtime
|
42
36
|
prerelease: false
|
43
37
|
version_requirements: !ruby/object:Gem::Requirement
|
44
38
|
requirements:
|
45
|
-
- - "
|
39
|
+
- - ">="
|
46
40
|
- !ruby/object:Gem::Version
|
47
41
|
version: '3.1'
|
48
42
|
- !ruby/object:Gem::Dependency
|
49
43
|
name: rack
|
50
44
|
requirement: !ruby/object:Gem::Requirement
|
51
45
|
requirements:
|
52
|
-
- - "
|
46
|
+
- - ">="
|
53
47
|
- !ruby/object:Gem::Version
|
54
48
|
version: '2'
|
55
49
|
type: :runtime
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
52
|
requirements:
|
59
|
-
- - "
|
53
|
+
- - ">="
|
60
54
|
- !ruby/object:Gem::Version
|
61
55
|
version: '2'
|
62
56
|
- !ruby/object:Gem::Dependency
|
@@ -97,72 +91,72 @@ dependencies:
|
|
97
91
|
name: rspec
|
98
92
|
requirement: !ruby/object:Gem::Requirement
|
99
93
|
requirements:
|
100
|
-
- - "
|
94
|
+
- - ">="
|
101
95
|
- !ruby/object:Gem::Version
|
102
96
|
version: '3.0'
|
103
97
|
type: :development
|
104
98
|
prerelease: false
|
105
99
|
version_requirements: !ruby/object:Gem::Requirement
|
106
100
|
requirements:
|
107
|
-
- - "
|
101
|
+
- - ">="
|
108
102
|
- !ruby/object:Gem::Version
|
109
103
|
version: '3.0'
|
110
104
|
- !ruby/object:Gem::Dependency
|
111
105
|
name: rspec-its
|
112
106
|
requirement: !ruby/object:Gem::Requirement
|
113
107
|
requirements:
|
114
|
-
- - "
|
108
|
+
- - ">="
|
115
109
|
- !ruby/object:Gem::Version
|
116
|
-
version: '
|
110
|
+
version: '0'
|
117
111
|
type: :development
|
118
112
|
prerelease: false
|
119
113
|
version_requirements: !ruby/object:Gem::Requirement
|
120
114
|
requirements:
|
121
|
-
- - "
|
115
|
+
- - ">="
|
122
116
|
- !ruby/object:Gem::Version
|
123
|
-
version: '
|
117
|
+
version: '0'
|
124
118
|
- !ruby/object:Gem::Dependency
|
125
119
|
name: rubocop
|
126
120
|
requirement: !ruby/object:Gem::Requirement
|
127
121
|
requirements:
|
128
|
-
- - "
|
122
|
+
- - ">="
|
129
123
|
- !ruby/object:Gem::Version
|
130
|
-
version: 0
|
124
|
+
version: '0'
|
131
125
|
type: :development
|
132
126
|
prerelease: false
|
133
127
|
version_requirements: !ruby/object:Gem::Requirement
|
134
128
|
requirements:
|
135
|
-
- - "
|
129
|
+
- - ">="
|
136
130
|
- !ruby/object:Gem::Version
|
137
|
-
version: 0
|
131
|
+
version: '0'
|
138
132
|
- !ruby/object:Gem::Dependency
|
139
133
|
name: timecop
|
140
134
|
requirement: !ruby/object:Gem::Requirement
|
141
135
|
requirements:
|
142
|
-
- - "
|
136
|
+
- - ">="
|
143
137
|
- !ruby/object:Gem::Version
|
144
|
-
version: '0
|
138
|
+
version: '0'
|
145
139
|
type: :development
|
146
140
|
prerelease: false
|
147
141
|
version_requirements: !ruby/object:Gem::Requirement
|
148
142
|
requirements:
|
149
|
-
- - "
|
143
|
+
- - ">="
|
150
144
|
- !ruby/object:Gem::Version
|
151
|
-
version: '0
|
145
|
+
version: '0'
|
152
146
|
- !ruby/object:Gem::Dependency
|
153
147
|
name: webmock
|
154
148
|
requirement: !ruby/object:Gem::Requirement
|
155
149
|
requirements:
|
156
|
-
- - "
|
150
|
+
- - ">="
|
157
151
|
- !ruby/object:Gem::Version
|
158
|
-
version: '
|
152
|
+
version: '0'
|
159
153
|
type: :development
|
160
154
|
prerelease: false
|
161
155
|
version_requirements: !ruby/object:Gem::Requirement
|
162
156
|
requirements:
|
163
|
-
- - "
|
157
|
+
- - ">="
|
164
158
|
- !ruby/object:Gem::Version
|
165
|
-
version: '
|
159
|
+
version: '0'
|
166
160
|
description:
|
167
161
|
email:
|
168
162
|
- andrew.kozin@gmail.com
|
@@ -174,10 +168,10 @@ extra_rdoc_files:
|
|
174
168
|
- CHANGELOG.md
|
175
169
|
files:
|
176
170
|
- ".codeclimate.yml"
|
171
|
+
- ".github/workflows/ci.yml"
|
177
172
|
- ".gitignore"
|
178
173
|
- ".rspec"
|
179
174
|
- ".rubocop.yml"
|
180
|
-
- ".travis.yml"
|
181
175
|
- CHANGELOG.md
|
182
176
|
- Gemfile
|
183
177
|
- LICENSE.txt
|
@@ -305,16 +299,16 @@ require_paths:
|
|
305
299
|
- lib
|
306
300
|
required_ruby_version: !ruby/object:Gem::Requirement
|
307
301
|
requirements:
|
308
|
-
- - "
|
302
|
+
- - ">="
|
309
303
|
- !ruby/object:Gem::Version
|
310
|
-
version: '2.
|
304
|
+
version: '2.6'
|
311
305
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
312
306
|
requirements:
|
313
307
|
- - ">="
|
314
308
|
- !ruby/object:Gem::Version
|
315
309
|
version: '0'
|
316
310
|
requirements: []
|
317
|
-
rubygems_version: 3.
|
311
|
+
rubygems_version: 3.2.3
|
318
312
|
signing_key:
|
319
313
|
specification_version: 4
|
320
314
|
summary: Human-friendly DSL for building HTTP(s) clients in Ruby
|
data/.travis.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sudo: false
|
3
|
-
language: ruby
|
4
|
-
cache: bundler
|
5
|
-
before_install: gem install bundler --no-document
|
6
|
-
script:
|
7
|
-
- bundle exec rspec
|
8
|
-
- bundle exec rubocop
|
9
|
-
rvm:
|
10
|
-
- '2.3.0'
|
11
|
-
- ruby-head
|
12
|
-
- jruby-9.2.7.0
|
13
|
-
- jruby-head
|
14
|
-
matrix:
|
15
|
-
allow_failures:
|
16
|
-
- rvm: ruby-head
|
17
|
-
- rvm: jruby-head
|
18
|
-
- rvm: truffleruby
|