evil-client 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +32 -14
- data/LICENSE.txt +1 -1
- data/evil-client.gemspec +1 -1
- data/lib/evil/client.rb +1 -0
- data/lib/evil/client/dsl.rb +6 -2
- data/lib/evil/client/dsl/operation.rb +1 -1
- data/lib/evil/client/dsl/security.rb +1 -1
- data/lib/evil/client/middleware/merge_security.rb +1 -1
- data/spec/features/instantiation_spec.rb +2 -2
- data/spec/features/operation_with_form_body_spec.rb +1 -1
- data/spec/features/operation_with_headers_spec.rb +1 -1
- data/spec/features/operation_with_json_body_spec.rb +1 -1
- data/spec/features/operation_with_query_spec.rb +2 -2
- data/spec/unit/evil/client/dsl/operation_spec.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d05eb1654246a3c8ebda837f8e292fa356bca35e
|
4
|
+
data.tar.gz: 9685ee8ea9bf347a54c794ca7c83b612eb206912
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09241951f999f8909d4000e5b7ec81bab248729125bdd040f23d2162ab2f8739eb55d9c4f736fc72fc63750e7ebe48a62b0b13fecc82deaa01ccbdc839c76813'
|
7
|
+
data.tar.gz: eade03b9334d111284a7c08d81a30f0bf5457a24b5ae7bec0a5461fe8f162a6e41fa9ff6833b1fc89db83a5583ab0c3999696e9cdf7cb1f9fb70d539103e93c7
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,26 +1,38 @@
|
|
1
|
-
#
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog], and this project adheres
|
5
|
+
to [Semantic Versioning].
|
6
|
+
|
7
|
+
## [0.3.3] - [2017-07-14]
|
8
|
+
|
9
|
+
On the road to v0.3.3
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
- dependency from 'securerandom' standard library (nepalez)
|
13
|
+
|
14
|
+
### Added
|
15
|
+
- variables for client settings and base_url (nepalez)
|
16
|
+
|
17
|
+
# [0.3.2] - [2016-11-29]
|
2
18
|
|
3
19
|
On the road to v0.4.0
|
4
20
|
|
5
|
-
|
21
|
+
### Fixed
|
6
22
|
- Query and body encoding (nepalez)
|
7
23
|
|
8
|
-
|
24
|
+
### Internal
|
9
25
|
- Refactoring of some DSL classes (nepalez)
|
10
26
|
|
11
|
-
[
|
12
|
-
|
13
|
-
# v0.3.1 2016-11-22
|
27
|
+
## [0.3.1] - [2016-11-22]
|
14
28
|
|
15
|
-
|
29
|
+
### Fixed
|
16
30
|
- Loading of 'json' from stdlib (nepalez)
|
17
31
|
|
18
|
-
|
32
|
+
### Internal
|
19
33
|
- Class `Evil::Client::Model` is extracted to `evil-struct` gem (nepalez)
|
20
34
|
|
21
|
-
[
|
22
|
-
|
23
|
-
# v0.3.0 2016-11-18
|
35
|
+
## [0.3.0] - [2016-11-18]
|
24
36
|
|
25
37
|
This version changes the way of processing responses. Instead of dealing
|
26
38
|
with raw rake responses, we add opinionated methods to gracefully process
|
@@ -29,8 +41,8 @@ responses from JSON or plain text.
|
|
29
41
|
In the next minor versions processors for both "form" and "file" (multipart)
|
30
42
|
formats will be added.
|
31
43
|
|
32
|
-
|
33
|
-
- Method `DSL#response` was redefined with a new signature (nepalez)
|
44
|
+
### Changed
|
45
|
+
- [BREAKING] Method `DSL#response` was redefined with a new signature (nepalez)
|
34
46
|
|
35
47
|
The method takes 2 _mandatory_ positional params: unique name and
|
36
48
|
integer status. This allows to process responses with the same status,
|
@@ -52,7 +64,7 @@ formats will be added.
|
|
52
64
|
Names (the first param) are unique. When several definitions use the same name,
|
53
65
|
only the last one will be applicable.
|
54
66
|
|
55
|
-
|
67
|
+
### Added
|
56
68
|
- Method `DSL#responses` to share options between response definitions (nepalez)
|
57
69
|
|
58
70
|
```ruby
|
@@ -70,3 +82,9 @@ formats will be added.
|
|
70
82
|
response :failure, 400, format: "json", raise: true
|
71
83
|
response :not_found, 404, format: "json", raise: true
|
72
84
|
```
|
85
|
+
|
86
|
+
[0.3.3]: https://github.com/evilmartians/evil-client/compare/v0.3.2...v0.3.3
|
87
|
+
[0.3.2]: https://github.com/evilmartians/evil-client/compare/v0.3.1...v0.3.2
|
88
|
+
[0.3.1]: https://github.com/evilmartians/evil-client/compare/v0.3.0...v0.3.1
|
89
|
+
[Keep a Changelog]: http://keepachangelog.com/
|
90
|
+
[Semantic Versioning]: http://semver.org/
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2016 Andrew Kozin (
|
3
|
+
Copyright (c) 2016-2017 Andrew Kozin (nepalez), andrew.kozin@gmail.com
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
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 = "0.3.
|
3
|
+
gem.version = "0.3.3"
|
4
4
|
gem.author = ["Andrew Kozin (nepalez)", "Ravil Bairamgalin (brainopia)"]
|
5
5
|
gem.email = "andrew.kozin@gmail.com"
|
6
6
|
gem.homepage = "https://github.com/evilmartians/evil-client"
|
data/lib/evil/client.rb
CHANGED
data/lib/evil/client/dsl.rb
CHANGED
@@ -17,7 +17,11 @@ class Evil::Client
|
|
17
17
|
|
18
18
|
# Adds [#operations] to a specific client's instances
|
19
19
|
def self.extended(klass)
|
20
|
-
klass.include Dry::Initializer.define ->
|
20
|
+
klass.include Dry::Initializer.define -> do
|
21
|
+
param :settings
|
22
|
+
param :base_url
|
23
|
+
param :operations
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
# Helper to define params and options a for a client's constructor
|
@@ -103,7 +107,7 @@ class Evil::Client
|
|
103
107
|
hash[key] = Evil::Client::Operation.new schema, connection
|
104
108
|
end
|
105
109
|
|
106
|
-
super(data)
|
110
|
+
super(settings, base_url, data)
|
107
111
|
end
|
108
112
|
|
109
113
|
private
|
@@ -72,7 +72,7 @@ module Evil::Client::DSL
|
|
72
72
|
# ==========================================================================
|
73
73
|
|
74
74
|
def __valid_format__(format)
|
75
|
-
formats = %w
|
75
|
+
formats = %w[json form]
|
76
76
|
return format.to_s if formats.include? format.to_s
|
77
77
|
raise ArgumentError.new "Invalid format #{format} for body." \
|
78
78
|
" Use one of formats: #{formats}"
|
@@ -49,7 +49,7 @@ module Evil::Client::DSL
|
|
49
49
|
# ==========================================================================
|
50
50
|
|
51
51
|
def __validate__(part)
|
52
|
-
parts = %i
|
52
|
+
parts = %i[body query headers]
|
53
53
|
return if parts.include? part
|
54
54
|
raise ArgumentError.new "Wrong part '#{part}'. Use one of parts: #{parts}"
|
55
55
|
end
|
@@ -9,7 +9,7 @@ class Evil::Client::Middleware
|
|
9
9
|
def build(env)
|
10
10
|
env.dup.tap do |hash|
|
11
11
|
security = hash.delete(:security).to_h
|
12
|
-
%i
|
12
|
+
%i[headers body query].each do |key|
|
13
13
|
next unless security[key]
|
14
14
|
hash[key] ||= {}
|
15
15
|
hash[key].update security[key]
|
@@ -30,7 +30,7 @@ RSpec.describe "instantiation" do
|
|
30
30
|
let(:client) { Test::Client.new(**options) }
|
31
31
|
|
32
32
|
it "is rejected" do
|
33
|
-
expect { client }.to raise_error(
|
33
|
+
expect { client }.to raise_error(StandardError)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -54,7 +54,7 @@ RSpec.describe "instantiation" do
|
|
54
54
|
before { options.delete :user }
|
55
55
|
|
56
56
|
it "is rejected" do
|
57
|
-
expect { client }.to raise_error(
|
57
|
+
expect { client }.to raise_error(ArgumentError)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -140,7 +140,7 @@ RSpec.describe "operation with form body" do
|
|
140
140
|
end
|
141
141
|
|
142
142
|
it "requires mandatory arguments" do
|
143
|
-
expect { operation.call bar: 2, baz: 3 }.to raise_error(
|
143
|
+
expect { operation.call bar: 2, baz: 3 }.to raise_error(ArgumentError)
|
144
144
|
end
|
145
145
|
|
146
146
|
it "applies type restrictions" do
|
@@ -61,7 +61,7 @@ RSpec.describe "operation with headers" do
|
|
61
61
|
|
62
62
|
it "requires mandatory headers" do
|
63
63
|
expect { client.operations[:clear_data].call bar: "BAR", baz: "BAZ" }
|
64
|
-
.to raise_error(
|
64
|
+
.to raise_error(ArgumentError)
|
65
65
|
end
|
66
66
|
|
67
67
|
it "applies type constraints" do
|
@@ -138,7 +138,7 @@ RSpec.describe "operation with json body" do
|
|
138
138
|
end
|
139
139
|
|
140
140
|
it "requires mandatory arguments" do
|
141
|
-
expect { operation.call bar: 2, baz: 3 }.to raise_error(
|
141
|
+
expect { operation.call bar: 2, baz: 3 }.to raise_error(ArgumentError)
|
142
142
|
end
|
143
143
|
|
144
144
|
it "applies type restrictions" do
|
@@ -65,12 +65,12 @@ RSpec.describe "operation with query" do
|
|
65
65
|
|
66
66
|
it "applies type restrictuions" do
|
67
67
|
expect { client.operations[:filter].call id: 1, name: "Joe" }
|
68
|
-
.to raise_error(
|
68
|
+
.to raise_error(ArgumentError)
|
69
69
|
end
|
70
70
|
|
71
71
|
it "supports nesting in a Rails style" do
|
72
72
|
client.operations[:search].call name: {
|
73
|
-
"first": "John", last: "Doe", middle: %w
|
73
|
+
"first": "John", last: "Doe", middle: %w[Juan Andre]
|
74
74
|
}
|
75
75
|
query = [
|
76
76
|
"name%5Bfirst%5D=John",
|
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: 0.3.
|
4
|
+
version: 0.3.3
|
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: 2017-07-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: evil-struct
|
@@ -246,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
246
246
|
version: '0'
|
247
247
|
requirements: []
|
248
248
|
rubyforge_project:
|
249
|
-
rubygems_version: 2.
|
249
|
+
rubygems_version: 2.5.2
|
250
250
|
signing_key:
|
251
251
|
specification_version: 4
|
252
252
|
summary: Human-friendly DSL for building HTTP(s) clients in Ruby
|
@@ -282,3 +282,4 @@ test_files:
|
|
282
282
|
- spec/unit/evil/client/middleware_spec.rb
|
283
283
|
- spec/unit/evil/client/operation/request_spec.rb
|
284
284
|
- spec/unit/evil/client/operation/response_spec.rb
|
285
|
+
has_rdoc:
|