ezclient 0.11.0 → 0.12.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: 6d9f110bfae1ffb37a3ed9bdeb162487717a243178175822b9e0152df2533288
4
- data.tar.gz: 7f1380b423969a1101648fa5017f3e70c3ffbff774156068337fb839cab5854d
3
+ metadata.gz: e9897ff5dccafb68e0eadf415f8c65b1232d8da91f38c1dbe29bbccc7263939a
4
+ data.tar.gz: 81a60d20746b3482697f49433aad567361892b98c51705c4fcddae0d7755eb32
5
5
  SHA512:
6
- metadata.gz: d2bf1f8d239320d4bc4b8a57b0d23208ec3700922eb4b2fe00cac386efb69ecc0961da46695697f2b9fc3aaa642f3f8fe47992f9cfa545a4aa971db4253b69d4
7
- data.tar.gz: 49fb747c452aff9168492439f94324f911e8389ead521037f54e9480971394aeeca8ef90867542e8ee448ec6289c896be2bcd22b2a33ab0f332916b8eb795d8c
6
+ metadata.gz: ecbdc6a0ac6c5221128016c16ad39e1addaad7c8d79cecdb9accdb30e55c458ef39fbdfbaeac05af39ee826033392036770ed93a6375af7a28283dd97f93559d
7
+ data.tar.gz: 4feb95f5c9de7581c215e23fd1ea2a54cab09cf18e593c04cdeddccc761b02af64b39ce5e33338d9c7bb39fe4ce551f8db6716dd82fb24c5cc38b3c69bb99b0e
@@ -68,11 +68,14 @@ class EzClient::Request
68
68
 
69
69
  def http_request
70
70
  @http_request ||= begin
71
- # RUBY25: Hash#slice
72
- opts = options.select { |key| [:json, :body, :headers].include?(key) }
71
+ opts = {}
72
+
73
73
  opts[verb == "GET" ? :params : :form] = options[:params]
74
+ opts[:json] = options[:json] if options[:json]
75
+ opts[:body] = options[:body] if options[:body]
74
76
  opts[:params] = options[:query] if options[:query]
75
77
  opts[:form] = options[:form] if options[:form]
78
+ opts[:headers] = prepare_headers(options[:headers])
76
79
 
77
80
  http_client.build_request(verb, url, opts)
78
81
  end
@@ -140,6 +143,12 @@ class EzClient::Request
140
143
  options[:max_retries] || 1
141
144
  end
142
145
 
146
+ def prepare_headers(headers)
147
+ headers = HTTP::Headers.coerce(headers)
148
+ headers[:user_agent] ||= "ezclient/#{EzClient::VERSION}"
149
+ headers
150
+ end
151
+
143
152
  def basic_auth
144
153
  @basic_auth ||= begin
145
154
  case options[:basic_auth]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EzClient
4
- VERSION = "0.11.0"
4
+ VERSION = "0.12.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: 0.11.0
4
+ version: 0.12.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-02-26 00:00:00.000000000 Z
11
+ date: 2018-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http