redis_token 0.0.5 → 0.0.6

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: 875d8513b286fd87257c6f5dfb329b290651e18b
4
- data.tar.gz: 3d95c64ffa4c45c18cb1696ce3a42e9de07ae042
3
+ metadata.gz: 8661570273e3ba7ce99b0b96c4412c439c04501f
4
+ data.tar.gz: 301b2b1af39cb1e3edf93f6affb794b37b21b365
5
5
  SHA512:
6
- metadata.gz: c907b23ac817799726c69fcbe206bbfd160c61eda0b074eda50dec93dc2f4ddd47272f92e8af807df2f928023d125656f474442930ef4252cac1ca8b601ce3cf
7
- data.tar.gz: 72d605d0d3f28e5e6b7256e383d6224ec63533dd49b202a017a2e2e419c1d4a3a40a1b433e4254f280e6a1b07b71c0282f45025693e69af9fee26002bd3929f5
6
+ metadata.gz: 6d37f7342a1a40a519e1f3084a112cce0c27f53b10b4cab0eaaa93ab5c081359007e061de22fb219c36935863b4b580a04112d515cce9576e56a3ea5e612d62d
7
+ data.tar.gz: 36f674da4617ca39f6bc88757c3134a5af7662ac66eb29c2fa18f2bbe6c6d9ae98476fa24b96012d2029fb3531ae311e7839c813139126a6e42346f880a338b4
data/README.md CHANGED
@@ -57,7 +57,7 @@ end
57
57
  private
58
58
 
59
59
  def create_service
60
- @redis_token ||= RedisToken.new(prefix: 'myproject.tokens.', ttl: 30.days)
60
+ @redis_token ||= RedisToken.new(ttl: 30.days)
61
61
  end
62
62
  ```
63
63
 
@@ -67,18 +67,18 @@ Implicit Redis instance creation:
67
67
 
68
68
  ```ruby
69
69
  # Redis.new with no arguments:
70
- r = RedisToken.new(prefix: 'myproject.tokens.', ttl: 30.days)
70
+ r = RedisToken.new(ttl: 30.days)
71
71
 
72
72
  # Redis.new(host: '192.168.1.1', port: 33421)
73
- r = RedisToken.new(prefix: 'myproject.tokens.', host: '192.168.1.1', port: 33421)
73
+ r = RedisToken.new(host: '192.168.1.1', port: 33421)
74
74
  ```
75
75
 
76
76
  Explicit Redis instance injection:
77
77
 
78
78
  ```ruby
79
79
  redis = Redis.new
80
- r = RedisToken.new(redis, prefix: 'myproject.tokens.', ttl: 30.days)
81
- r = RedisToken.new(redis, prefix: 'myproject2.tokens.')
80
+ r = RedisToken.new(redis, ttl: 30.days)
81
+ r = RedisToken.new(redis)
82
82
  ```
83
83
 
84
84
  ### Create token
@@ -162,8 +162,8 @@ class MsgPackSerializer
162
162
  end
163
163
  end
164
164
 
165
- r = RedisToken.new(prefix: PREFIX, serializer_class: MsgPackSerializer)
165
+ r = RedisToken.new(serializer_class: MsgPackSerializer)
166
166
  # Or
167
- r = RedisToken.new(prefix: PREFIX)
167
+ r = RedisToken.new
168
168
  r.use(MsgPackSerializer)
169
169
  ```
@@ -1,3 +1,3 @@
1
1
  class RedisToken
2
- VERSION = '0.0.5'.freeze
2
+ VERSION = '0.0.6'.freeze
3
3
  end
data/lib/redis_token.rb CHANGED
@@ -9,6 +9,7 @@ require 'time'
9
9
  class RedisToken
10
10
  # Token lives 14 days by default
11
11
  DEFAULT_TTL = 14 * 24 * 60 * 60
12
+ DEFAULT_PREFIX = 'tokens.'.freeze
12
13
 
13
14
  attr_reader :redis
14
15
  attr_accessor :default_ttl
@@ -25,7 +26,7 @@ class RedisToken
25
26
  # RedisToken.new(redis, ttl: 5.days, prefix: 'project.tokens.')
26
27
  #
27
28
  # @param [Hash] args
28
- # @option args [String] :prefix redis keys prefix (e.g. 'myproject.tokens.')
29
+ # @option args [String] :prefix (DEFAULT_PREFIX) redis keys prefix (e.g. 'myproject.tokens.')
29
30
  # @option args [Integer] :ttl token time to live value (14 days by default)
30
31
  # @option args [Class] :serializer_class serialization class, see RedisToken::Serializers::Native, or #use method
31
32
  #
@@ -218,7 +219,7 @@ class RedisToken
218
219
 
219
220
  def init_params(args)
220
221
  @default_ttl = args[:ttl] || DEFAULT_TTL
221
- @prefix = args[:prefix]
222
+ @prefix = args[:prefix] || DEFAULT_PREFIX
222
223
 
223
224
  @serializer_class = args[:serializer_class]
224
225
  @serializer_class = Serializers::Native unless @serializer_class
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_token
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Baikuzin