stockpile-redis 1.1 → 2.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
2
  SHA1:
3
- metadata.gz: c921c5dea37bc0ab0c8f2b5ebb77bb3db14071a3
4
- data.tar.gz: 75fa3e0437603717c027d83270d36f93eb814852
3
+ metadata.gz: d40f8011b02ab91d739a865686931cee23ea4ba0
4
+ data.tar.gz: 201d2ae7aba6ec7df5f58153824978bf5267c4ee
5
5
  SHA512:
6
- metadata.gz: bc72992d8cf5eaf4d146d0f3ae643659ea6b1c14d97a24bdaae96fa17b6fc2d74234dab6d79b39b3549d7ad16abae044784a2eff8e67717ddd8ff5917105116a
7
- data.tar.gz: 061fe3aabb239931475bd1ba656b5d48e0d187c1f40777861844c9afa7e98be17a1b040256204193dc718a0bdde69d1e2fe13ba9780e9ef962c8f2c4d83204ca
6
+ metadata.gz: 98c37e4a71cd967669e837918d24bff07fafcc6aa57018306cddce2e85dd3617e0724d21a885d4a60161d6d828749d59591a7d31207cfcca9dce3e559fdf02d5
7
+ data.tar.gz: ad1bd1b18becc30212432f2b0c29e085fb94e469fa32bbf60f8e8ad53b91225ab11ffbe367124725777bb67e559a530555406ee7708044fdc4be139f93b243e7
data/.autotest CHANGED
@@ -1,27 +1,8 @@
1
+ # frozen_string_literal: true
1
2
  # -*- ruby -*-
2
3
 
3
- require "autotest/restart"
4
+ require 'autotest/restart'
4
5
 
5
6
  Autotest.add_hook :initialize do |at|
6
- # .minitest.rb ensures that the gem version of minitest is used.
7
7
  at.testlib = ".minitest.rb"
8
- # at.testlib = "minitest/unit"
9
- #
10
- # at.extra_files << "../some/external/dependency.rb"
11
- #
12
- # at.libs << ":../some/external"
13
- #
14
- # at.add_exception "vendor"
15
- #
16
- # at.add_mapping(/dependency.rb/) do |f, _|
17
- # at.files_matching(/test_.*rb$/)
18
- # end
19
- #
20
- # %w(TestA TestB).each do |klass|
21
- # at.extra_class_map[klass] = "test/test_misc.rb"
22
- # end
23
8
  end
24
-
25
- # Autotest.add_hook :run_command do |at|
26
- # system "rake build"
27
- # end
@@ -1,2 +1,3 @@
1
- gem "minitest"
2
- require "minitest/autorun"
1
+ # frozen_string_literal: true
2
+ gem 'minitest'
3
+ require 'minitest/autorun'
@@ -0,0 +1,209 @@
1
+ ---
2
+ # inherit_from: .rubocop_todo.yml
3
+
4
+ AllCops:
5
+ Include:
6
+ - '**/Rakefile'
7
+ - '**/config.rb'
8
+ Exclude:
9
+ - 'bin/**/*'
10
+ - 'config/**/*'
11
+ - 'script/**/*'
12
+ - 'tmp/**/*'
13
+ DisplayCopNames: true
14
+ TargetRubyVersion: 2.3
15
+
16
+ Style/AlignHash:
17
+ EnforcedHashRocketStyle: key
18
+ EnforcedColonStyle: key
19
+ EnforcedLastArgumentHashStyle: always_ignore
20
+
21
+ Style/AndOr:
22
+ EnforcedStyle: conditionals
23
+
24
+ Style/BarePercentLiterals:
25
+ EnforcedStyle: percent_q
26
+
27
+ Style/BracesAroundHashParameters:
28
+ EnforcedStyle: context_dependent
29
+
30
+ Style/Documentation:
31
+ Enabled: false
32
+
33
+ Style/Lambda:
34
+ Enabled: false
35
+
36
+ Style/TrailingCommaInLiteral:
37
+ Enabled: false
38
+
39
+ Style/TrailingCommaInArguments:
40
+ Enabled: false
41
+
42
+ Style/ClassAndModuleChildren:
43
+ Enabled: false
44
+
45
+ Style/MultilineMethodCallIndentation:
46
+ EnforcedStyle: indented
47
+
48
+ Style/MultilineOperationIndentation:
49
+ EnforcedStyle: indented
50
+
51
+ Style/DotPosition:
52
+ EnforcedStyle: trailing
53
+
54
+ Style/AlignParameters:
55
+ EnforcedStyle: with_fixed_indentation
56
+
57
+ # This replaces the old Style/Blocks. The default for this is still stupid
58
+ # (multiline blocks are do/end and single-line blocks are {/}), but it now
59
+ # performs a semantic analysis, allowing for the more nuanced version proposed
60
+ # by Jim Weirich around 2004. If a block is used as part of an assignment or
61
+ # method chaining, prefer {/} delimiters; if not, prefer do/end delimiters. It
62
+ # isn't *quite* that simple in all circumstances, but we can add them to one of
63
+ # three groups: ProceduralMethods (prefer do/end), FunctionalMethods ({/}), and
64
+ # ignored (because it does not matter).
65
+ Style/BlockDelimiters:
66
+ Enabled: false
67
+ EnforcedStyle: semantic
68
+ ProceduralMethods:
69
+ # Methods that are known to be procedural in nature but look functional from
70
+ # their usage, e.g.
71
+ #
72
+ # time = Benchmark.realtime do
73
+ # foo.bar
74
+ # end
75
+ #
76
+ # Here, the return value of the block is discarded but the return value of
77
+ # `Benchmark.realtime` is used.
78
+ - benchmark
79
+ - bm
80
+ - bmbm
81
+ - create
82
+ - each_with_object
83
+ - measure
84
+ - new
85
+ - realtime
86
+ - tap
87
+ - with_object
88
+ - assert_raises
89
+ - solr_search
90
+ - solr_paginated
91
+ - all_of
92
+ - any_of
93
+ FunctionalMethods:
94
+ # Methods that are known to be functional in nature but look procedural from
95
+ # their usage, e.g.
96
+ #
97
+ # let(:foo) { Foo.new }
98
+ #
99
+ # Here, the return value of `Foo.new` is used to define a `foo` helper but
100
+ # doesn't appear to be used from the return value of `let`.
101
+ - let
102
+ - let!
103
+ - subject
104
+ - watch
105
+ IgnoredMethods:
106
+ # Methods that can be either procedural or functional and cannot be
107
+ # categorised from their usage alone, e.g.
108
+ #
109
+ # foo = lambda do |x|
110
+ # puts "Hello, #{x}"
111
+ # end
112
+ #
113
+ # foo = lambda do |x|
114
+ # x * 100
115
+ # end
116
+ #
117
+ # Here, it is impossible to tell from the return value of `lambda` whether
118
+ # the inner block's return value is significant.
119
+ - lambda
120
+ - proc
121
+ - it
122
+ Performance/FixedSize:
123
+ Enabled: false
124
+
125
+ Style/FormatString:
126
+ Enabled: false
127
+
128
+ Style/NumericLiterals:
129
+ Enabled: false
130
+
131
+ Style/SpaceInsideBrackets:
132
+ Enabled: false
133
+
134
+ Style/CommentAnnotation:
135
+ Enabled: false
136
+
137
+ Style/AsciiComments:
138
+ Enabled: false
139
+
140
+ Style/ClassCheck:
141
+ EnforcedStyle: kind_of?
142
+
143
+ Style/RegexpLiteral:
144
+ EnforcedStyle: mixed
145
+
146
+ Style/CommandLiteral:
147
+ EnforcedStyle: percent_x
148
+
149
+ Style/UnneededPercentQ:
150
+ Enabled: false
151
+
152
+ Style/IndentAssignment:
153
+ Enabled: false
154
+
155
+ Metrics/AbcSize:
156
+ Enabled: false
157
+
158
+ Metrics/CyclomaticComplexity:
159
+ Enabled: false
160
+
161
+ Metrics/MethodLength:
162
+ Enabled: false
163
+
164
+ Metrics/ModuleLength:
165
+ Enabled: false
166
+
167
+ Metrics/ClassLength:
168
+ Enabled: false
169
+
170
+ Metrics/PerceivedComplexity:
171
+ Enabled: false
172
+
173
+ Metrics/LineLength:
174
+ Max: 90
175
+ Exclude:
176
+ - test/**/*
177
+ - Gemfile
178
+
179
+ Style/MethodDefParentheses:
180
+ Exclude:
181
+ - test/**/*
182
+
183
+ Style/DoubleNegation:
184
+ Enabled: false
185
+
186
+ Style/FileName:
187
+ Exclude:
188
+ - Gemfile
189
+ - .autotest
190
+ - .simplecov-prelude.rb
191
+
192
+ Style/RedundantSelf:
193
+ Exclude:
194
+ - test/test_helper.rb
195
+
196
+ Style/SignalException:
197
+ EnforcedStyle: semantic
198
+
199
+ Style/Alias:
200
+ EnforcedStyle: prefer_alias_method
201
+
202
+ Style/SpecialGlobalVars:
203
+ Enabled: false
204
+
205
+ Performance/RedundantBlockCall:
206
+ Enabled: false
207
+
208
+ Style/LambdaCall:
209
+ Enabled: false
@@ -0,0 +1,9 @@
1
+ require 'simplecov'
2
+
3
+ SimpleCov.start do
4
+ command_name 'Minitest'
5
+ add_filter '/lib/cartage/backport.rb'
6
+ add_filter '/test/'
7
+ end
8
+
9
+ gem 'minitest'
@@ -1,18 +1,17 @@
1
1
  ---
2
+ sudo: false
2
3
  language: ruby
3
4
  rvm:
4
- - "2.2"
5
- - "2.1"
6
- - 2.0.0
7
- - 1.9.3
5
+ - 2.3.0
6
+ - 2.2
7
+ - 2.1
8
+ - 2.0
8
9
  - ruby-head
9
- - jruby-19mode
10
- - jruby-head
10
+ - jruby-9.0
11
11
  - rbx-2
12
12
  matrix:
13
13
  allow_failures:
14
14
  - rvm: rbx-2
15
- - rvm: jruby-head
16
15
  - rvm: ruby-head
17
16
  gemfile:
18
17
  - Gemfile
@@ -33,5 +32,3 @@ notifications:
33
32
  - halostatue@gmail.com
34
33
  on_success: change
35
34
  on_failure: always
36
- sudo:
37
- false
@@ -0,0 +1,5 @@
1
+ #! zsh
2
+
3
+ --workenv-tab --first
4
+ --workenv-tab --desc autotest autotest
5
+ --workenv-tab --desc documents "fswatch -o *.rdoc lib/**/*.rb| xargs -n1 -I{} rake docs"
data/Gemfile CHANGED
@@ -3,7 +3,9 @@
3
3
  # NOTE: This file is present to keep Travis CI happy. Edits to it will not
4
4
  # be accepted.
5
5
 
6
- source "https://rubygems.org/"
6
+ source 'https://rubygems.org/'
7
7
  gemspec
8
8
 
9
+ gem 'stockpile', path: ENV['LOCAL_STOCKPILE'] if ENV['LOCAL_STOCKPILE']
10
+
9
11
  # vim: syntax=ruby
@@ -0,0 +1,40 @@
1
+ ### 2.0 / 2016-04-04
2
+
3
+ * 1 major change
4
+
5
+ * Dropped support for Ruby 1.9
6
+
7
+ * 1 minor change
8
+
9
+ * Changed Rails environment support from looking for Rails.env to
10
+ RAILS_ENV.
11
+
12
+ * 1 bugfix
13
+
14
+ * Fix [issue #1][]. OpenStruct is now supported for Stockpile options.
15
+
16
+ * 1 governance change:
17
+
18
+ * Stockpile::Redis is under the Contributer Covenant Code of Conduct.
19
+
20
+ * Miscellaneous
21
+
22
+ * Added Rubocop.
23
+
24
+ ### 1.1 / 2015-02-10
25
+
26
+ * 2 minor enhancements
27
+
28
+ * Modified Stockpile::Redis to be implemented based on the new
29
+ Stockpile::Base class provided in stockpile 1.1.
30
+
31
+ * Implemented the +namespace+ option for client connections to add additional
32
+ namespace support to individual child connections.
33
+
34
+ ### 1.0 / 2015-01-21
35
+
36
+ * 1 major enhancement
37
+
38
+ * Birthday!
39
+
40
+ [issue #1]: https://github.com/halostatue/stockpile-redis/issues/1
@@ -2,7 +2,7 @@
2
2
 
3
3
  This software is available under an MIT-style licence.
4
4
 
5
- * Copyright 2015 Austin Ziegler
5
+ * Copyright 2015–2016 Austin Ziegler
6
6
 
7
7
  Permission is hereby granted, free of charge, to any person obtaining a copy of
8
8
  this software and associated documentation files (the "Software"), to deal in
@@ -1,10 +1,13 @@
1
1
  .autotest
2
2
  .gemtest
3
3
  .minitest.rb
4
+ .rubocop.yml
5
+ .simplecov-prelude.rb
4
6
  .travis.yml
7
+ .workenv
5
8
  Contributing.rdoc
6
9
  Gemfile
7
- History.rdoc
10
+ History.md
8
11
  Licence.rdoc
9
12
  Manifest.txt
10
13
  README.rdoc
@@ -2,7 +2,7 @@
2
2
 
3
3
  code :: https://github.com/halostatue/stockpile-redis/
4
4
  bugs :: https://github.com/halostatue/stockpile-redis/issues
5
- continuous integration :: {<img src="https://travis-ci.org/halostatue/stockpile-redis.png" />}[https://travis-ci.org/halostatue/stockpile-redis]
5
+ continuous integration :: {<img src="https://travis-ci.org/halostatue/stockpile-redis.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/halostatue/stockpile-redis]
6
6
 
7
7
  == Description
8
8
 
@@ -18,8 +18,8 @@ Redis.new)</tt>).
18
18
  stockpile-redis provides special-case handling for connections for Resque when
19
19
  the name of the client is +:resque+.
20
20
 
21
- Release 1.1 adds a minor enhancement to allow for namespaces for named clients
22
- using Stockpile::Redis#connection_for.
21
+ Release 2.0 fixes an issue with initialization using OpenStruct for options.
22
+ Ruby 1.9 is no longer supported.
23
23
 
24
24
  == Synopsis
25
25
 
@@ -105,7 +105,7 @@ using Stockpile::Redis#connection_for.
105
105
 
106
106
  Put stockpile-redis in your Gemfile:
107
107
 
108
- gem 'stockpile-redis', '~> 1.1'
108
+ gem 'stockpile-redis', '~> 2.0'
109
109
 
110
110
  Or manually install:
111
111
 
data/Rakefile CHANGED
@@ -2,55 +2,63 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'hoe'
5
+ require 'rake/clean'
5
6
 
6
7
  Hoe.plugin :doofus
8
+ Hoe.plugin :email unless ENV['CI'] || ENV['TRAVIS']
7
9
  Hoe.plugin :gemspec2
8
10
  Hoe.plugin :git
9
11
  Hoe.plugin :minitest
10
12
  Hoe.plugin :travis
11
- Hoe.plugin :email unless ENV['CI'] or ENV['TRAVIS']
12
13
 
13
14
  spec = Hoe.spec 'stockpile-redis' do
14
15
  developer('Austin Ziegler', 'halostatue@gmail.com')
15
16
 
16
- self.history_file = 'History.rdoc'
17
+ self.history_file = 'History.md'
17
18
  self.readme_file = 'README.rdoc'
18
- self.extra_rdoc_files = FileList["*.rdoc"].to_a
19
-
20
- license "MIT"
21
-
22
- self.need_tar = true
23
- self.require_ruby_version '>= 1.9.2'
24
-
25
- self.extra_deps << ['stockpile', '~> 1.1']
26
- self.extra_deps << ['redis', '~> 3.0']
27
- self.extra_deps << ['redis-namespace', '~> 1.0']
28
- self.extra_dev_deps << ['fakeredis', '~> 0.5']
29
- self.extra_dev_deps << ['hoe-doofus', '~> 1.0']
30
- self.extra_dev_deps << ['hoe-gemspec2', '~> 1.1']
31
- self.extra_dev_deps << ['hoe-git', '~> 1.5']
32
- self.extra_dev_deps << ['hoe-travis', '~> 1.2']
33
- self.extra_dev_deps << ['minitest', '~> 5.4']
34
- self.extra_dev_deps << ['minitest-around', '~> 0.3']
35
- self.extra_dev_deps << ['minitest-autotest', '~> 1.0']
36
- self.extra_dev_deps << ['minitest-bisect', '~> 1.2']
37
- self.extra_dev_deps << ['minitest-focus', '~> 1.1']
38
- self.extra_dev_deps << ['minitest-moar', '~> 0.0']
39
- self.extra_dev_deps << ['minitest-pretty_diff', '~> 0.1']
40
- self.extra_dev_deps << ['rake', '>= 10.0']
41
- self.extra_dev_deps << ['redis-namespace', '~> 1.5']
42
- self.extra_dev_deps << ['simplecov', '~> 0.7']
19
+
20
+ license 'MIT'
21
+
22
+ require_ruby_version '>= 2.0'
23
+
24
+ extra_deps << ['stockpile', '~> 2.0']
25
+ extra_deps << ['redis', '~> 3.0']
26
+ extra_deps << ['redis-namespace', '~> 1.0']
27
+ extra_dev_deps << ['fakeredis', '~> 0.5']
28
+ extra_dev_deps << ['hoe-doofus', '~> 1.0']
29
+ extra_dev_deps << ['hoe-gemspec2', '~> 1.1']
30
+ extra_dev_deps << ['hoe-git', '~> 1.5']
31
+ extra_dev_deps << ['hoe-travis', '~> 1.2']
32
+ extra_dev_deps << ['minitest', '~> 5.4']
33
+ extra_dev_deps << ['minitest-autotest', '~> 1.0']
34
+ extra_dev_deps << ['minitest-bisect', '~> 1.2']
35
+ extra_dev_deps << ['minitest-bonus-assertions', '~> 2.0']
36
+ extra_dev_deps << ['minitest-focus', '~> 1.1']
37
+ extra_dev_deps << ['minitest-moar', '~> 0.0']
38
+ extra_dev_deps << ['minitest-pretty_diff', '~> 0.1']
39
+ extra_dev_deps << ['rake', '>= 10.0']
40
+ extra_dev_deps << ['redis-namespace', '~> 1.5']
41
+ extra_dev_deps << ['simplecov', '~> 0.7']
42
+ end
43
+
44
+ module Hoe::Publish
45
+ alias_method :original_make_rdoc_cmd, :make_rdoc_cmd
46
+
47
+ def make_rdoc_cmd(*extra_args) # :nodoc:
48
+ spec.extra_rdoc_files.reject! { |f| f == 'Manifest.txt' }
49
+ original_make_rdoc_cmd(*extra_args)
50
+ end
43
51
  end
44
52
 
45
53
  namespace :test do
46
54
  task :coverage do
47
- spec.test_prelude = [
48
- 'require "simplecov"',
49
- 'SimpleCov.start("test_frameworks") { command_name "Minitest" }',
50
- 'gem "minitest"'
51
- ].join('; ')
55
+ spec.test_prelude = %q(load ".simplecov-prelude.rb")
52
56
  Rake::Task['test'].execute
53
57
  end
58
+
59
+ CLOBBER << 'coverage'
54
60
  end
55
61
 
62
+ CLOBBER << 'tmp'
63
+
56
64
  # vim: syntax=ruby
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  require 'stockpile/redis'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # coding: utf-8
2
3
 
3
4
  require 'redis'
@@ -7,7 +8,7 @@ require 'stockpile/base'
7
8
  class Stockpile
8
9
  # A connection manager for Redis.
9
10
  class Redis < Stockpile::Base
10
- VERSION = '1.1' # :nodoc:
11
+ VERSION = '2.0' # :nodoc:
11
12
 
12
13
  # Create a new Redis connection manager with the provided options.
13
14
  #
@@ -28,11 +29,10 @@ class Stockpile
28
29
  super
29
30
 
30
31
  @redis_options = (@options.delete(:redis) || {}).dup
32
+ @redis_options = @redis_options.to_h unless @redis_options.kind_of?(Hash)
31
33
  @namespace = @options.fetch(:namespace) {
32
34
  @redis_options.fetch(:namespace) {
33
- ENV['REDIS_NAMESPACE'] ||
34
- (defined?(::Rails) && ::Rails.env) ||
35
- ENV['RACK_ENV']
35
+ ENV['REDIS_NAMESPACE'] || ENV['RAILS_ENV'] || ENV['RACK_ENV']
36
36
  }
37
37
  }
38
38
 
@@ -142,6 +142,7 @@ class Stockpile
142
142
  # :method: disconnect
143
143
 
144
144
  private
145
+
145
146
  def client_connect(name = nil, options = {})
146
147
  options = { namespace: options[:namespace] }
147
148
 
@@ -153,11 +154,11 @@ class Stockpile
153
154
  end
154
155
  end
155
156
 
156
- def client_reconnect(redis = connection())
157
+ def client_reconnect(redis = connection)
157
158
  redis.client.reconnect if redis
158
159
  end
159
160
 
160
- def client_disconnect(redis = connection())
161
+ def client_disconnect(redis = connection)
161
162
  redis.quit if redis
162
163
  end
163
164
 
@@ -187,7 +188,7 @@ class Stockpile
187
188
  if r.instance_of?(::Redis::Namespace) && r.namespace.to_s !~ /:resque\z/
188
189
  r = ::Redis::Namespace.new(:"#{r.namespace}:resque", redis: r.redis)
189
190
  elsif r.instance_of?(::Redis)
190
- r = ::Redis::Namespace.new("resque", redis: r)
191
+ r = ::Redis::Namespace.new('resque', redis: r)
191
192
  end
192
193
 
193
194
  r
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # -*- ruby encoding: utf-8 -*-
2
3
 
3
4
  gem 'minitest'
@@ -22,11 +23,7 @@ module Minitest::ENVStub
22
23
  def stub_env env, options = {}, *block_args, &block
23
24
  mock = lambda { |key|
24
25
  env.fetch(key) { |k|
25
- if options[:passthrough]
26
- ENV.send(:"__minitest_stub__[]", k)
27
- else
28
- nil
29
- end
26
+ ENV.send(:"__minitest_stub__[]", k) if options[:passthrough]
30
27
  }
31
28
  }
32
29
 
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
1
2
  require 'minitest_config'
2
3
  require 'stockpile/redis'
3
4
  require 'time'
4
5
 
5
6
  describe Stockpile do
6
- describe ".inject!" do
7
+ describe '.inject!' do
7
8
  let(:mod) { Module.new }
8
9
  let(:lrt) {
9
10
  Module.new do
@@ -18,25 +19,25 @@ describe Stockpile do
18
19
  end
19
20
  }
20
21
 
21
- describe "Mod.cache_adapter" do
22
+ describe 'Mod.cache_adapter' do
22
23
  let(:now) { Time.now }
23
24
  before { ::Stockpile.inject_redis!(mod, adaptable: true) }
24
25
 
25
- it "adapts the cache with last_run_time" do
26
+ it 'adapts the cache with last_run_time' do
26
27
  mod.cache_adapter(lrt)
27
28
  assert_nil mod.cache.last_run_time('foo')
28
29
  assert_equal true, mod.cache.last_run_time('foo', now)
29
30
  assert_equal now.to_i, mod.cache.last_run_time('foo').to_i
30
31
  end
31
32
 
32
- it "adapts the module with last_run_time" do
33
+ it 'adapts the module with last_run_time' do
33
34
  mod.cache_adapter(lrt, mod)
34
35
  assert_nil mod.last_run_time('foo')
35
36
  assert_equal true, mod.last_run_time('foo', now)
36
37
  assert_equal now.to_i, mod.last_run_time('foo').to_i
37
38
  end
38
39
 
39
- it "adapts the lrt module with last_run_time" do
40
+ it 'adapts the lrt module with last_run_time' do
40
41
  mod.cache_adapter!(lrt)
41
42
  assert_nil lrt.last_run_time('foo')
42
43
  assert_equal true, lrt.last_run_time('foo', now)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'minitest_config'
2
3
  require 'stockpile/redis'
3
4
 
@@ -13,19 +14,17 @@ describe Stockpile::Redis do
13
14
  let(:rcm_narrow) { stub_env({}) { Stockpile::Redis.new(narrow: true) } }
14
15
 
15
16
  describe 'constructor' do
16
- it "uses the default connection width by default" do
17
+ it 'uses the default connection width by default' do
17
18
  stub ::Stockpile, :narrow?, lambda { false } do
18
- refute Stockpile::Redis.new.narrow?,
19
- "should be narrow, but is not"
19
+ refute Stockpile::Redis.new.narrow?, 'should be narrow, but is not'
20
20
  end
21
21
 
22
22
  stub ::Stockpile, :narrow?, lambda { true } do
23
- assert Stockpile::Redis.new.narrow?,
24
- "is not narrow, but should be"
23
+ assert Stockpile::Redis.new.narrow?, 'is not narrow, but should be'
25
24
  end
26
25
  end
27
26
 
28
- it "can be told which connection width to use explicitly" do
27
+ it 'can be told which connection width to use explicitly' do
29
28
  stub ::Stockpile, :narrow?, lambda { false } do
30
29
  assert rcm_narrow.narrow?
31
30
  end
@@ -35,7 +34,7 @@ describe Stockpile::Redis do
35
34
  end
36
35
  end
37
36
 
38
- it "passes settings through to Redis" do
37
+ it 'passes settings through to Redis' do
39
38
  options = {
40
39
  redis: {
41
40
  url: 'redis://xyz/'
@@ -45,98 +44,103 @@ describe Stockpile::Redis do
45
44
  assert_equal 'xyz', rcm.connect.client.options[:host]
46
45
  end
47
46
 
48
- it "has no clients by default" do
47
+ it 'passes settings through to Redis with an OpenStruct' do
48
+ require 'ostruct'
49
+ options = OpenStruct.new(redis: { url: 'redis://xyz/' })
50
+ rcm = ::Stockpile::Redis.new(options)
51
+ assert_equal 'xyz', rcm.connect.client.options[:host]
52
+ end
53
+
54
+ it 'passes settings through to Redis with a nested OpenStruct' do
55
+ require 'ostruct'
56
+ redis_options = OpenStruct.new(url: 'redis://xyz/')
57
+ options = OpenStruct.new(redis: redis_options)
58
+ rcm = ::Stockpile::Redis.new(options)
59
+ assert_equal 'xyz', rcm.connect.client.options[:host]
60
+ end
61
+
62
+ it 'has no clients by default' do
49
63
  assert_clients [], ::Stockpile::Redis.new
50
64
  end
51
65
 
52
- describe "namespace support" do
66
+ describe 'namespace support' do
53
67
  def assert_namespace(client)
54
68
  assert_equal 'stockpile', client.instance_variable_get(:@namespace)
55
69
  end
56
70
 
57
- it "will set namespace from ENV['REDIS_NAMESPACE']" do
58
- stub_env({ 'REDIS_NAMESPACE' => 'stockpile' }) do
71
+ it %q(will set namespace from ENV['REDIS_NAMESPACE']) do
72
+ stub_env('REDIS_NAMESPACE' => 'stockpile') do
59
73
  assert_namespace ::Stockpile::Redis.new
60
74
  end
61
75
  end
62
76
 
63
- it "will set namespace from Rails.env" do
64
- begin
65
- ::Rails = Class.new do
66
- def self.env
67
- 'stockpile'
68
- end
69
- end
70
-
71
- stub_env({}) do
72
- assert_namespace ::Stockpile::Redis.new
73
- end
74
- ensure
75
- Object.send(:remove_const, :Rails)
77
+ it 'will set namespace from RAILS_ENV' do
78
+ stub_env('RAILS_ENV' => 'stockpile') do
79
+ assert_namespace ::Stockpile::Redis.new
76
80
  end
77
81
  end
78
82
 
79
- it "will set namespace from ENV['RACK_ENV']" do
80
- stub_env({ 'RACK_ENV' => 'stockpile' }) do
83
+ it %q(will set namespace from ENV['RACK_ENV']) do
84
+ stub_env('RACK_ENV' => 'stockpile') do
81
85
  assert_namespace ::Stockpile::Redis.new
82
86
  end
83
87
  end
84
88
 
85
- it "will set namespace from parameters" do
86
- stub_env({ 'RACK_ENV' => 'test' }) do
89
+ it 'will set namespace from parameters' do
90
+ stub_env('RACK_ENV' => 'test') do
87
91
  assert_namespace ::Stockpile::Redis.new(namespace: 'stockpile')
88
92
  end
89
93
  end
90
94
  end
91
95
  end
92
96
 
93
- describe "#connect" do
94
- it "creates a connection to Redis" do
97
+ describe '#connect' do
98
+ it 'creates a connection to Redis' do
95
99
  assert_nil rcm.connection
96
100
  refute_nil rcm.connect
97
101
  assert_kind_of ::Redis, rcm.connection
98
102
  end
99
103
 
100
- it "creates a namespaced connection to Redis" do
104
+ it 'creates a namespaced connection to Redis' do
101
105
  assert_nil rcm_namespace.connection
102
106
  refute_nil rcm_namespace.connect
103
107
  assert_kind_of ::Redis::Namespace, rcm_namespace.connection
104
108
  end
105
109
 
106
- describe "with a wide connection width" do
110
+ describe 'with a wide connection width' do
107
111
  before do
108
112
  rcm_wide.connect(:redis, rollout: { namespace: 'rollout' })
109
113
  end
110
114
 
111
- it "connects multiple clients" do
115
+ it 'connects multiple clients' do
112
116
  assert_clients [ :redis, :rollout ], rcm_wide
113
117
  end
114
118
 
115
- it "creates a Redis::Namespace for rollout" do
119
+ it 'creates a Redis::Namespace for rollout' do
116
120
  assert_kind_of Redis::Namespace, rcm_wide.connection_for(:rollout)
117
121
  end
118
122
 
119
- it "connects *different* clients" do
123
+ it 'connects *different* clients' do
120
124
  refute_same rcm_wide.connection, rcm_wide.connection_for(:redis)
121
125
  refute_same rcm_wide.connection, rcm_wide.connection_for(:rollout)
122
126
  refute_same rcm_wide.connection_for(:redis), rcm_wide.connection_for(:rollout)
123
127
  end
124
128
  end
125
129
 
126
- describe "with a narrow connection width" do
130
+ describe 'with a narrow connection width' do
127
131
  before do
128
132
  rcm_narrow.connect(:redis, rollout: { namespace: 'rollout' })
129
133
  end
130
134
 
131
- it "appears to connect multiple clients" do
135
+ it 'appears to connect multiple clients' do
132
136
  assert_clients [ :redis, :rollout ], rcm_narrow
133
137
  end
134
138
 
135
- it "creates a Redis::Namespace for rollout" do
139
+ it 'creates a Redis::Namespace for rollout' do
136
140
  assert_kind_of Redis::Namespace, rcm_narrow.connection_for(:rollout)
137
141
  end
138
142
 
139
- it "returns identical clients" do
143
+ it 'returns identical clients' do
140
144
  assert_same rcm_narrow.connection, rcm_narrow.connection_for(:redis)
141
145
  refute_same rcm_narrow.connection, rcm_narrow.connection_for(:rollout)
142
146
  assert_same rcm_narrow.connection,
@@ -148,28 +152,28 @@ describe Stockpile::Redis do
148
152
  end
149
153
  end
150
154
 
151
- describe "#connection_for" do
152
- describe "with a wide connection width" do
153
- it "connects the main client" do
155
+ describe '#connection_for' do
156
+ describe 'with a wide connection width' do
157
+ it 'connects the main client' do
154
158
  rcm_wide.connection_for(:global)
155
159
  assert rcm_wide.connection
156
160
  refute_same rcm_wide.connection, rcm_wide.connection_for(:global)
157
161
  end
158
162
 
159
- it "wraps a :resque client in Redis::Namespace" do
163
+ it 'wraps a :resque client in Redis::Namespace' do
160
164
  assert_kind_of Redis::Namespace, rcm_wide.connection_for(:resque)
161
- assert_equal "resque", rcm_wide.connection_for(:resque).namespace
165
+ assert_equal 'resque', rcm_wide.connection_for(:resque).namespace
162
166
  end
163
167
  end
164
168
 
165
- describe "with a narrow connection width" do
166
- it "connects the main client" do
169
+ describe 'with a narrow connection width' do
170
+ it 'connects the main client' do
167
171
  rcm_narrow.connection_for(:global)
168
172
  assert rcm_narrow.connection
169
173
  assert_same rcm_narrow.connection, rcm_narrow.connection_for(:global)
170
174
  end
171
175
 
172
- it "wraps a :resque client in Redis::Namespace" do
176
+ it 'wraps a :resque client in Redis::Namespace' do
173
177
  assert_kind_of Redis::Namespace, rcm_narrow.connection_for(:resque)
174
178
  end
175
179
  end
@@ -177,8 +181,8 @@ describe Stockpile::Redis do
177
181
 
178
182
  # #disconnect cannot be tested with FakeRedis because the FakeRedis
179
183
  # #connected? method always returns true.
180
- describe "#disconnect" do
181
- describe "with a wide connection width" do
184
+ describe '#disconnect' do
185
+ describe 'with a wide connection width' do
182
186
  let(:global) { rcm_wide.connection }
183
187
  let(:redis) { rcm_wide.connection_for(:redis) }
184
188
 
@@ -188,7 +192,7 @@ describe Stockpile::Redis do
188
192
  redis.client.connect
189
193
  end
190
194
 
191
- it "disconnects the global client" do
195
+ it 'disconnects the global client' do
192
196
  instance_stub Redis, :quit do
193
197
  force_connection
194
198
  rcm_wide.disconnect
@@ -196,7 +200,7 @@ describe Stockpile::Redis do
196
200
  assert_instance_called Redis, :quit, 1
197
201
  end
198
202
 
199
- it "disconnects the redis and global clients" do
203
+ it 'disconnects the redis and global clients' do
200
204
  instance_stub Redis, :quit do
201
205
  force_connection
202
206
  rcm_wide.disconnect(:redis)
@@ -205,7 +209,7 @@ describe Stockpile::Redis do
205
209
  end
206
210
  end
207
211
 
208
- describe "with a narrow connection width" do
212
+ describe 'with a narrow connection width' do
209
213
  let(:global) { rcm_narrow.connection }
210
214
  let(:redis) { rcm_narrow.connection_for(:redis) }
211
215
 
@@ -215,7 +219,7 @@ describe Stockpile::Redis do
215
219
  redis.client.connect
216
220
  end
217
221
 
218
- it "disconnects the global client" do
222
+ it 'disconnects the global client' do
219
223
  instance_stub Redis, :quit do
220
224
  force_connection
221
225
  rcm_narrow.disconnect
@@ -223,7 +227,7 @@ describe Stockpile::Redis do
223
227
  assert_instance_called Redis, :quit, 1
224
228
  end
225
229
 
226
- it "disconnects the redis and global clients" do
230
+ it 'disconnects the redis and global clients' do
227
231
  instance_stub Redis, :quit do
228
232
  force_connection
229
233
  rcm_narrow.disconnect(:redis)
@@ -235,8 +239,8 @@ describe Stockpile::Redis do
235
239
 
236
240
  # #reconnect cannot be tested with FakeRedis because the FakeRedis
237
241
  # #connected? method always returns true.
238
- describe "#reconnect" do
239
- describe "with a wide connection width" do
242
+ describe '#reconnect' do
243
+ describe 'with a wide connection width' do
240
244
  let(:global) { rcm_wide.connection }
241
245
  let(:redis) { rcm_wide.connection_for(:redis) }
242
246
 
@@ -246,7 +250,7 @@ describe Stockpile::Redis do
246
250
  redis.client.connect
247
251
  end
248
252
 
249
- it "reconnects the global client" do
253
+ it 'reconnects the global client' do
250
254
  instance_stub Redis::Client, :reconnect do
251
255
  force_connection
252
256
  rcm_wide.reconnect
@@ -254,7 +258,7 @@ describe Stockpile::Redis do
254
258
  assert_instance_called Redis::Client, :reconnect, 1
255
259
  end
256
260
 
257
- it "reconnects the redis and global clients" do
261
+ it 'reconnects the redis and global clients' do
258
262
  instance_stub Redis::Client, :reconnect do
259
263
  force_connection
260
264
  rcm_wide.reconnect(:redis)
@@ -263,7 +267,7 @@ describe Stockpile::Redis do
263
267
  end
264
268
  end
265
269
 
266
- describe "with a narrow connection width" do
270
+ describe 'with a narrow connection width' do
267
271
  let(:global) { rcm_narrow.connection }
268
272
  let(:redis) { rcm_narrow.connection_for(:redis) }
269
273
 
@@ -273,7 +277,7 @@ describe Stockpile::Redis do
273
277
  redis.client.connect
274
278
  end
275
279
 
276
- it "reconnects the global client" do
280
+ it 'reconnects the global client' do
277
281
  instance_stub Redis::Client, :reconnect do
278
282
  force_connection
279
283
  rcm_narrow.reconnect
@@ -281,7 +285,7 @@ describe Stockpile::Redis do
281
285
  assert_instance_called Redis::Client, :reconnect, 1
282
286
  end
283
287
 
284
- it "reconnects the redis and global clients" do
288
+ it 'reconnects the redis and global clients' do
285
289
  instance_stub Redis::Client, :reconnect do
286
290
  force_connection
287
291
  rcm_narrow.reconnect(:redis)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stockpile-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
4
+ version: '2.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Ziegler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-10 00:00:00.000000000 Z
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stockpile
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.1'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.1'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: redis
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '5.5'
61
+ version: '5.8'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '5.5'
68
+ version: '5.8'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rdoc
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -151,47 +151,47 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '1.2'
153
153
  - !ruby/object:Gem::Dependency
154
- name: minitest-around
154
+ name: minitest-autotest
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '0.3'
159
+ version: '1.0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '0.3'
166
+ version: '1.0'
167
167
  - !ruby/object:Gem::Dependency
168
- name: minitest-autotest
168
+ name: minitest-bisect
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: '1.0'
173
+ version: '1.2'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '1.0'
180
+ version: '1.2'
181
181
  - !ruby/object:Gem::Dependency
182
- name: minitest-bisect
182
+ name: minitest-bonus-assertions
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: '1.2'
187
+ version: '2.0'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: '1.2'
194
+ version: '2.0'
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: minitest-focus
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -268,14 +268,14 @@ dependencies:
268
268
  requirements:
269
269
  - - "~>"
270
270
  - !ruby/object:Gem::Version
271
- version: '3.13'
271
+ version: '3.15'
272
272
  type: :development
273
273
  prerelease: false
274
274
  version_requirements: !ruby/object:Gem::Requirement
275
275
  requirements:
276
276
  - - "~>"
277
277
  - !ruby/object:Gem::Version
278
- version: '3.13'
278
+ version: '3.15'
279
279
  description: |-
280
280
  stockpile-redis is a connection manager for Redis to be used with
281
281
  {Stockpile}[https://github.com/halostatue/stockpile].
@@ -285,7 +285,7 @@ executables: []
285
285
  extensions: []
286
286
  extra_rdoc_files:
287
287
  - Contributing.rdoc
288
- - History.rdoc
288
+ - History.md
289
289
  - Licence.rdoc
290
290
  - Manifest.txt
291
291
  - README.rdoc
@@ -293,10 +293,13 @@ files:
293
293
  - ".autotest"
294
294
  - ".gemtest"
295
295
  - ".minitest.rb"
296
+ - ".rubocop.yml"
297
+ - ".simplecov-prelude.rb"
296
298
  - ".travis.yml"
299
+ - ".workenv"
297
300
  - Contributing.rdoc
298
301
  - Gemfile
299
- - History.rdoc
302
+ - History.md
300
303
  - Licence.rdoc
301
304
  - Manifest.txt
302
305
  - README.rdoc
@@ -320,7 +323,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
320
323
  requirements:
321
324
  - - ">="
322
325
  - !ruby/object:Gem::Version
323
- version: 1.9.2
326
+ version: '2.0'
324
327
  required_rubygems_version: !ruby/object:Gem::Requirement
325
328
  requirements:
326
329
  - - ">="
@@ -328,7 +331,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
328
331
  version: '0'
329
332
  requirements: []
330
333
  rubyforge_project:
331
- rubygems_version: 2.2.2
334
+ rubygems_version: 2.5.1
332
335
  signing_key:
333
336
  specification_version: 4
334
337
  summary: stockpile-redis is a connection manager for Redis to be used with {Stockpile}[https://github.com/halostatue/stockpile].
@@ -1,15 +0,0 @@
1
- === 1.1 / 2015-02-10
2
-
3
- * 2 minor enhancements
4
-
5
- * Modified Stockpile::Redis to be implmented based on the new Stockpile::Base
6
- class provided in stockpile 1.1.
7
-
8
- * Implemented the +namespace+ option for client connections to add additional
9
- namespace support to individual child connections.
10
-
11
- === 1.0 / 2015-01-21
12
-
13
- * 1 major enhancement
14
-
15
- * Birthday!