almodovar 1.7.6 → 1.7.7

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: 5bf8daf20a34b735694f237e74c7d6a3dbd2d3aeb383ed8a9fb4b9fee48d14b3
4
- data.tar.gz: 946f4449c0931dc085259a6238eae7b42306264b90bba73d9ba2291b24e72918
3
+ metadata.gz: 697594700427d3065a55287788a6a398f9dafa7f067c98bfe5b432ea9704e48d
4
+ data.tar.gz: 9a74aa72c439726bbca0d9d5a04ead6b0f1e759c51746a35b1ad7cb43b35886b
5
5
  SHA512:
6
- metadata.gz: 2c815dad7020c2e24db4fdd5f8633522638cba2e9eae3c2a9d7e682902653e5c83dc2f1ee618ba6c541054af14ad3ceedc1edcf1151256415c976d05b3e5f347
7
- data.tar.gz: 5595081a995e00af88b03720c555ab573048b1b5359f461cd818e41d6e0885cf658df79bbf865c024525b415c0f81013bcbb1dfca6b1dec168b2c118f974921b
6
+ metadata.gz: eb397b25f5f8dea9e1b73907053aae819093f373a74f035f253b40121209faad5264b65530b45a5aef606393ee912af2b6796786f492a88147f1d94a310585a9
7
+ data.tar.gz: fe665afd24a05d52d126813da704dbbf48a1748be61f161de084df0c69a3d365c0fa0f1eacbf54ce74de8ad2f3639fbc44ed00ae18c57e60338d8d5d814e8322
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- =Almodovar {<img src="http://travis-ci.org/bebanjo/almodovar.png" />}[http://travis-ci.org/bebanjo/almodovar]
1
+ =Almodovar {<img src="https://github.com/bebanjo/almodovar/workflows/CI/badge.svg" />}[http://travis-ci.org/bebanjo/almodovar]
2
2
 
3
3
  Almodovar is a client for BeBanjo's Sequence & Movida API written in Ruby (it's actually a generic client which plays nice with any RESTful API following some conventions).
4
4
 
data/lib/almodovar.rb CHANGED
@@ -21,24 +21,41 @@ module Almodovar
21
21
  DEFAULT_RECEIVE_TIMEOUT = 120
22
22
 
23
23
  class << self
24
+
25
+ # default_options allows to configure some settings on the underlying HTTP client used by Almodovar:
26
+ # - send_timeout: Request sending timeout in sec. Defaults to 120
27
+ # - connect_timeout: Connect timeout in sec. Defaults to 30
28
+ # - receive_timeout: Response receiving timeout in sec. Defaults to 120
29
+ # - user_agent: User-Agent header in HTTP request. defaults to Almodovar/#{Almodovar::VERSION}
30
+ # - force_basic_auth: flag for sending Authorization header w/o getting 401 first. Useful during tests
31
+ # - headers: is for providing default headers Hash that all HTTP
32
+ # requests should have, such as custom 'X-Request-Id' header in tracing.
33
+ # As Almodovar does not expose http API, this accept a proc which will be
34
+ # evaluated per request. You can override :headers with Almodovar::HTTPClient headers method
35
+ # or using Hash parameter in HTTP request methods but this is not accessible on default Almodovar usage.
24
36
  def default_options
25
37
  default = {
26
38
  send_timeout: DEFAULT_SEND_TIMEOUT,
27
39
  connect_timeout: DEFAULT_CONNECT_TIMEOUT,
28
40
  receive_timeout: DEFAULT_RECEIVE_TIMEOUT,
29
41
  user_agent: "Almodovar/#{Almodovar::VERSION}",
30
- force_basic_auth: false
42
+ force_basic_auth: false,
43
+ headers: nil,
31
44
  }
32
45
  default.merge(@default_options || {})
33
46
  end
34
47
 
35
48
  def default_options=(options = {})
36
- @default_options = {
37
- send_timeout: options[:send_timeout],
38
- connect_timeout: options[:connect_timeout],
39
- receive_timeout: options[:receive_timeout],
40
- force_basic_auth: options[:force_basic_auth]
41
- }
49
+ @default_options ||= {}
50
+ # Only assign provided keys too keep defaults when merging
51
+ %i(send_timeout connect_timeout receive_timeout force_basic_auth headers).each do |key|
52
+ @default_options[key] = options[key] if options.has_key?(key)
53
+ end
54
+ @default_options
55
+ end
56
+
57
+ def reset_options
58
+ @default_options = nil
42
59
  end
43
60
  end
44
61
  end
@@ -38,8 +38,15 @@ module Almodovar
38
38
 
39
39
  private
40
40
 
41
- def merge_headers(headers)
42
- (self.headers ||= {}).merge(headers)
41
+ def merge_headers(req_headers)
42
+ (default_headers || {}).
43
+ merge(self.headers ||= {}).
44
+ merge(req_headers)
45
+ end
46
+
47
+ def default_headers
48
+ defaults = Almodovar::default_options[:headers] || {}
49
+ defaults = defaults.is_a?(Proc) ? defaults.call() : defaults
43
50
  end
44
51
 
45
52
  def requires_auth?
@@ -1,3 +1,3 @@
1
1
  module Almodovar
2
- VERSION = '1.7.6'
2
+ VERSION = '1.7.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: almodovar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.6
4
+ version: 1.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - BeBanjo S.L.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-10 00:00:00.000000000 Z
11
+ date: 2021-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -108,7 +108,7 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- description:
111
+ description:
112
112
  email: ballsbreaking@bebanjo.com
113
113
  executables: []
114
114
  extensions: []
@@ -130,7 +130,7 @@ homepage: http://wiki.github.com/bebanjo/almodovar/
130
130
  licenses:
131
131
  - MIT
132
132
  metadata: {}
133
- post_install_message:
133
+ post_install_message:
134
134
  rdoc_options:
135
135
  - "--main"
136
136
  - README.rdoc
@@ -147,8 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
149
  requirements: []
150
- rubygems_version: 3.0.3
151
- signing_key:
150
+ rubygems_version: 3.2.3
151
+ signing_key:
152
152
  specification_version: 4
153
153
  summary: BeBanjo API client
154
154
  test_files: []