ezclient 1.5.1 → 1.6.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: 9a7c441970d24a2206c3cd0f2f93ed5cbecb592ae8344d6a7ba449dd3d0b16f6
4
- data.tar.gz: '049c93b96e988fc0e2898161e87ff1b8cadb6282c4deb2a88d34f00ffc2cccb0'
3
+ metadata.gz: dac201c757a098759085d61cad73c4a327a5899b6b804e598d33063926de271b
4
+ data.tar.gz: 45ca2421264d131634d5f357110d05e044697294001a451ed9d8cc62b76f44cc
5
5
  SHA512:
6
- metadata.gz: 6b5a1fb31992687e9bf84f10cc1bdd4fc34b84672ce7a3e6f097778f2e07a0b8516f7c82d8a55e655dd85a7cf24de6b92484c5d7c0165f2408bcf3309ce60808
7
- data.tar.gz: e3a4e0dde38f1da48c7d18c330014e14275853cacd7e3b693ab58b5ac6735524a89d081c818f56def176a06bde8ba1714a2d0f5b4de24c4c3daac3792e59f396
6
+ metadata.gz: a920b8ae2a285ea52dc6a9332ccb8841c173cd4e578ee3a8f9a9efce38e2309023aea3886fa346179f4155a9d6795060edce1083cb6f600889251203d29246c4
7
+ data.tar.gz: 1da388891f466fa5935ca400a883bee45dc868e58e9ca2a3613a7f752805a8ade29c87bff30e0947ce221b8a555c1ff991eb3aaaea7d4604f8a73c2f3a49e471
@@ -0,0 +1,31 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+
9
+ # We want to run on external PRs, but not on our own internal PRs as they'll be run on push event
10
+ if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'umbrellio/ezclient'
11
+
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby: ["2.7", "3.0", "3.1"]
16
+
17
+ name: ${{ matrix.ruby }}
18
+
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler-cache: true
26
+
27
+ - run: bundle exec rake
28
+
29
+ - uses: coverallsapp/github-action@v1.1.2
30
+ with:
31
+ github-token: ${{ secrets.GITHUB_TOKEN }}
data/.gitignore CHANGED
@@ -7,5 +7,3 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  .rspec_status
10
- Gemfile.lock
11
- /gemfiles/*.lock
data/.rubocop.yml CHANGED
@@ -1,9 +1,11 @@
1
+ require: rubocop-rake
2
+
1
3
  inherit_gem:
2
4
  rubocop-config-umbrellio: lib/rubocop.yml
3
5
 
4
6
  AllCops:
5
7
  DisplayCopNames: true
6
- TargetRubyVersion: 2.5
8
+ TargetRubyVersion: 2.7
7
9
  Include:
8
10
  - bin/console
9
11
  - Gemfile
@@ -14,4 +16,6 @@ AllCops:
14
16
  - gemfile/**/*
15
17
  Exclude:
16
18
  - vendor/**/*
17
- - gemfiles/**/*
19
+
20
+ RSpec/Rails/HaveHttpStatus:
21
+ Enabled: false
data/Gemfile.lock ADDED
@@ -0,0 +1,156 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ezclient (1.6.0)
5
+ http (>= 4)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (7.0.4)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 1.6, < 2)
13
+ minitest (>= 5.1)
14
+ tzinfo (~> 2.0)
15
+ addressable (2.8.1)
16
+ public_suffix (>= 2.0.2, < 6.0)
17
+ ast (2.4.2)
18
+ coderay (1.1.3)
19
+ concurrent-ruby (1.1.10)
20
+ coveralls (0.7.2)
21
+ multi_json (~> 1.3)
22
+ rest-client (= 1.6.7)
23
+ simplecov (>= 0.7)
24
+ term-ansicolor (= 1.2.2)
25
+ thor (= 0.18.1)
26
+ crack (0.4.5)
27
+ rexml
28
+ diff-lcs (1.5.0)
29
+ docile (1.4.0)
30
+ domain_name (0.5.20190701)
31
+ unf (>= 0.0.5, < 1.0.0)
32
+ ffi (1.15.5)
33
+ ffi-compiler (1.0.1)
34
+ ffi (>= 1.0.0)
35
+ rake
36
+ hashdiff (1.0.1)
37
+ http (5.1.0)
38
+ addressable (~> 2.8)
39
+ http-cookie (~> 1.0)
40
+ http-form_data (~> 2.2)
41
+ llhttp-ffi (~> 0.4.0)
42
+ http-cookie (1.0.5)
43
+ domain_name (~> 0.5)
44
+ http-form_data (2.3.0)
45
+ i18n (1.12.0)
46
+ concurrent-ruby (~> 1.0)
47
+ json (2.6.2)
48
+ llhttp-ffi (0.4.0)
49
+ ffi-compiler (~> 1.0)
50
+ rake (~> 13.0)
51
+ method_source (1.0.0)
52
+ mime-types (3.4.1)
53
+ mime-types-data (~> 3.2015)
54
+ mime-types-data (3.2022.0105)
55
+ minitest (5.16.3)
56
+ multi_json (1.15.0)
57
+ parallel (1.22.1)
58
+ parser (3.1.2.1)
59
+ ast (~> 2.4.1)
60
+ pry (0.14.1)
61
+ coderay (~> 1.1)
62
+ method_source (~> 1.0)
63
+ public_suffix (5.0.0)
64
+ rack (3.0.0)
65
+ rainbow (3.1.1)
66
+ rake (13.0.6)
67
+ regexp_parser (2.6.0)
68
+ rest-client (1.6.7)
69
+ mime-types (>= 1.16)
70
+ rexml (3.2.5)
71
+ rspec (3.12.0)
72
+ rspec-core (~> 3.12.0)
73
+ rspec-expectations (~> 3.12.0)
74
+ rspec-mocks (~> 3.12.0)
75
+ rspec-core (3.12.0)
76
+ rspec-support (~> 3.12.0)
77
+ rspec-expectations (3.12.0)
78
+ diff-lcs (>= 1.2.0, < 2.0)
79
+ rspec-support (~> 3.12.0)
80
+ rspec-mocks (3.12.0)
81
+ diff-lcs (>= 1.2.0, < 2.0)
82
+ rspec-support (~> 3.12.0)
83
+ rspec-support (3.12.0)
84
+ rubocop (1.35.1)
85
+ json (~> 2.3)
86
+ parallel (~> 1.10)
87
+ parser (>= 3.1.2.1)
88
+ rainbow (>= 2.2.2, < 4.0)
89
+ regexp_parser (>= 1.8, < 3.0)
90
+ rexml (>= 3.2.5, < 4.0)
91
+ rubocop-ast (>= 1.20.1, < 2.0)
92
+ ruby-progressbar (~> 1.7)
93
+ unicode-display_width (>= 1.4.0, < 3.0)
94
+ rubocop-ast (1.23.0)
95
+ parser (>= 3.1.1.0)
96
+ rubocop-config-umbrellio (1.35.0.69)
97
+ rubocop (~> 1.35.0)
98
+ rubocop-performance (~> 1.14.0)
99
+ rubocop-rails (~> 2.15.0)
100
+ rubocop-rake (~> 0.6.0)
101
+ rubocop-rspec (~> 2.12.0)
102
+ rubocop-sequel (~> 0.3.3)
103
+ rubocop-performance (1.14.3)
104
+ rubocop (>= 1.7.0, < 2.0)
105
+ rubocop-ast (>= 0.4.0)
106
+ rubocop-rails (2.15.2)
107
+ activesupport (>= 4.2.0)
108
+ rack (>= 1.1)
109
+ rubocop (>= 1.7.0, < 2.0)
110
+ rubocop-rake (0.6.0)
111
+ rubocop (~> 1.0)
112
+ rubocop-rspec (2.12.1)
113
+ rubocop (~> 1.31)
114
+ rubocop-sequel (0.3.4)
115
+ rubocop (~> 1.0)
116
+ ruby-progressbar (1.11.0)
117
+ simplecov (0.21.2)
118
+ docile (~> 1.1)
119
+ simplecov-html (~> 0.11)
120
+ simplecov_json_formatter (~> 0.1)
121
+ simplecov-html (0.12.3)
122
+ simplecov-lcov (0.8.0)
123
+ simplecov_json_formatter (0.1.4)
124
+ term-ansicolor (1.2.2)
125
+ tins (~> 0.8)
126
+ thor (0.18.1)
127
+ tins (0.13.2)
128
+ tzinfo (2.0.5)
129
+ concurrent-ruby (~> 1.0)
130
+ unf (0.1.4)
131
+ unf_ext
132
+ unf_ext (0.0.8.2)
133
+ unicode-display_width (2.3.0)
134
+ webmock (3.18.1)
135
+ addressable (>= 2.8.0)
136
+ crack (>= 0.3.2)
137
+ hashdiff (>= 0.4.0, < 2.0.0)
138
+
139
+ PLATFORMS
140
+ ruby
141
+
142
+ DEPENDENCIES
143
+ bundler
144
+ coveralls
145
+ ezclient!
146
+ pry
147
+ rake
148
+ rspec
149
+ rubocop-config-umbrellio
150
+ rubocop-rake
151
+ simplecov
152
+ simplecov-lcov
153
+ webmock
154
+
155
+ BUNDLED WITH
156
+ 2.3.25
data/README.md CHANGED
@@ -35,6 +35,7 @@ Valid client options are:
35
35
 
36
36
  - `api_auth` – arguments for `ApiAuth.sign!` (see https://github.com/mgomes/api_auth)
37
37
  - `basic_auth` – arguments for basic authentication (either a hash with `:user` and `:pass` keys or a two-element array)
38
+ - `cookies` – a hash of cookies (or `HTTP::CookieJar` object) for requests
38
39
  - `headers` – a hash of headers for requests
39
40
  - `keep_alive` – timeout for persistent connection in seconds
40
41
  - `max_retries` – maximum number of retries in case `retry_exceptions` option is provided
@@ -44,7 +45,7 @@ Valid client options are:
44
45
  - `retry_exceptions` – an array of exception classes to retry
45
46
  - `ssl_context` – ssl context for requests (an `OpenSSL::SSL::SSLContext` instance)
46
47
  - `timeout` – timeout for requests in seconds or hash like `{ read: 5, write: 5, connect: 1 }`
47
- - `follow` - enable following redirects (`true` or hash with options – e.g. `{ max_hops: 1, strict: false}`)
48
+ - `follow` enable following redirects (`true` or hash with options – e.g. `{ max_hops: 1, strict: false}`)
48
49
 
49
50
  All these options are passed to each request made by this client but can be overriden on per-request basis.
50
51
 
@@ -118,6 +119,7 @@ request.verb # => "POST"
118
119
  request.url # => "http://example.com"
119
120
  request.body # => '{"a": 1}'
120
121
  request.headers # => { "Content-Type" => "application/json; charset=UTF-8", ... }
122
+ request.elapsed_seconds # => 0.08117745001072763
121
123
  ```
122
124
 
123
125
  ## Response object
data/ezclient.gemspec CHANGED
@@ -5,16 +5,16 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require "ezclient/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.required_ruby_version = ">= 2.5.0"
8
+ spec.required_ruby_version = ">= 2.7"
9
9
 
10
- spec.name = "ezclient"
10
+ spec.name = "ezclient"
11
11
  spec.version = EzClient::VERSION
12
12
  spec.authors = ["Yuri Smirnov"]
13
- spec.email = ["tycooon@yandex.ru", "oss@umbrellio.biz"]
13
+ spec.email = ["tycooon@yandex.ru", "oss@umbrellio.biz"]
14
14
 
15
- spec.summary = "An HTTP gem wrapper for easy persistent connections and more."
15
+ spec.summary = "An HTTP gem wrapper for easy persistent connections and more."
16
16
  spec.homepage = "https://github.com/umbrellio/ezclient"
17
- spec.license = "MIT"
17
+ spec.license = "MIT"
18
18
 
19
19
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) }
20
20
  spec.require_paths = ["lib"]
@@ -27,6 +27,8 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "rake"
28
28
  spec.add_development_dependency "rspec"
29
29
  spec.add_development_dependency "rubocop-config-umbrellio"
30
+ spec.add_development_dependency "rubocop-rake"
30
31
  spec.add_development_dependency "simplecov"
32
+ spec.add_development_dependency "simplecov-lcov"
31
33
  spec.add_development_dependency "webmock"
32
34
  end
@@ -0,0 +1,115 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ ezclient (1.0.0)
5
+ http (>= 3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.5.2)
11
+ public_suffix (>= 2.0.2, < 4.0)
12
+ ast (2.4.0)
13
+ coderay (1.1.2)
14
+ coveralls (0.7.2)
15
+ multi_json (~> 1.3)
16
+ rest-client (= 1.6.7)
17
+ simplecov (>= 0.7)
18
+ term-ansicolor (= 1.2.2)
19
+ thor (= 0.18.1)
20
+ crack (0.4.3)
21
+ safe_yaml (~> 1.0.0)
22
+ diff-lcs (1.3)
23
+ docile (1.3.0)
24
+ domain_name (0.5.20180417)
25
+ unf (>= 0.0.5, < 1.0.0)
26
+ hashdiff (0.3.7)
27
+ http (3.3.0)
28
+ addressable (~> 2.3)
29
+ http-cookie (~> 1.0)
30
+ http-form_data (~> 2.0)
31
+ http_parser.rb (~> 0.6.0)
32
+ http-cookie (1.0.3)
33
+ domain_name (~> 0.5)
34
+ http-form_data (2.1.0)
35
+ http_parser.rb (0.6.0)
36
+ json (2.1.0)
37
+ method_source (0.9.0)
38
+ mime-types (3.1)
39
+ mime-types-data (~> 3.2015)
40
+ mime-types-data (3.2016.0521)
41
+ multi_json (1.13.1)
42
+ parallel (1.12.1)
43
+ parser (2.5.1.0)
44
+ ast (~> 2.4.0)
45
+ powerpack (0.1.1)
46
+ pry (0.11.3)
47
+ coderay (~> 1.1.0)
48
+ method_source (~> 0.9.0)
49
+ public_suffix (3.0.2)
50
+ rainbow (3.0.0)
51
+ rake (12.3.1)
52
+ rest-client (1.6.7)
53
+ mime-types (>= 1.16)
54
+ rspec (3.7.0)
55
+ rspec-core (~> 3.7.0)
56
+ rspec-expectations (~> 3.7.0)
57
+ rspec-mocks (~> 3.7.0)
58
+ rspec-core (3.7.1)
59
+ rspec-support (~> 3.7.0)
60
+ rspec-expectations (3.7.0)
61
+ diff-lcs (>= 1.2.0, < 2.0)
62
+ rspec-support (~> 3.7.0)
63
+ rspec-mocks (3.7.0)
64
+ diff-lcs (>= 1.2.0, < 2.0)
65
+ rspec-support (~> 3.7.0)
66
+ rspec-support (3.7.1)
67
+ rubocop (0.52.1)
68
+ parallel (~> 1.10)
69
+ parser (>= 2.4.0.2, < 3.0)
70
+ powerpack (~> 0.1)
71
+ rainbow (>= 2.2.2, < 4.0)
72
+ ruby-progressbar (~> 1.7)
73
+ unicode-display_width (~> 1.0, >= 1.0.1)
74
+ rubocop-config-umbrellio (0.52.1.0)
75
+ rubocop (= 0.52.1)
76
+ rubocop-rspec (= 1.22.1)
77
+ rubocop-rspec (1.22.1)
78
+ rubocop (>= 0.52.1)
79
+ ruby-progressbar (1.9.0)
80
+ safe_yaml (1.0.4)
81
+ simplecov (0.16.1)
82
+ docile (~> 1.1)
83
+ json (>= 1.8, < 3)
84
+ simplecov-html (~> 0.10.0)
85
+ simplecov-html (0.10.2)
86
+ term-ansicolor (1.2.2)
87
+ tins (~> 0.8)
88
+ thor (0.18.1)
89
+ tins (0.13.2)
90
+ unf (0.1.4)
91
+ unf_ext
92
+ unf_ext (0.0.7.5)
93
+ unicode-display_width (1.3.2)
94
+ webmock (3.3.0)
95
+ addressable (>= 2.3.6)
96
+ crack (>= 0.3.2)
97
+ hashdiff
98
+
99
+ PLATFORMS
100
+ ruby
101
+
102
+ DEPENDENCIES
103
+ bundler
104
+ coveralls
105
+ ezclient!
106
+ http (~> 3.0)
107
+ pry
108
+ rake
109
+ rspec
110
+ rubocop-config-umbrellio
111
+ simplecov
112
+ webmock
113
+
114
+ BUNDLED WITH
115
+ 1.16.6
@@ -6,6 +6,7 @@ module EzClient
6
6
 
7
7
  def initialize(response)
8
8
  self.response = response
9
+ super
9
10
  end
10
11
 
11
12
  def message
@@ -10,7 +10,7 @@ class EzClient::Request
10
10
  query
11
11
  ].freeze
12
12
 
13
- attr_accessor :verb, :url, :options
13
+ attr_accessor :verb, :url, :options, :elapsed_seconds
14
14
 
15
15
  def initialize(verb, url, options)
16
16
  self.verb = verb.to_s.upcase
@@ -101,6 +101,7 @@ class EzClient::Request
101
101
  end
102
102
 
103
103
  def perform_request
104
+ perform_started_at = EzClient.get_time
104
105
  with_retry do
105
106
  # Use original client so that connection can be reused
106
107
  res = client.perform(http_request, http_options)
@@ -110,6 +111,8 @@ class EzClient::Request
110
111
  client.perform(request, http_options)
111
112
  end
112
113
  end
114
+ ensure
115
+ self.elapsed_seconds = EzClient.get_time - perform_started_at
113
116
  end
114
117
 
115
118
  def with_retry(&block)
@@ -198,7 +201,7 @@ class EzClient::Request
198
201
  end
199
202
 
200
203
  def basic_auth
201
- @basic_auth ||= begin
204
+ @basic_auth ||=
202
205
  case options[:basic_auth]
203
206
  when Array
204
207
  user, password = options[:basic_auth]
@@ -206,6 +209,5 @@ class EzClient::Request
206
209
  when Hash
207
210
  options[:basic_auth]
208
211
  end
209
- end
210
212
  end
211
213
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EzClient
4
- VERSION = "1.5.1"
4
+ VERSION = "1.6.0"
5
5
  end
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: 1.5.1
4
+ version: 1.6.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: 2020-07-31 00:00:00.000000000 Z
11
+ date: 2022-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: simplecov
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +136,20 @@ dependencies:
122
136
  - - ">="
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov-lcov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
125
153
  - !ruby/object:Gem::Dependency
126
154
  name: webmock
127
155
  requirement: !ruby/object:Gem::Requirement
@@ -144,11 +172,12 @@ executables: []
144
172
  extensions: []
145
173
  extra_rdoc_files: []
146
174
  files:
175
+ - ".github/workflows/ci.yml"
147
176
  - ".gitignore"
148
177
  - ".rspec"
149
178
  - ".rubocop.yml"
150
- - ".travis.yml"
151
179
  - Gemfile
180
+ - Gemfile.lock
152
181
  - LICENSE.txt
153
182
  - README.md
154
183
  - Rakefile
@@ -156,6 +185,7 @@ files:
156
185
  - bin/rspec
157
186
  - ezclient.gemspec
158
187
  - gemfiles/http3.gemfile
188
+ - gemfiles/http3.gemfile.lock
159
189
  - lib/ezclient.rb
160
190
  - lib/ezclient/check_options.rb
161
191
  - lib/ezclient/client.rb
@@ -177,14 +207,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
207
  requirements:
178
208
  - - ">="
179
209
  - !ruby/object:Gem::Version
180
- version: 2.5.0
210
+ version: '2.7'
181
211
  required_rubygems_version: !ruby/object:Gem::Requirement
182
212
  requirements:
183
213
  - - ">="
184
214
  - !ruby/object:Gem::Version
185
215
  version: '0'
186
216
  requirements: []
187
- rubygems_version: 3.1.2
217
+ rubygems_version: 3.3.25
188
218
  signing_key:
189
219
  specification_version: 4
190
220
  summary: An HTTP gem wrapper for easy persistent connections and more.
data/.travis.yml DELETED
@@ -1,17 +0,0 @@
1
- language: ruby
2
-
3
- os: linux
4
-
5
- dist: xenial
6
-
7
- before_install: gem install bundler
8
-
9
- jobs:
10
- fast_finish: true
11
- include:
12
- - rvm: 2.5
13
- - rvm: 2.6
14
- - rvm: 2.7
15
- - rvm: ruby-head
16
- allow_failures:
17
- - rvm: ruby-head