rb-net_http-client 1.2.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/client/client.rb +1 -1
- data/lib/client/schema.rb +31 -36
- data/lib/core/core.rb +1 -7
- data/lib/request/request.rb +1 -1
- data/lib/request/schema.rb +11 -12
- data/lib/version.rb +1 -1
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4438fbea7afb62ae8feba9e90879dfdadfa98a06193d784d1e93787048a2843
|
4
|
+
data.tar.gz: 7d5b6582cafe859823266c6b1309f17acbb1bb11c5d6f620fbf72bc721f1989d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d5c8e21cfc19583e1eb03bba0f87c643d70d59ca33a47496b151712a37e0f1ef3199457f9e5182e7caabea76f8d7ae980b6b7d84d53aee327fb0c3e2212d6a9
|
7
|
+
data.tar.gz: 35397ca1cc7295f412dbc5a4fab454f97d24e9bc96c61b6bcff6138696e161cc3b3ab44f57738f129b0b78b5e735df1748bd27622e4dadef073586bf8ca028dd
|
data/lib/client/client.rb
CHANGED
@@ -33,7 +33,7 @@ module NetHTTP
|
|
33
33
|
|
34
34
|
def initialize(opts = {})
|
35
35
|
send('logger=', opts[:logger])
|
36
|
-
schema_results = Core.schema_validation(opts, NetHTTP::Client::Schema) unless opts[:enforce_schema_validation] == false
|
36
|
+
schema_results = Core.schema_validation(opts, NetHTTP::Client::Schema.new) unless opts[:enforce_schema_validation] == false
|
37
37
|
unless schema_results.nil?
|
38
38
|
logger.debug("NetHTTP::Client::SchemaError -> #{schema_results}")
|
39
39
|
raise NetHTTP::Client::SchemaError.new(schema_results.to_s)
|
data/lib/client/schema.rb
CHANGED
@@ -4,47 +4,42 @@ require 'dry-validation'
|
|
4
4
|
|
5
5
|
module NetHTTP
|
6
6
|
class Client
|
7
|
-
Schema
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
class Schema < Dry::Validation::Contract
|
8
|
+
schema do
|
9
|
+
optional(:ca_file).value(:string).filled
|
10
|
+
optional(:host).value(:string)
|
11
|
+
optional(:logger).filled
|
12
|
+
optional(:open_timeout).value(:integer).filled
|
13
|
+
optional(:path).value(:string)
|
14
|
+
optional(:port).value(:integer)
|
15
|
+
optional(:pkcs12_file).value(:string).filled
|
16
|
+
optional(:pkcs12_passphrase).value(:string).filled
|
17
|
+
optional(:proxy_uri_host).value(:string)
|
18
|
+
optional(:proxy_uri_path).value(:string)
|
19
|
+
optional(:proxy_uri_port).value(:integer)
|
20
|
+
optional(:proxy_uri_scheme).value(:string)
|
21
|
+
optional(:proxy_uri).value(:string).filled
|
22
|
+
optional(:proxy_url).value(:string).filled
|
23
|
+
optional(:query).value(:string).filled
|
24
|
+
optional(:read_timeout).value(:integer).filled
|
25
|
+
optional(:scheme).value(:string)
|
26
|
+
optional(:ssl_path).value(:string).filled
|
27
|
+
optional(:uri).value(:string)
|
28
|
+
optional(:url).value(:string)
|
29
|
+
optional(:use_ssl)
|
30
|
+
optional(:verify_mode).filled
|
16
31
|
end
|
17
32
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
optional(:open_timeout).filled(type?: Integer)
|
22
|
-
optional(:path).maybe(type?: String)
|
23
|
-
optional(:port).maybe(type?: Integer)
|
24
|
-
optional(:pkcs12_file).filled(type?: String)
|
25
|
-
optional(:pkcs12_passphrase).filled(type?: String)
|
26
|
-
optional(:proxy_uri_host).maybe(type?: String)
|
27
|
-
optional(:proxy_uri_path).maybe(type?: String)
|
28
|
-
optional(:proxy_uri_port).maybe(type?: Integer)
|
29
|
-
optional(:proxy_uri_scheme).maybe(type?: String)
|
30
|
-
optional(:proxy_uri).filled(type?: String)
|
31
|
-
optional(:proxy_url).filled(type?: String)
|
32
|
-
optional(:query).filled(type?: String)
|
33
|
-
optional(:read_timeout).filled(type?: Integer)
|
34
|
-
optional(:scheme).maybe(type?: String)
|
35
|
-
optional(:ssl_path).filled(type?: String)
|
36
|
-
optional(:uri).maybe(type?: String)
|
37
|
-
optional(:url).maybe(type?: String)
|
38
|
-
optional(:use_ssl).filled(included_in?: true_or_false)
|
39
|
-
optional(:verify_mode).filled
|
33
|
+
rule(:uri, :url, :host) do
|
34
|
+
key.failure('uri, url, & host cannot all be nil') if (values[:uri].nil? && values[:url].nil? && values[:host].nil?)
|
35
|
+
end
|
40
36
|
|
41
|
-
rule(
|
42
|
-
|
37
|
+
rule(:uri, :url, :scheme, :port) do
|
38
|
+
key.failure('if uri and url are nil, scheme or port cannot be nil') if (values[:uri].nil? && values[:url].nil? && (values[:scheme].nil? || values[:port].nil?))
|
43
39
|
end
|
44
40
|
|
45
|
-
rule(
|
46
|
-
|
47
|
-
uri.empty?.then(url.empty?.then(port.empty?.then(scheme.filled?)))
|
41
|
+
rule(:use_ssl) do
|
42
|
+
key.failure('use_ssl must be either true or false') if (!values[:use_ssl].nil? && values[:use_ssl].class != (FalseClass || TrueClass))
|
48
43
|
end
|
49
44
|
end
|
50
45
|
|
data/lib/core/core.rb
CHANGED
data/lib/request/request.rb
CHANGED
@@ -167,7 +167,7 @@ module NetHTTP
|
|
167
167
|
end
|
168
168
|
|
169
169
|
def request_opts(opts)
|
170
|
-
schema_results = Core.schema_validation(opts, NetHTTP::Request::Schema) unless opts[:enforce_schema_validation] == false
|
170
|
+
schema_results = Core.schema_validation(opts, NetHTTP::Request::Schema.new) unless opts[:enforce_schema_validation] == false
|
171
171
|
unless schema_results.nil?
|
172
172
|
logger.debug("NetHTTP::Request::SchemaError -> #{schema_results}")
|
173
173
|
raise NetHTTP::Request::SchemaError.new(schema_results.to_s)
|
data/lib/request/schema.rb
CHANGED
@@ -4,20 +4,19 @@ require 'dry-validation'
|
|
4
4
|
|
5
5
|
module NetHTTP
|
6
6
|
class Request
|
7
|
-
Schema
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
class Schema < Dry::Validation::Contract
|
8
|
+
schema do
|
9
|
+
required(:method).value(:string).filled
|
10
|
+
optional(:headers).value(:hash)
|
11
|
+
optional(:body)
|
12
|
+
optional(:query).filled
|
13
|
+
optional(:uri).value(:string).filled
|
14
|
+
optional(:url).value(:string).filled
|
15
|
+
optional(:path).value(:string).filled
|
12
16
|
end
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
optional(:body).maybe
|
17
|
-
optional(:query).filled
|
18
|
-
|
19
|
-
rule(if_url_and_uri_are_nil_must_provide_path: [:uri, :url, :path]) do |uri, url, path|
|
20
|
-
uri.empty?.then(url.empty?.then(path.filled?))
|
18
|
+
rule(:uri, :url, :path) do
|
19
|
+
key.failure('uri, url, & path cannot all be nil') if (values[:uri].nil? && values[:url].nil? && values[:path].nil?)
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb-net_http-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bostian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: dry-validation
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: nokogiri
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -279,7 +279,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
279
279
|
- !ruby/object:Gem::Version
|
280
280
|
version: '0'
|
281
281
|
requirements: []
|
282
|
-
rubygems_version: 3.
|
282
|
+
rubygems_version: 3.1.2
|
283
283
|
signing_key:
|
284
284
|
specification_version: 4
|
285
285
|
summary: A Simple Ruby HTTP Client
|