almodovar 1.7.0 → 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
- SHA1:
3
- metadata.gz: b19f145513065282e66a50128438782214bb2bb5
4
- data.tar.gz: 03ce3b45231c091f9ca6d166ad663b7ecc073585
2
+ SHA256:
3
+ metadata.gz: 697594700427d3065a55287788a6a398f9dafa7f067c98bfe5b432ea9704e48d
4
+ data.tar.gz: 9a74aa72c439726bbca0d9d5a04ead6b0f1e759c51746a35b1ad7cb43b35886b
5
5
  SHA512:
6
- metadata.gz: b7ff66acbc2cd20268dd447587d4a8129a058b4e1f6f843ac78a082763e290b66a9df8224b9b75bea208d4482d16d4ffae874ecec068a03606d01e3c7223a16b
7
- data.tar.gz: 7574afcfa409d58a79eb69537e086d352503f8eef9fef615de384c7bbf08bdfbce560bf316f03003e042b1fb542d25085093d057c74dd2e8326b57c0db1234d6
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
 
@@ -101,6 +101,18 @@ You can use the _update_ method:
101
101
  >> job.name
102
102
  => "Wadus wadus"
103
103
 
104
+ == Updating associations
105
+
106
+ When updating a resource you can call the update method with other resources as parameters too. This allows you to create or update associations between resources (if they are supported, of course):
107
+
108
+ >> series = Almodovar::Resource("http://localhost:4001/api/title_groups/101", auth)
109
+ => <title-group> ... </title-group>
110
+ >> title = Almodovar::Resource("http://localhost:4001/api/titles/1001", auth)
111
+ => <title> ... </title>
112
+ >> title.update( title: { series: series } )
113
+
114
+ This will work the same with the create method, in case you need it.
115
+
104
116
  == Deleting resources
105
117
 
106
118
  And exactly the same with the _delete_ method:
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.0'
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.0
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: 2018-01-19 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
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.10.4
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: 1.10.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -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,9 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
149
  requirements: []
150
- rubyforge_project:
151
- rubygems_version: 2.5.1
152
- signing_key:
150
+ rubygems_version: 3.2.3
151
+ signing_key:
153
152
  specification_version: 4
154
153
  summary: BeBanjo API client
155
154
  test_files: []