redis-store 1.5.0 → 1.6.0

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
- SHA256:
3
- metadata.gz: 10e6007fb1a0708fe88d7627a23a2b5e8e0303e9ee81ec886d27a5c6fdb7ed07
4
- data.tar.gz: 9415f933dae0284fe8114cf6d350561bc23c58bcf9f1182d734f36fdf8436707
2
+ SHA1:
3
+ metadata.gz: 7d09e598db500a23547cfabf8b0ee023aa473aa5
4
+ data.tar.gz: 34fea83415585fe81210982d30f1f8891e4f90c5
5
5
  SHA512:
6
- metadata.gz: 69a4d72561bf0b9da2c88cc7a32d37a7ca06bb758a60d338bc4c12added10c1549f818f6e0e68af3854e0911a92f591c3c3094455d731f7a48d1cb1b47a9a700
7
- data.tar.gz: da5fee4e7926a6032ca82fa7ee924c0a676124bffb55c84d5f553f066eb0ca47678cad583403ccc5979d04b7ddcdeb98652edf906472db364713baf483bc64e3
6
+ metadata.gz: a50a647e8edc5a25a1a2d9c2038bac4bec7d77cdc4b68734004c9f5cf4aec105a6d737172cf2a4759239309484aaf9470f73a0db14f0b08bec76718d8a5bd242
7
+ data.tar.gz: 24c45f122e99129e14c8dc352875ed7be76c3461623f4b101f955fa2322a4eb16ed0c53c62e1da936480c6e0d096284c77fed18c816f95c64957a9e8776396ad
@@ -0,0 +1,6 @@
1
+ ---
2
+ plugins:
3
+ rubocop:
4
+ enabled: true
5
+ fixme:
6
+ enabled: true
@@ -0,0 +1,138 @@
1
+ ---
2
+ AllCops:
3
+ TargetRubyVersion: 2.4
4
+ # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
5
+ # to ignore them, so only the ones explicitly set in this file are enabled.
6
+ DisabledByDefault: true
7
+ Exclude:
8
+ - '**/vendor/**/*'
9
+
10
+ # Prefer &&/|| over and/or.
11
+ Style/AndOr:
12
+ Enabled: true
13
+
14
+ # Do not use braces for hash literals when they are the last argument of a
15
+ # method call.
16
+ Style/BracesAroundHashParameters:
17
+ Enabled: true
18
+ EnforcedStyle: context_dependent
19
+
20
+ # Align comments with method definitions.
21
+ Layout/CommentIndentation:
22
+ Enabled: true
23
+
24
+ Layout/ElseAlignment:
25
+ Enabled: true
26
+
27
+ Layout/EmptyLineAfterMagicComment:
28
+ Enabled: true
29
+
30
+ # In a regular class definition, no empty lines around the body.
31
+ Layout/EmptyLinesAroundClassBody:
32
+ Enabled: true
33
+
34
+ # In a regular method definition, no empty lines around the body.
35
+ Layout/EmptyLinesAroundMethodBody:
36
+ Enabled: true
37
+
38
+ # In a regular module definition, no empty lines around the body.
39
+ Layout/EmptyLinesAroundModuleBody:
40
+ Enabled: true
41
+
42
+ Layout/FirstParameterIndentation:
43
+ Enabled: true
44
+
45
+ # Method definitions after `private` or `protected` isolated calls need one
46
+ # extra level of indentation.
47
+ Layout/IndentationConsistency:
48
+ Enabled: true
49
+ EnforcedStyle: rails
50
+
51
+ # Two spaces, no tabs (for indentation).
52
+ Layout/IndentationWidth:
53
+ Enabled: true
54
+
55
+ Layout/LeadingCommentSpace:
56
+ Enabled: true
57
+
58
+ Layout/SpaceAfterColon:
59
+ Enabled: true
60
+
61
+ Layout/SpaceAfterComma:
62
+ Enabled: true
63
+
64
+ Layout/SpaceAroundEqualsInParameterDefault:
65
+ Enabled: true
66
+
67
+ Layout/SpaceAroundKeyword:
68
+ Enabled: true
69
+
70
+ Layout/SpaceAroundOperators:
71
+ Enabled: true
72
+
73
+ Layout/SpaceBeforeComma:
74
+ Enabled: true
75
+
76
+ Layout/SpaceBeforeFirstArg:
77
+ Enabled: true
78
+
79
+ Style/DefWithParentheses:
80
+ Enabled: true
81
+
82
+ # Defining a method with parameters needs parentheses.
83
+ Style/MethodDefParentheses:
84
+ Enabled: true
85
+
86
+ # Use `foo {}` not `foo{}`.
87
+ Layout/SpaceBeforeBlockBraces:
88
+ Enabled: true
89
+
90
+ # Use `foo { bar }` not `foo {bar}`.
91
+ Layout/SpaceInsideBlockBraces:
92
+ Enabled: true
93
+
94
+ # Use `{ a: 1 }` not `{a:1}`.
95
+ Layout/SpaceInsideHashLiteralBraces:
96
+ Enabled: true
97
+
98
+ Layout/SpaceInsideParens:
99
+ Enabled: true
100
+
101
+ # Detect hard tabs, no hard tabs.
102
+ Layout/Tab:
103
+ Enabled: true
104
+
105
+ # Blank lines should not have any spaces.
106
+ Layout/TrailingBlankLines:
107
+ Enabled: true
108
+
109
+ # No trailing whitespace.
110
+ Layout/TrailingWhitespace:
111
+ Enabled: true
112
+
113
+ # Use quotes for string literals when they are enough.
114
+ Style/UnneededPercentQ:
115
+ Enabled: true
116
+
117
+ # Align `end` with the matching keyword or starting expression except for
118
+ # assignments, where it should be aligned with the LHS.
119
+ Layout/EndAlignment:
120
+ Enabled: true
121
+ EnforcedStyleAlignWith: variable
122
+ AutoCorrect: true
123
+
124
+ # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
125
+ Lint/RequireParentheses:
126
+ Enabled: true
127
+
128
+ Style/RedundantReturn:
129
+ Enabled: true
130
+ AllowMultipleReturnValues: true
131
+
132
+ Style/Semicolon:
133
+ Enabled: true
134
+ AllowAsExpressionSeparator: true
135
+
136
+ # Prefer Foo.method over Foo::method
137
+ Style/ColonMethodCall:
138
+ Enabled: true
@@ -5,12 +5,14 @@ notifications:
5
5
  webhooks: https://www.travisbuddy.com
6
6
  on_success: never
7
7
 
8
- # 1.9.3 has Bundler 1.7.6 with the "undefined method `spec' for nil" bug
9
- before_install: gem install bundler
8
+ before_install:
9
+ # Install Code Climate test reporter
10
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
11
+ - chmod +x ./cc-test-reporter
12
+ # 1.9.3 has Bundler 1.7.6 with the "undefined method `spec' for nil" bug
13
+ - gem install bundler
10
14
 
11
15
  rvm:
12
- - 1.9.3
13
- - 2.0
14
16
  - 2.1
15
17
  - 2.2
16
18
  - 2.3
@@ -22,14 +24,18 @@ gemfile:
22
24
  - gemfiles/redis_3_x.gemfile
23
25
  - gemfiles/redis_4_x.gemfile
24
26
 
27
+ before_script: ./cc-test-reporter before-build
28
+
29
+ # Pipe the coverage data to Code Climate if tests pass
30
+ after_script:
31
+ - ./cc-test-reporter after-build --exit-code $EXIT_CODE
32
+ - ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.json
33
+ - if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then ./cc-test-reporter upload-coverage; fi # Upload coverage/codeclimate.json
34
+
25
35
  matrix:
26
36
  allow_failures:
27
37
  - rvm: jruby-head
28
38
  - rvm: ruby-head
29
39
  exclude:
30
- - rvm: 1.9.3
31
- gemfile: gemfiles/redis_4_x.gemfile
32
- - rvm: 2.0
33
- gemfile: gemfiles/redis_4_x.gemfile
34
40
  - rvm: 2.1
35
41
  gemfile: gemfiles/redis_4_x.gemfile
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.6.0
4
+
5
+ Breaking Changes
6
+
7
+ * None
8
+
9
+ Added
10
+
11
+ * [SSL/TLS Support with the rediss:// URI scheme](https://github.com/redis-store/redis-store/pull/306)
12
+ * [Use Code Style Guide For New Contributions](https://github.com/redis-store/redis-store/pull/309)
13
+
14
+ Fixed
15
+
16
+ * None
17
+
3
18
  ## 1.5.0
4
19
 
5
20
  Breaking Changes
data/README.md CHANGED
@@ -23,7 +23,7 @@ Download and install Redis from [the download page](http://redis.io//download) a
23
23
  ```ruby
24
24
  git clone git://github.com/redis-store/redis-store.git
25
25
  cd redis-store
26
- gem install bundler
26
+ bundle install
27
27
  bundle exec rake
28
28
  ```
29
29
 
data/Rakefile CHANGED
@@ -3,7 +3,9 @@ require 'rake'
3
3
  require 'bundler/gem_tasks'
4
4
  require 'redis-store/testing/tasks'
5
5
  require 'appraisal'
6
+ require 'rubocop/rake_task'
6
7
 
8
+ RuboCop::RakeTask.new :lint
7
9
 
8
10
  if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
9
11
  task :default do
@@ -5,7 +5,7 @@ class Redis
5
5
  @@timeout = 5
6
6
  attr_reader :ring
7
7
 
8
- def initialize(addresses, options = { })
8
+ def initialize(addresses, options = {})
9
9
  _extend_namespace options
10
10
  @ring = options[:ring] || Redis::HashRing.new([], options[:replicas] || Redis::HashRing::POINTS_PER_SERVER)
11
11
 
@@ -19,7 +19,7 @@ class Redis
19
19
  end
20
20
 
21
21
  def reconnect
22
- nodes.each {|node| node.reconnect }
22
+ nodes.each { |node| node.reconnect }
23
23
  end
24
24
 
25
25
  def set(key, value, options = nil)
@@ -57,10 +57,10 @@ class Redis
57
57
  end
58
58
 
59
59
  def _merge_options(address, options)
60
- address.merge({
61
- :timeout => options[:timeout] || @@timeout,
60
+ address.merge(
61
+ :timeout => options[:timeout] || @@timeout,
62
62
  :namespace => options[:namespace]
63
- })
63
+ )
64
64
  end
65
65
  end
66
66
  end
@@ -13,7 +13,7 @@ class Redis
13
13
  class Store < self
14
14
  include Ttl, Interface, RedisVersion
15
15
 
16
- def initialize(options = { })
16
+ def initialize(options = {})
17
17
  super
18
18
 
19
19
  unless options[:marshalling].nil?
@@ -66,4 +66,3 @@ class Redis
66
66
  end
67
67
  end
68
68
  end
69
-
@@ -3,7 +3,6 @@ require 'uri'
3
3
  class Redis
4
4
  class Store < self
5
5
  class Factory
6
-
7
6
  DEFAULT_PORT = 6379
8
7
 
9
8
  def self.create(*options)
@@ -41,7 +40,7 @@ class Redis
41
40
  if host_options?(options)
42
41
  options
43
42
  else
44
- nil
43
+ nil
45
44
  end
46
45
  end
47
46
 
@@ -57,12 +56,12 @@ class Redis
57
56
  !options[:marshalling]
58
57
  else
59
58
  false
60
- end
59
+ end
61
60
  options
62
61
  end
63
62
 
64
63
  def self.host_options?(options)
65
- options.keys.any? {|n| [:host, :db, :port, :path].include?(n) }
64
+ options.keys.any? { |n| [:host, :db, :port, :path].include?(n) }
66
65
  end
67
66
 
68
67
  def self.extract_host_options_from_uri(uri)
@@ -71,13 +70,14 @@ class Redis
71
70
  options = { :path => uri.path }
72
71
  else
73
72
  _, db, namespace = if uri.path
74
- uri.path.split(/\//)
75
- end
73
+ uri.path.split(/\//)
74
+ end
76
75
 
77
76
  options = {
77
+ :scheme => uri.scheme,
78
78
  :host => uri.hostname,
79
79
  :port => uri.port || DEFAULT_PORT,
80
- :password => uri.password.nil? ? nil : CGI::unescape(uri.password.to_s)
80
+ :password => uri.password.nil? ? nil : CGI.unescape(uri.password.to_s)
81
81
  }
82
82
 
83
83
  options[:db] = db.to_i if db
@@ -95,16 +95,16 @@ class Redis
95
95
 
96
96
  private
97
97
 
98
- def extract_addresses_and_options(*options)
99
- options.flatten.compact.each do |token|
100
- resolved = self.class.resolve(token)
101
- if resolved
102
- @addresses << resolved
103
- else
104
- @options.merge!(self.class.normalize_key_names(token))
98
+ def extract_addresses_and_options(*options)
99
+ options.flatten.compact.each do |token|
100
+ resolved = self.class.resolve(token)
101
+ if resolved
102
+ @addresses << resolved
103
+ else
104
+ @options.merge!(self.class.normalize_key_names(token))
105
+ end
105
106
  end
106
107
  end
107
- end
108
108
  end
109
109
  end
110
110
  end
@@ -36,15 +36,15 @@ class Redis
36
36
  end
37
37
 
38
38
  def keys(pattern = "*")
39
- namespace(pattern) { |p| super(p).map{|key| strip_namespace(key) } }
39
+ namespace(pattern) { |p| super(p).map { |key| strip_namespace(key) } }
40
40
  end
41
41
 
42
42
  def del(*keys)
43
- super(*keys.map {|key| interpolate(key) }) if keys.any?
43
+ super(*keys.map { |key| interpolate(key) }) if keys.any?
44
44
  end
45
45
 
46
46
  def watch(*keys)
47
- super(*keys.map {|key| interpolate(key) }) if keys.any?
47
+ super(*keys.map { |key| interpolate(key) }) if keys.any?
48
48
  end
49
49
 
50
50
  def mget(*keys, &blk)
@@ -52,15 +52,15 @@ class Redis
52
52
  if keys.any?
53
53
  # Serialization gets extended before Namespace does, so we need to pass options further
54
54
  if singleton_class.ancestors.include? Serialization
55
- super(*keys.map {|key| interpolate(key) }, options, &blk)
55
+ super(*keys.map { |key| interpolate(key) }, options, &blk)
56
56
  else
57
- super(*keys.map {|key| interpolate(key) }, &blk)
57
+ super(*keys.map { |key| interpolate(key) }, &blk)
58
58
  end
59
59
  end
60
60
  end
61
61
 
62
62
  def expire(key, ttl)
63
- namespace(key) { |k| super(k, ttl) }
63
+ namespace(key) { |k| super(k, ttl) }
64
64
  end
65
65
 
66
66
  def to_s
@@ -11,4 +11,3 @@ class Redis
11
11
  end
12
12
  end
13
13
  end
14
-
@@ -1,5 +1,5 @@
1
1
  class Redis
2
2
  class Store < self
3
- VERSION = '1.5.0'
3
+ VERSION = '1.6.0'
4
4
  end
5
5
  end
@@ -1,4 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
+
2
3
  $:.push File.expand_path('../lib', __FILE__)
3
4
  require 'redis/store/version'
4
5
 
@@ -8,14 +9,14 @@ Gem::Specification.new do |s|
8
9
  s.authors = ['Luca Guidi']
9
10
  s.email = ['me@lucaguidi.com']
10
11
  s.homepage = 'http://redis-store.org/redis-store'
11
- s.summary = %q{Redis stores for Ruby frameworks}
12
- s.description = %q{Namespaced Rack::Session, Rack::Cache, I18n and cache Redis stores for Ruby web frameworks.}
12
+ s.summary = 'Redis stores for Ruby frameworks'
13
+ s.description = 'Namespaced Rack::Session, Rack::Cache, I18n and cache Redis stores for Ruby web frameworks.'
13
14
 
14
15
  s.rubyforge_project = 'redis-store'
15
16
 
16
17
  s.files = `git ls-files`.split("\n")
17
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
20
  s.require_paths = ["lib"]
20
21
  s.license = 'MIT'
21
22
 
@@ -30,4 +31,5 @@ Gem::Specification.new do |s|
30
31
  s.add_development_dependency 'pry', '~> 0.10.4'
31
32
  s.add_development_dependency 'redis-store-testing'
32
33
  s.add_development_dependency 'appraisal', '~> 2.0'
34
+ s.add_development_dependency 'rubocop', '~> 0.54'
33
35
  end
@@ -3,8 +3,8 @@ require 'test_helper'
3
3
  describe "Redis::DistributedStore" do
4
4
  def setup
5
5
  @dmr = Redis::DistributedStore.new [
6
- {:host => "localhost", :port => "6380", :db => 0},
7
- {:host => "localhost", :port => "6381", :db => 0}
6
+ { :host => "localhost", :port => "6380", :db => 0 },
7
+ { :host => "localhost", :port => "6381", :db => 0 }
8
8
  ]
9
9
  @rabbit = OpenStruct.new :name => "bunny"
10
10
  @white_rabbit = OpenStruct.new :color => "white"
@@ -67,8 +67,8 @@ describe "Redis::DistributedStore" do
67
67
 
68
68
  it "passes through ring replica options" do
69
69
  dmr = Redis::DistributedStore.new [
70
- {:host => "localhost", :port => "6380", :db => 0},
71
- {:host => "localhost", :port => "6381", :db => 0}
70
+ { :host => "localhost", :port => "6380", :db => 0 },
71
+ { :host => "localhost", :port => "6381", :db => 0 }
72
72
  ], replicas: 1024
73
73
  dmr.ring.replicas.must_equal 1024
74
74
  end
@@ -76,8 +76,8 @@ describe "Redis::DistributedStore" do
76
76
  it "uses a custom ring object" do
77
77
  my_ring = Redis::HashRing.new
78
78
  dmr = Redis::DistributedStore.new [
79
- {:host => "localhost", :port => "6380", :db => 0},
80
- {:host => "localhost", :port => "6381", :db => 0}
79
+ { :host => "localhost", :port => "6380", :db => 0 },
80
+ { :host => "localhost", :port => "6381", :db => 0 }
81
81
  ], ring: my_ring
82
82
  dmr.ring.must_equal my_ring
83
83
  dmr.ring.nodes.length.must_equal 2
@@ -100,8 +100,8 @@ describe "Redis::DistributedStore" do
100
100
  describe "namespace" do
101
101
  it "uses namespaced key" do
102
102
  @dmr = Redis::DistributedStore.new [
103
- {:host => "localhost", :port => "6380", :db => 0},
104
- {:host => "localhost", :port => "6381", :db => 0}
103
+ { :host => "localhost", :port => "6380", :db => 0 },
104
+ { :host => "localhost", :port => "6381", :db => 0 }
105
105
  ], :namespace => "theplaylist"
106
106
 
107
107
  @dmr.expects(:node_for).with("theplaylist:rabbit").returns(@dmr.nodes.first)
@@ -22,6 +22,11 @@ describe "Redis::Store::Factory" do
22
22
  store.to_s.must_equal("Redis Client connected to localhost:6380 against DB 0")
23
23
  end
24
24
 
25
+ it "uses specified scheme" do
26
+ store = Redis::Store::Factory.create :scheme => "rediss"
27
+ store.instance_variable_get(:@client).scheme.must_equal('rediss')
28
+ end
29
+
25
30
  it "uses specified path" do
26
31
  store = Redis::Store::Factory.create :path => "/var/run/redis.sock"
27
32
  store.to_s.must_equal("Redis Client connected to /var/run/redis.sock against DB 0")
@@ -69,6 +74,23 @@ describe "Redis::Store::Factory" do
69
74
  store.instance_variable_get(:@options)[:raw].must_equal(false)
70
75
  end
71
76
 
77
+ describe "defaults" do
78
+ it "defaults to localhost if no host specified" do
79
+ store = Redis::Store::Factory.create
80
+ store.instance_variable_get(:@client).host.must_equal('127.0.0.1')
81
+ end
82
+
83
+ it "defaults to 6379 if no port specified" do
84
+ store = Redis::Store::Factory.create
85
+ store.instance_variable_get(:@client).port.must_equal(6379)
86
+ end
87
+
88
+ it "defaults to redis:// if no scheme specified" do
89
+ store = Redis::Store::Factory.create
90
+ store.instance_variable_get(:@client).scheme.must_equal('redis')
91
+ end
92
+ end
93
+
72
94
  describe 'with stdout disabled' do
73
95
  before do
74
96
  @original_stderr = $stderr
@@ -98,11 +120,11 @@ describe "Redis::Store::Factory" do
98
120
 
99
121
  it "should instantiate a Redis::DistributedStore store" do
100
122
  store = Redis::Store::Factory.create(
101
- {:host => "localhost", :port => 6379},
102
- {:host => "localhost", :port => 6380}
123
+ { :host => "localhost", :port => 6379 },
124
+ { :host => "localhost", :port => 6380 }
103
125
  )
104
126
  store.must_be_kind_of(Redis::DistributedStore)
105
- store.nodes.map {|node| node.to_s }.must_equal([
127
+ store.nodes.map { |node| node.to_s }.must_equal([
106
128
  "Redis Client connected to localhost:6379 against DB 0",
107
129
  "Redis Client connected to localhost:6380 against DB 0",
108
130
  ])
@@ -120,6 +142,16 @@ describe "Redis::Store::Factory" do
120
142
  store.to_s.must_equal("Redis Client connected to 127.0.0.1:6380 against DB 0")
121
143
  end
122
144
 
145
+ it "uses specified scheme" do
146
+ store = Redis::Store::Factory.create "rediss://127.0.0.1:6380"
147
+ store.instance_variable_get(:@client).scheme.must_equal('rediss')
148
+ end
149
+
150
+ it "correctly defaults to redis:// when relative scheme specified" do
151
+ store = Redis::Store::Factory.create "//127.0.0.1:6379"
152
+ store.instance_variable_get(:@client).scheme.must_equal('redis')
153
+ end
154
+
123
155
  it "uses specified path" do
124
156
  store = Redis::Store::Factory.create "unix:///var/run/redis.sock"
125
157
  store.to_s.must_equal("Redis Client connected to /var/run/redis.sock against DB 0")
@@ -174,50 +206,50 @@ describe "Redis::Store::Factory" do
174
206
  it "instantiates Redis::DistributedStore" do
175
207
  store = Redis::Store::Factory.create "redis://127.0.0.1:6379", "redis://127.0.0.1:6380"
176
208
  store.must_be_kind_of(Redis::DistributedStore)
177
- store.nodes.map {|node| node.to_s }.must_equal([
209
+ store.nodes.map { |node| node.to_s }.must_equal([
178
210
  "Redis Client connected to 127.0.0.1:6379 against DB 0",
179
211
  "Redis Client connected to 127.0.0.1:6380 against DB 0",
180
212
  ])
181
213
  end
182
214
  end
183
215
 
184
- describe 'when given host Hash and options Hash' do
216
+ describe 'when given host Hash and options Hash' do
185
217
  it 'instantiates Redis::Store and merges options' do
186
218
  store = Redis::Store::Factory.create(
187
- { :host => '127.0.0.1', :port => '6379' },
219
+ { :host => '127.0.0.1', :port => '6379' },
188
220
  { :namespace => 'theplaylist' }
189
221
  )
190
222
  end
191
223
 
192
- it 'instantiates Redis::DistributedStore and merges options' do
224
+ it 'instantiates Redis::DistributedStore and merges options' do
193
225
  store = Redis::Store::Factory.create(
194
- { :host => '127.0.0.1', :port => '6379' },
195
- { :host => '127.0.0.1', :port => '6380' },
226
+ { :host => '127.0.0.1', :port => '6379' },
227
+ { :host => '127.0.0.1', :port => '6380' },
196
228
  { :namespace => 'theplaylist' }
197
229
  )
198
- store.nodes.map {|node| node.to_s }.must_equal([
230
+ store.nodes.map { |node| node.to_s }.must_equal([
199
231
  "Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist",
200
232
  "Redis Client connected to 127.0.0.1:6380 against DB 0 with namespace theplaylist"
201
233
  ])
202
234
  end
203
235
  end
204
236
 
205
- describe 'when given host String and options Hash' do
206
- it 'instantiates Redis::Store and merges options' do
207
- store = Redis::Store::Factory.create "redis://127.0.0.1", { :namespace => 'theplaylist' }
237
+ describe 'when given host String and options Hash' do
238
+ it 'instantiates Redis::Store and merges options' do
239
+ store = Redis::Store::Factory.create "redis://127.0.0.1", :namespace => 'theplaylist'
208
240
  store.to_s.must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
209
241
  end
210
242
 
211
- it 'instantiates Redis::DistributedStore and merges options' do
212
- store = Redis::Store::Factory.create "redis://127.0.0.1:6379", "redis://127.0.0.1:6380", { :namespace => 'theplaylist' }
213
- store.nodes.map {|node| node.to_s }.must_equal([
243
+ it 'instantiates Redis::DistributedStore and merges options' do
244
+ store = Redis::Store::Factory.create "redis://127.0.0.1:6379", "redis://127.0.0.1:6380", :namespace => 'theplaylist'
245
+ store.nodes.map { |node| node.to_s }.must_equal([
214
246
  "Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist",
215
247
  "Redis Client connected to 127.0.0.1:6380 against DB 0 with namespace theplaylist",
216
248
  ])
217
249
  end
218
250
 
219
251
  it 'instantiates Redis::Store and sets namespace from String' do
220
- store = Redis::Store::Factory.create "redis://127.0.0.1:6379/0/theplaylist", { :expire_after => 5 }
252
+ store = Redis::Store::Factory.create "redis://127.0.0.1:6379/0/theplaylist", :expire_after => 5
221
253
  store.to_s.must_equal("Redis Client connected to 127.0.0.1:6379 against DB 0 with namespace theplaylist")
222
254
  end
223
255
  end
@@ -10,18 +10,18 @@ describe Redis::Store::Interface do
10
10
  end
11
11
 
12
12
  it "should get an element" do
13
- lambda { @r.get("key", :option => true) } #.wont_raise ArgumentError
13
+ lambda { @r.get("key", :option => true) } # .wont_raise ArgumentError
14
14
  end
15
15
 
16
16
  it "should set an element" do
17
- lambda { @r.set("key", "value", :option => true) } #.wont_raise ArgumentError
17
+ lambda { @r.set("key", "value", :option => true) } # .wont_raise ArgumentError
18
18
  end
19
19
 
20
20
  it "should setnx an element" do
21
- lambda { @r.setnx("key", "value", :option => true) } #.wont_raise ArgumentError
21
+ lambda { @r.setnx("key", "value", :option => true) } # .wont_raise ArgumentError
22
22
  end
23
23
 
24
24
  it "should setex an element" do
25
- lambda { @r.setex("key", 1, "value", :option => true) } #.wont_raise ArgumentError
25
+ lambda { @r.setex("key", 1, "value", :option => true) } # .wont_raise ArgumentError
26
26
  end
27
27
  end
@@ -90,52 +90,52 @@ describe "Redis::Store::Namespace" do
90
90
  end
91
91
 
92
92
  describe 'method calls' do
93
- let(:store){Redis::Store.new :namespace => @namespace, :serializer => nil}
94
- let(:client){store.instance_variable_get(:@client)}
93
+ let(:store) { Redis::Store.new :namespace => @namespace, :serializer => nil }
94
+ let(:client) { store.instance_variable_get(:@client) }
95
95
 
96
96
  it "should namespace get" do
97
- client.expects(:call).with([:get, "#{@namespace}:rabbit"]).once
98
- store.get("rabbit")
97
+ client.expects(:call).with([:get, "#{@namespace}:rabbit"]).once
98
+ store.get("rabbit")
99
99
  end
100
100
 
101
101
  it "should namespace set" do
102
- client.expects(:call).with([:set, "#{@namespace}:rabbit", @rabbit])
103
- store.set "rabbit", @rabbit
102
+ client.expects(:call).with([:set, "#{@namespace}:rabbit", @rabbit])
103
+ store.set "rabbit", @rabbit
104
104
  end
105
105
 
106
106
  it "should namespace setnx" do
107
- client.expects(:call).with([:setnx, "#{@namespace}:rabbit", @rabbit])
108
- store.setnx "rabbit", @rabbit
107
+ client.expects(:call).with([:setnx, "#{@namespace}:rabbit", @rabbit])
108
+ store.setnx "rabbit", @rabbit
109
109
  end
110
110
 
111
111
  it "should namespace del with single key" do
112
- client.expects(:call).with([:del, "#{@namespace}:rabbit"])
113
- store.del "rabbit"
112
+ client.expects(:call).with([:del, "#{@namespace}:rabbit"])
113
+ store.del "rabbit"
114
114
  end
115
115
 
116
116
  it "should namespace del with multiple keys" do
117
- client.expects(:call).with([:del, "#{@namespace}:rabbit", "#{@namespace}:white_rabbit"])
118
- store.del "rabbit", "white_rabbit"
117
+ client.expects(:call).with([:del, "#{@namespace}:rabbit", "#{@namespace}:white_rabbit"])
118
+ store.del "rabbit", "white_rabbit"
119
119
  end
120
120
 
121
121
  it "should namespace keys" do
122
- store.set "rabbit", @rabbit
123
- store.keys("rabb*").must_equal [ "rabbit" ]
122
+ store.set "rabbit", @rabbit
123
+ store.keys("rabb*").must_equal [ "rabbit" ]
124
124
  end
125
125
 
126
126
  it "should namespace exists" do
127
- client.expects(:call).with([:exists, "#{@namespace}:rabbit"])
128
- store.exists "rabbit"
127
+ client.expects(:call).with([:exists, "#{@namespace}:rabbit"])
128
+ store.exists "rabbit"
129
129
  end
130
130
 
131
131
  it "should namespace incrby" do
132
- client.expects(:call).with([:incrby, "#{@namespace}:counter", 1])
133
- store.incrby "counter", 1
132
+ client.expects(:call).with([:incrby, "#{@namespace}:counter", 1])
133
+ store.incrby "counter", 1
134
134
  end
135
135
 
136
136
  it "should namespace decrby" do
137
- client.expects(:call).with([:decrby, "#{@namespace}:counter", 1])
138
- store.decrby "counter", 1
137
+ client.expects(:call).with([:decrby, "#{@namespace}:counter", 1])
138
+ store.decrby "counter", 1
139
139
  end
140
140
 
141
141
  it "should namespace mget" do
@@ -154,24 +154,24 @@ describe "Redis::Store::Namespace" do
154
154
  end
155
155
 
156
156
  it "should namespace expire" do
157
- client.expects(:call).with([:expire, "#{@namespace}:rabbit", 60]).once
158
- store.expire("rabbit",60)
157
+ client.expects(:call).with([:expire, "#{@namespace}:rabbit", 60]).once
158
+ store.expire("rabbit", 60)
159
159
  end
160
160
 
161
161
  it "should namespace ttl" do
162
- client.expects(:call).with([:ttl, "#{@namespace}:rabbit"]).once
163
- store.ttl("rabbit")
162
+ client.expects(:call).with([:ttl, "#{@namespace}:rabbit"]).once
163
+ store.ttl("rabbit")
164
164
  end
165
165
 
166
166
  it "should namespace watch" do
167
- client.expects(:call).with([:watch,"#{@namespace}:rabbit"]).once
167
+ client.expects(:call).with([:watch, "#{@namespace}:rabbit"]).once
168
168
  store.watch("rabbit")
169
169
  end
170
170
 
171
171
  it "wraps flushdb with appropriate KEYS * calls" do
172
172
  client.expects(:call).with([:flushdb]).never
173
- client.expects(:call).with([:keys,"#{@namespace}:*"]).once.returns(["rabbit"])
174
- client.expects(:call).with([:del,"#{@namespace}:rabbit"]).once
173
+ client.expects(:call).with([:keys, "#{@namespace}:*"]).once.returns(["rabbit"])
174
+ client.expects(:call).with([:del, "#{@namespace}:rabbit"]).once
175
175
  store.flushdb
176
176
  end
177
177
 
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  describe "Redis::RedisVersion" do
4
4
  def setup
5
- @store = Redis::Store.new
5
+ @store = Redis::Store.new
6
6
  end
7
7
 
8
8
  def teardown
@@ -26,4 +26,3 @@ describe "Redis::RedisVersion" do
26
26
  end
27
27
  end
28
28
  end
29
-
@@ -81,8 +81,8 @@ describe "Redis::Serialization" do
81
81
 
82
82
  it "marshals setex (over a distributed store)" do
83
83
  @store = Redis::DistributedStore.new [
84
- {:host => "localhost", :port => "6380", :db => 0},
85
- {:host => "localhost", :port => "6381", :db => 0}
84
+ { :host => "localhost", :port => "6380", :db => 0 },
85
+ { :host => "localhost", :port => "6381", :db => 0 }
86
86
  ]
87
87
  @store.setex "rabbit", 50, @white_rabbit
88
88
  @store.get("rabbit").must_equal(@white_rabbit)
@@ -90,8 +90,8 @@ describe "Redis::Serialization" do
90
90
 
91
91
  it "doesn't marshal setex if raw option is true (over a distributed store)" do
92
92
  @store = Redis::DistributedStore.new [
93
- {:host => "localhost", :port => "6380", :db => 0},
94
- {:host => "localhost", :port => "6381", :db => 0}
93
+ { :host => "localhost", :port => "6380", :db => 0 },
94
+ { :host => "localhost", :port => "6381", :db => 0 }
95
95
  ]
96
96
  @store.setex "rabbit", 50, @white_rabbit, :raw => true
97
97
  @store.get("rabbit", :raw => true).must_equal(%(#<OpenStruct color="white">))
@@ -50,7 +50,6 @@ class MockRedis
50
50
  def has_expire?(*a)
51
51
  @expires.include?(a)
52
52
  end
53
-
54
53
  end
55
54
 
56
55
  class MockTtlStore < MockRedis
@@ -80,7 +79,7 @@ describe MockTtlStore do
80
79
 
81
80
  describe 'with nx and ex option' do
82
81
  it 'must call super with key and value and options' do
83
- set_options = {nx: true, ex: 3600}
82
+ set_options = { nx: true, ex: 3600 }
84
83
  redis.set(key, mock_value, set_options)
85
84
  redis.has_set?(key, mock_value, set_options).must_equal true
86
85
  end
@@ -16,6 +16,6 @@ module Kernel
16
16
  $VERBOSE = nil
17
17
  result = yield
18
18
  $VERBOSE = original_verbosity
19
- return result
19
+ result
20
20
  end
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-store
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-16 00:00:00.000000000 Z
11
+ date: 2018-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -156,6 +156,20 @@ dependencies:
156
156
  - - "~>"
157
157
  - !ruby/object:Gem::Version
158
158
  version: '2.0'
159
+ - !ruby/object:Gem::Dependency
160
+ name: rubocop
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - "~>"
164
+ - !ruby/object:Gem::Version
165
+ version: '0.54'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: '0.54'
159
173
  description: Namespaced Rack::Session, Rack::Cache, I18n and cache Redis stores for
160
174
  Ruby web frameworks.
161
175
  email:
@@ -164,7 +178,9 @@ executables: []
164
178
  extensions: []
165
179
  extra_rdoc_files: []
166
180
  files:
181
+ - ".codeclimate.yml"
167
182
  - ".gitignore"
183
+ - ".rubocop.yml"
168
184
  - ".travis.yml"
169
185
  - Appraisals
170
186
  - CHANGELOG.md
@@ -215,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
231
  version: '0'
216
232
  requirements: []
217
233
  rubyforge_project: redis-store
218
- rubygems_version: 2.7.3
234
+ rubygems_version: 2.6.14
219
235
  signing_key:
220
236
  specification_version: 4
221
237
  summary: Redis stores for Ruby frameworks