unimatrix 3.3.1 → 3.3.2

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
  SHA1:
3
- metadata.gz: 855794135ee5becfbca9f3a05a06c2161d162f5f
4
- data.tar.gz: c993f1bf6e5ec5e5f349acf426aedfbf054abd32
3
+ metadata.gz: 1e4a9781565879afc0c5d8edf0efdc4291a772bc
4
+ data.tar.gz: 2c8bfda82d8c2438d8dc8368eebbdff6fada85a5
5
5
  SHA512:
6
- metadata.gz: b9ccc0ca311d3db7ddf1fb99f943fe0e2e26cfe5efc82f6552592385bd1504bed67474bdc35bf501a4bf5805c50f4b8a640b4440869cc7acbc5a200b15bd3e4d
7
- data.tar.gz: b83ffd34ed213f719a7bbad2235d75a547b877186f7c111e0852df1431584bf642e448326dc2d649fbf40f33e0f92e4d6fbec828fe2859a6be3c2a7ac9e43312
6
+ metadata.gz: 5e017c0e73f8b915f4add49d20e4597ea1e350c9410561f497c798a8794ecb58ecd311689174f50ca25e27bae36470238e67c31a91016265cf76b46c44acd760
7
+ data.tar.gz: c4afdc30cc2b46c36668cbfeb169215d37a9994a4631a61d29bc39cd7f513252e38faaa101d055f3a68ddace1fd2263459132ccdbf7457910e51115abe5e7577
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.3.1
1
+ 3.3.2
@@ -5,7 +5,9 @@ module Unimatrix::Authorization
5
5
  result = nil
6
6
  Request.new.tap do | request |
7
7
  response = request.destroy( @path, @parameters )
8
- if response.present?
8
+ if response_is_error?( response )
9
+ result = response
10
+ elsif response.present?
9
11
  result = response.resources
10
12
  end
11
13
  end
@@ -17,12 +19,16 @@ module Unimatrix::Authorization
17
19
  response = nil
18
20
  Request.new.tap do | request |
19
21
  request.get( @path, @parameters ).tap do | response |
20
- result = response.resources
21
- if block_given?
22
- case block.arity
23
- when 0; yield
24
- when 1; yield result
25
- when 2; yield result, response
22
+ if response_is_error?( response )
23
+ result = response
24
+ else
25
+ result = response.resources
26
+ if block_given?
27
+ case block.arity
28
+ when 0; yield
29
+ when 1; yield result
30
+ when 2; yield result, response
31
+ end
26
32
  end
27
33
  end
28
34
  end
@@ -35,7 +41,9 @@ module Unimatrix::Authorization
35
41
  Request.new.tap do | request |
36
42
  serializer = Unimatrix::Serializer.new( objects )
37
43
  response = request.post( @path, @parameters, serializer.serialize( node ) )
38
- if response.present?
44
+ if response_is_error?( response )
45
+ result = response
46
+ else
39
47
  result = response.resources
40
48
  if block_given?
41
49
  case block.arity
@@ -55,6 +63,10 @@ module Unimatrix::Authorization
55
63
  @parameters.deep_merge( parameters || {} )
56
64
  )
57
65
  end
66
+
67
+ protected; def response_is_error?( response )
68
+ response.is_a?( Error ) || response.is_a?( Unimatrix::Error )
69
+ end
58
70
 
59
71
  end
60
72
 
@@ -7,6 +7,11 @@ module Unimatrix::Authorization
7
7
  def initialize( default_parameters = {} )
8
8
  uri = URI( Unimatrix.configuration.authorization_url )
9
9
  @http = Net::HTTP.new( uri.host, uri.port )
10
+
11
+ timeout_limit = ( ENV[ 'TIMEOUT_LIMIT' ] || 60 ).to_i
12
+
13
+ @http.open_timeout = timeout_limit
14
+ @http.read_timeout = timeout_limit
10
15
 
11
16
  @http.use_ssl = ( uri.scheme == 'https' )
12
17
  @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -15,36 +20,24 @@ module Unimatrix::Authorization
15
20
  end
16
21
 
17
22
  def get( path, parameters = {} )
18
- response = nil
19
-
20
- begin
21
- response = Response.new(
23
+ attempt_request do
24
+ Response.new(
22
25
  @http.get( compose_request_path( path, parameters ) ),
23
26
  path
24
27
  )
25
- rescue Timeout::Error
26
- response = nil
27
28
  end
28
-
29
- response
30
29
  end
31
30
 
32
31
  def post( path, parameters = {}, body = {} )
33
- response = nil
34
-
35
- begin
32
+ attempt_request do
36
33
  request = Net::HTTP::Post.new(
37
34
  compose_request_path( path, parameters ),
38
35
  { 'Content-Type' =>'application/json' }
39
36
  )
40
37
  request.body = body.to_json
41
38
 
42
- response = Response.new( @http.request( request ), path )
43
- rescue Timeout::Error
44
- response = nil
39
+ Response.new( @http.request( request ), path )
45
40
  end
46
-
47
- response
48
41
  end
49
42
 
50
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unimatrix
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.1
4
+ version: 3.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jackson Souza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-26 00:00:00.000000000 Z
11
+ date: 2018-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport