esi 0.4.12 → 0.4.13.pre.alpa2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68e387404646d212d17d199025c513524eddd55bddf55e78105974b7245c0080
4
- data.tar.gz: 092ee6893b9613c381be0475e75e9b8611f567450e709ecc83403e80d65c9011
3
+ metadata.gz: bcaffc70bd2847f7ae948e5b7ff8115e317c5a9b0730cd08851241cfcaf209b2
4
+ data.tar.gz: f4532b5f6e8e56d6989f69314ca0ec76b7b0ae662a85cfc70a7cae5072bfdf77
5
5
  SHA512:
6
- metadata.gz: 12fffec327434b1238085b155ac499156883f2d1378ac1dd40156a7f517e50fabf95bea835f1c18b062313201bd205658182ca39cac9061e2b78ae8df7eee39b
7
- data.tar.gz: 6acc3aeaca298f0b226a1b132d6b0e8834fcd5acd60f663aedec57baa434ca363cf633205f7cdf45fb95415fdadc9dca631ff27125da375df048f4b019f767ae
6
+ metadata.gz: 6ac2860625402b608aeb7e0de0740a0e2a4337215d421d53ced0269fb88e723c7c152a24262b0595801aa4842df4c803b8c0cb7832f353478e3592b457b19f67
7
+ data.tar.gz: 60cfe7052b01428894d71b94d68470225679dc067173b6a2e7bec3eab2135576a43b4c3917e1084265fb4d9864dbed225e2be9bb2f8e942b7120c0805d206945
data/lib/esi/client.rb CHANGED
@@ -25,11 +25,13 @@ module Esi
25
25
  # @param token [String] token the esi access_token
26
26
  # @param refresh_token [String] refresh_token the esi refresh_token
27
27
  # @param expires_at [Time] expires_at the time stamp the esi token expires_at
28
- def initialize(token: nil, refresh_token: nil, expires_at: nil)
28
+ # @param oauth_client [OAuth2::Client] Custom instance of OAuth2::Client
29
+ def initialize(token: nil, refresh_token: nil, expires_at: nil, oauth_client: nil)
29
30
  @logger = Esi.logger
30
31
  @access_token = token
31
32
  @refresh_token = refresh_token
32
33
  @expires_at = expires_at
34
+ @oauth_client = oauth_client
33
35
  @oauth = init_oauth
34
36
  end
35
37
 
@@ -152,11 +154,13 @@ module Esi
152
154
  name.dup.to_s.split('_').map(&:capitalize).join
153
155
  end
154
156
 
157
+ # rubocop:disable Metrics/MethodLength
155
158
  def init_oauth
156
159
  @oauth ||= OAuth.new(
157
160
  access_token: @access_token,
158
161
  refresh_token: @refresh_token,
159
162
  expires_at: @expires_at,
163
+ client: @oauth_client,
160
164
  callback: lambda { |token, expires_at|
161
165
  @access_token = token
162
166
  @expires_at = expires_at
@@ -164,6 +168,7 @@ module Esi
164
168
  }
165
169
  )
166
170
  end
171
+ # rubocop:enable Metrics/MethodLength
167
172
 
168
173
  def request_paginated(call, &block)
169
174
  call.page = 1
data/lib/esi/o_auth.rb CHANGED
@@ -20,26 +20,36 @@ module Esi
20
20
  end
21
21
 
22
22
  def client
23
- @client ||= OAuth2::Client.new(
24
- Esi.config.client_id, Esi.config.client_secret,
25
- site: Esi.config.oauth_host
26
- )
23
+ @client ||= create_client
24
+ end
25
+
26
+ # @return [OAuth2::Client] new oAuth2 client instance with specified options
27
+ def create_client(client_id: nil, client_secret: nil)
28
+ client_id ||= Esi.config.client_id
29
+ client_secret ||= Esi.config.client_secret
30
+
31
+ OAuth2::Client.new(client_id, client_secret, site: Esi.config.oauth_host)
27
32
  end
28
33
  end
29
34
 
30
- def initialize(access_token:, refresh_token:, expires_at:, callback: nil)
35
+ def initialize(access_token:, refresh_token:, expires_at:, callback: nil, client: nil)
31
36
  raise Esi::Error, 'Callback should be a callable Proc' if callback && !callback.respond_to?(:call)
32
37
 
33
38
  @access_token = access_token
34
39
  @refresh_token = refresh_token
35
40
  @expires_at = expires_at
36
41
  @callback = callback if callback
42
+ @client = client if client
37
43
  end
38
44
 
39
45
  private
40
46
 
47
+ def client
48
+ @client || OAuth.client
49
+ end
50
+
41
51
  def token
42
- @token = Esi::AccessToken.new(OAuth.client, @access_token,
52
+ @token = Esi::AccessToken.new(client, @access_token,
43
53
  refresh_token: @refresh_token, expires_at: @expires_at)
44
54
  refresh_access_token if @token.expired?
45
55
  @token
data/lib/esi/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Esi
4
- VERSION = '0.4.12'
4
+ VERSION = '0.4.13-alpa2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.12
4
+ version: 0.4.13.pre.alpa2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Hiemstra
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-02-27 00:00:00.000000000 Z
12
+ date: 2018-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -188,9 +188,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
188
188
  version: '0'
189
189
  required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  requirements:
191
- - - ">="
191
+ - - ">"
192
192
  - !ruby/object:Gem::Version
193
- version: '0'
193
+ version: 1.3.1
194
194
  requirements: []
195
195
  rubyforge_project:
196
196
  rubygems_version: 2.7.6