flipper-redis 0.20.0 → 0.21.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/redis/README.md +14 -5
- data/examples/redis/basic.rb +1 -5
- data/examples/redis/internals.rb +1 -5
- data/examples/redis/namespaced.rb +3 -14
- data/lib/flipper-redis.rb +7 -0
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/adapters/redis_cache_spec.rb +5 -1
- data/spec/flipper/adapters/redis_spec.rb +14 -1
- data/test/adapters/redis_cache_test.rb +2 -0
- data/test/adapters/redis_test.rb +2 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fbd6aff802f007a9bd178485743a95ee7b44d536490c46d882eae42c3c64c36
|
4
|
+
data.tar.gz: d909399cc8b412d826bf09eb984e5a9800212cb0fcec8bfcc03a42c6159f7cc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a2d731225227ffda4d4f2262dde5ac7b3a93ab871acf9e71b8c7ed8d4fb4eba395f5e28200b396023ab7bb1b869304617b867305b763ed45408e2fb1f2c9be0
|
7
|
+
data.tar.gz: 55610c15c3d080c2f7894d896664518a594ad60ea0c80ac47ca8ff515332cef5f6796ad0fdff5404903b5470b79dd78a29862225198e459ff6ef06d493d2f9ad
|
data/docs/redis/README.md
CHANGED
@@ -18,12 +18,21 @@ Or install it yourself with:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
+
In most cases, all you need to do is require the adapter. It will connect to the Redis instance specified in the `REDIS_URL` or `FLIPPER_REDIS_URL` environment vairable, or localhost by default.
|
22
|
+
|
21
23
|
```ruby
|
22
|
-
require 'flipper
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
require 'flipper-redis'
|
25
|
+
```
|
26
|
+
|
27
|
+
**If you need to customize the adapter**, you can add this to an initializer:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
Flipper.configure do |config|
|
31
|
+
config.default do
|
32
|
+
client = Redis.new(url: ENV["FLIPPER_REDIS_URL"] || ENV["REDIS_URL"])
|
33
|
+
Flipper.new(Flipper::Adapters::Redis.new(client))
|
34
|
+
end
|
35
|
+
end
|
27
36
|
```
|
28
37
|
|
29
38
|
## Internals
|
data/examples/redis/basic.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'bundler/setup'
|
2
2
|
require 'logger'
|
3
3
|
|
4
|
-
root_path = Pathname(__FILE__).dirname.join('..').expand_path
|
5
|
-
lib_path = root_path.join('lib')
|
6
|
-
$:.unshift(lib_path)
|
7
|
-
|
8
4
|
require 'flipper/adapters/redis'
|
9
5
|
options = {}
|
10
6
|
if ENV['REDIS_URL']
|
data/examples/redis/internals.rb
CHANGED
@@ -1,11 +1,7 @@
|
|
1
|
+
require 'bundler/setup'
|
1
2
|
require 'pp'
|
2
|
-
require 'pathname'
|
3
3
|
require 'logger'
|
4
4
|
|
5
|
-
root_path = Pathname(__FILE__).dirname.join('..').expand_path
|
6
|
-
lib_path = root_path.join('lib')
|
7
|
-
$:.unshift(lib_path)
|
8
|
-
|
9
5
|
require 'flipper/adapters/redis'
|
10
6
|
|
11
7
|
options = {}
|
@@ -1,18 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require 'logger'
|
4
|
-
begin
|
5
|
-
require 'redis-namespace'
|
6
|
-
rescue LoadError
|
7
|
-
puts 'you must have redis-namespace gem installed'
|
8
|
-
exit 1
|
9
|
-
end
|
10
|
-
|
11
|
-
root_path = Pathname(__FILE__).dirname.join('..').expand_path
|
12
|
-
lib_path = root_path.join('lib')
|
13
|
-
$:.unshift(lib_path)
|
14
|
-
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'redis-namespace'
|
15
3
|
require 'flipper/adapters/redis'
|
4
|
+
|
16
5
|
options = {url: 'redis://127.0.0.1:6379'}
|
17
6
|
if ENV['REDIS_URL']
|
18
7
|
options[:url] = ENV['REDIS_URL']
|
data/lib/flipper-redis.rb
CHANGED
data/lib/flipper/version.rb
CHANGED
@@ -19,7 +19,11 @@ RSpec.describe Flipper::Adapters::RedisCache do
|
|
19
19
|
subject { adapter }
|
20
20
|
|
21
21
|
before do
|
22
|
-
|
22
|
+
begin
|
23
|
+
client.flushdb
|
24
|
+
rescue Redis::CannotConnectError
|
25
|
+
ENV['CI'] ? raise : skip('Redis not available')
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
29
|
it_should_behave_like 'a flipper adapter'
|
@@ -14,8 +14,21 @@ RSpec.describe Flipper::Adapters::Redis do
|
|
14
14
|
subject { described_class.new(client) }
|
15
15
|
|
16
16
|
before do
|
17
|
-
|
17
|
+
begin
|
18
|
+
client.flushdb
|
19
|
+
rescue Redis::CannotConnectError
|
20
|
+
ENV['CI'] ? raise : skip('Redis not available')
|
21
|
+
end
|
18
22
|
end
|
19
23
|
|
20
24
|
it_should_behave_like 'a flipper adapter'
|
25
|
+
|
26
|
+
it 'configures itself on load' do
|
27
|
+
Flipper.configuration = nil
|
28
|
+
Flipper.instance = nil
|
29
|
+
|
30
|
+
load 'flipper-redis.rb'
|
31
|
+
|
32
|
+
expect(Flipper.adapter.adapter).to be_a(Flipper::Adapters::Redis)
|
33
|
+
end
|
21
34
|
end
|
@@ -9,6 +9,8 @@ class RedisCacheTest < MiniTest::Test
|
|
9
9
|
@cache = Redis.new(url: url).tap(&:flushdb)
|
10
10
|
memory_adapter = Flipper::Adapters::Memory.new
|
11
11
|
@adapter = Flipper::Adapters::RedisCache.new(memory_adapter, @cache)
|
12
|
+
rescue Redis::CannotConnectError
|
13
|
+
ENV['CI'] ? raise : skip('Reids not available')
|
12
14
|
end
|
13
15
|
|
14
16
|
def teardown
|
data/test/adapters/redis_test.rb
CHANGED
@@ -8,5 +8,7 @@ class RedisTest < MiniTest::Test
|
|
8
8
|
url = ENV.fetch('REDIS_URL', 'redis://localhost:6379')
|
9
9
|
client = Redis.new(url: url).tap(&:flushdb)
|
10
10
|
@adapter = Flipper::Adapters::Redis.new(client)
|
11
|
+
rescue Redis::CannotConnectError
|
12
|
+
ENV['CI'] ? raise : skip('Redis not available')
|
11
13
|
end
|
12
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipper-redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: flipper
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.21.0.rc1
|
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: 0.
|
26
|
+
version: 0.21.0.rc1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: redis
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,9 +80,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
80
80
|
version: '0'
|
81
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
|
-
- - "
|
83
|
+
- - ">"
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
85
|
+
version: 1.3.1
|
86
86
|
requirements: []
|
87
87
|
rubygems_version: 3.0.3
|
88
88
|
signing_key:
|