ezclient 0.12.0 → 0.13.0

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: e9897ff5dccafb68e0eadf415f8c65b1232d8da91f38c1dbe29bbccc7263939a
4
- data.tar.gz: 81a60d20746b3482697f49433aad567361892b98c51705c4fcddae0d7755eb32
3
+ metadata.gz: 7894472c0e1703cc7917dec4725830f0ec9f39cdde75b10e8e62131f1cc72376
4
+ data.tar.gz: c1ff86649d20f2b7f3787083bdfcd10b3817086c74ff876c7b2b8ccca2759a00
5
5
  SHA512:
6
- metadata.gz: ecbdc6a0ac6c5221128016c16ad39e1addaad7c8d79cecdb9accdb30e55c458ef39fbdfbaeac05af39ee826033392036770ed93a6375af7a28283dd97f93559d
7
- data.tar.gz: 4feb95f5c9de7581c215e23fd1ea2a54cab09cf18e593c04cdeddccc761b02af64b39ce5e33338d9c7bb39fe4ce551f8db6716dd82fb24c5cc38b3c69bb99b0e
6
+ metadata.gz: 807d13903a58fc3d39f95ca8b620cd5a578934d8925c09484f89779d283d18733d5b683955c30b6a9c95de6ee18cbef1d099c30fdb4ee7298dbd4d644e7e8cd9
7
+ data.tar.gz: d49b93cc0bf2d93febb1bbed745e332431e709500858565be75bcaec7a608f1b9c36371bff3a5092801659ecb4713f7cd8164935f765056ef429de0b8b6d23d6
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /tmp/
9
9
  .rspec_status
10
10
  Gemfile.lock
11
+ /gemfiles/*.lock
data/.rubocop.yml CHANGED
@@ -6,3 +6,4 @@ AllCops:
6
6
  TargetRubyVersion: 2.5
7
7
  Exclude:
8
8
  - vendor/**/*
9
+ - gemfiles/**/*
data/.travis.yml CHANGED
@@ -8,6 +8,10 @@ rvm:
8
8
  - 2.5
9
9
  - ruby-head
10
10
 
11
+ gemfile:
12
+ - gemfiles/http3.gemfile
13
+ - gemfiles/http4.gemfile
14
+
11
15
  before_install: gem install bundler
12
16
 
13
17
  env: SUITE="rspec"
data/README.md CHANGED
@@ -2,11 +2,10 @@
2
2
  EzClient is [HTTP gem](https://github.com/httprb/http) wrapper for easy persistent connections and more.
3
3
 
4
4
  ## Installation
5
- Add this lines to your application's Gemfile:
5
+ Add this line to your application's Gemfile:
6
6
 
7
7
  ```ruby
8
8
  gem "ezclient"
9
- gem "http", github: "httprb/http" # version 3 is not supported for now
10
9
  ```
11
10
 
12
11
  ## Usage
data/ezclient.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) }
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_runtime_dependency "http", ">= 4.0.0dev"
20
+ spec.add_runtime_dependency "http", ">= 3"
21
21
 
22
22
  spec.add_development_dependency "bundler"
23
23
  spec.add_development_dependency "coveralls"
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec path: ".."
5
+
6
+ gem "http", "~> 3.0"
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec path: ".."
5
+
6
+ gem "http", github: "httprb/http"
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ unless HTTP::Client.instance_methods.include?(:build_request)
4
+ # Backport of https://github.com/httprb/http/pull/458 for HTTP v3
5
+ class HTTP::Client
6
+ def build_request(verb, uri, opts = {})
7
+ opts = @default_options.merge(opts)
8
+ uri = make_request_uri(uri, opts)
9
+ headers = make_request_headers(opts)
10
+ body = make_request_body(opts, headers)
11
+ proxy = opts.proxy
12
+
13
+ HTTP::Request.new(
14
+ verb: verb,
15
+ uri: uri,
16
+ headers: headers,
17
+ proxy: proxy,
18
+ body: body,
19
+ auto_deflate: opts.feature(:auto_deflate),
20
+ )
21
+ end
22
+ end
23
+ end
24
+
25
+ unless HTTP::Request::Body.instance_methods.include?(:source)
26
+ # Backport for HTTP v3
27
+ class HTTP::Request::Body
28
+ def source
29
+ @body
30
+ end
31
+ end
32
+ end
@@ -85,7 +85,7 @@ class EzClient::Request
85
85
  # Only used to build proper HTTP::Request and HTTP::Options instances
86
86
  @http_client ||= begin
87
87
  http_client = client.dup
88
- http_client = http_client.timeout(timeout) if timeout
88
+ http_client = set_timeout(http_client)
89
89
  http_client = http_client.basic_auth(basic_auth) if basic_auth
90
90
  http_client
91
91
  end
@@ -149,6 +149,20 @@ class EzClient::Request
149
149
  headers
150
150
  end
151
151
 
152
+ def set_timeout(client)
153
+ return client unless timeout
154
+
155
+ timeout_args =
156
+ # for HTTP v3
157
+ if HTTP::Timeout::Global.ancestors.include?(HTTP::Timeout::PerOperation)
158
+ [:global, read: timeout]
159
+ else
160
+ [timeout]
161
+ end
162
+
163
+ client.timeout(*timeout_args)
164
+ end
165
+
152
166
  def basic_auth
153
167
  @basic_auth ||= begin
154
168
  case options[:basic_auth]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EzClient
4
- VERSION = "0.12.0"
4
+ VERSION = "0.13.0"
5
5
  end
data/lib/ezclient.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "http"
4
+ require "ezclient/http_patch"
4
5
  require "ezclient/version"
5
6
  require "ezclient/client"
6
7
  require "ezclient/request"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ezclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Smirnov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-14 00:00:00.000000000 Z
11
+ date: 2018-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.0dev
19
+ version: '3'
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: 4.0.0dev
26
+ version: '3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -152,10 +152,13 @@ files:
152
152
  - README.md
153
153
  - Rakefile
154
154
  - ezclient.gemspec
155
+ - gemfiles/http3.gemfile
156
+ - gemfiles/http4.gemfile
155
157
  - lib/ezclient.rb
156
158
  - lib/ezclient/check_options.rb
157
159
  - lib/ezclient/client.rb
158
160
  - lib/ezclient/errors.rb
161
+ - lib/ezclient/http_patch.rb
159
162
  - lib/ezclient/request.rb
160
163
  - lib/ezclient/response.rb
161
164
  - lib/ezclient/version.rb