adsk_auth_service 1.0.4 → 1.0.5

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
  SHA1:
3
- metadata.gz: 1a55ab83859f06356d1b19a5e2ac19b3aede8746
4
- data.tar.gz: 923e0a23ad353028b393b633174676acfc121be2
3
+ metadata.gz: 3798a9499f9e8b9e9b490f0dbc5c39592e875597
4
+ data.tar.gz: 1ad642f3f9ab20ca02fa0b1213f3d55719c24499
5
5
  SHA512:
6
- metadata.gz: c8d2a579842c7b4b40ed03466535c543ab6d09cc2a7236b75d8f2beb2e18dca4d4ba982e4404a0d29d3ccdc883b1841c3fc086cc246a15cb453d168080fb7382
7
- data.tar.gz: f0996543cf958428bde18989e72fd395d301025b6e00bfc6d5e8d9091b6c1476ff0eeec6b03c61422fbefebf79f1f80cdb2a441f84882f0abdcb855fce378ed1
6
+ metadata.gz: af138d66b7194d5dfccdf0dda8a348acf03a3934852997441b08c25b12357cb0ea92d240e0b4af74a038999fd266fc3699ed1118a20b686c0cbc9d334f91f5fd
7
+ data.tar.gz: aa6346981a7f5c507cf16e978712aaf9cdc2a6238178975f805249f78f144f184d40dfa89b19b61f4decb7d7d7b86d537438aab5a39125cf34e68d8c2f1df20b
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'adsk_auth_service'
3
- s.version = '1.0.4'
3
+ s.version = '1.0.5'
4
4
  s.summary = "Autodesk second phase token retrieval"
5
5
  s.description = "A gem for Autodesk 2-phase authentication service."
6
6
  s.authors = ['Linh Chau']
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.files = [
9
9
  './Gemfile', './adsk_auth_service.gemspec',
10
10
  'lib/adsk_auth_service.rb',
11
- 'lib/services/auth_service.rb', 'lib/services/config_service.rb',
11
+ 'lib/services/auth_service.rb', 'lib/services/config_service.rb', 'lib/services/cache_service.rb',
12
12
  'lib/services/sdk_logger.rb', 'lib/services/token_cache_service.rb',
13
13
  'lib/caches/mc_cache.rb',
14
14
  'lib/utils/net_util.rb',
@@ -15,10 +15,8 @@ class McCache
15
15
  @@client = Dalli::Client.new(host, options)
16
16
  end #initialize
17
17
 
18
-
19
18
  # Cache API, mimics ActiveSupport::Cache::Store
20
19
  # http://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html
21
-
22
20
  def read(key, options = {})
23
21
  client.get(key, options)
24
22
  end
@@ -32,10 +30,6 @@ class McCache
32
30
  client.delete(key)
33
31
  deleted
34
32
  end
35
-
36
- def token_key
37
- "#{@@env}_token_data"
38
- end
39
33
  end #class methods
40
34
 
41
35
  initialize
@@ -0,0 +1,34 @@
1
+ require_relative './config_service'
2
+
3
+ class CacheService
4
+ class << self
5
+ def cache
6
+ @@cache
7
+ end
8
+
9
+ def cache=(other_cache)
10
+ @@cache = other_cache
11
+ end
12
+
13
+ def initialize
14
+ config = ConfigService.load_config('cache_config.yml')[ConfigService.environment]
15
+ # Load all the existing caches in the system, outside of the gem
16
+ Dir.glob("#{File.expand_path('.')}/caches/*.rb").each { |rb_file| require rb_file }
17
+ @@cache = Object.const_get(config['cache'])
18
+ end
19
+
20
+ def read(key, options = {})
21
+ cache.read(key, options)
22
+ end
23
+
24
+ def write(key, value, options = {})
25
+ cache.write(key, value, options)
26
+ end
27
+
28
+ def delete(key, options = {})
29
+ cache.delete(key, options)
30
+ end
31
+ end #class methods
32
+
33
+ initialize
34
+ end
@@ -1,35 +1,7 @@
1
- require 'adsk_auth_service'
2
-
3
- require_relative './config_service'
4
-
5
- class TokenCacheService
1
+ class TokenCacheService < CacheService
6
2
  class << self
7
- def cache
8
- # The cache supports the following API functions:
9
- # - read(key, options = {})
10
- # - write(key, value, options = {})
11
- # - delete(key, options = {})
12
- # - token_key
13
- @@cache
14
- end
15
-
16
- def cache=(other_cache)
17
- @@cache = other_cache
18
- end
19
-
20
- def initialize
21
- @@env = ConfigService.environment
22
- config = ConfigService.load_config('cache_config.yml')[@@env]
23
-
24
- # Load all the existing caches in the system, outside of the gem
25
- Dir.glob("#{File.expand_path('.')}/caches/*.rb").each { |rb_file| require rb_file }
26
-
27
- @@cache = Object.const_get(config['cache'])
28
-
29
- end #initialize
30
-
31
3
  def get_token
32
- token_data = cache.read(cache.token_key)
4
+ token_data = read(token_key)
33
5
  if token_data.nil?
34
6
  token_data = AuthService.oauth_token
35
7
  set_token(token_data)
@@ -38,7 +10,11 @@ class TokenCacheService
38
10
  end
39
11
 
40
12
  def set_token(token_data)
41
- cache.write(cache.token_key, token_data, { expires_in: token_data['expires_in'].to_i })
13
+ write(token_key, token_data, { expires_in: token_data['expires_in'].to_i })
14
+ end
15
+
16
+ def token_key
17
+ "#{ConfigService.environment}_token_key"
42
18
  end
43
19
 
44
20
  end #class methods
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adsk_auth_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linh Chau
@@ -77,6 +77,7 @@ files:
77
77
  - lib/adsk_auth_service.rb
78
78
  - lib/caches/mc_cache.rb
79
79
  - lib/services/auth_service.rb
80
+ - lib/services/cache_service.rb
80
81
  - lib/services/config_service.rb
81
82
  - lib/services/sdk_logger.rb
82
83
  - lib/services/token_cache_service.rb