flipper-redis 0.7.0.beta1 → 0.7.0.beta4

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: f87e5b265f72a14e8ad14af144ec4a6587fb4520
4
- data.tar.gz: 6dce4778d6ba7119839dde4ab9c58a6f7664abfb
3
+ metadata.gz: 4da9e39f7481e118dc8e7a7ec70d259ddca94a4e
4
+ data.tar.gz: a43ca999d29163a4c3183a5013c542935d5a021a
5
5
  SHA512:
6
- metadata.gz: 954c2d9187dc094ec4d8580797a389e8b27c126a7c6db86421747ec3b175c9d5e1fe5de50393f648551b8acbccd02b9bb6455c4fa4e7565c4af797332132ad24
7
- data.tar.gz: d23a80b8726e69e9b0c8a59e33ef6f50ad27f67d26f398547e1ba603a9cf0a18d674ddaf6ba0c129dcc5a2f0b3dd418a1cc9074251e0d57c4683396de5c0afd4
6
+ metadata.gz: 643e4db8d5482133157a1f128eb95a69c4140e600676642a7cb0132ce921d32c3c632061b72cfe6ee10469b21dc07c8e776daa870cc3c7cc3f90f80c9613898b
7
+ data.tar.gz: 026d30c28bbce7df01c84162001f2985461fbfa595c8c75656c6bbdf496f4135df5d0d89ce8748439b7998e90eea1be544b19b1a94d67f24f078f45204022e1a
@@ -32,11 +32,9 @@ Each feature is stored in a redis hash, which means getting a feature is single
32
32
 
33
33
  ```ruby
34
34
  require 'flipper/adapters/redis'
35
- require 'redis/namespace'
36
35
 
37
36
  client = Redis.new
38
- namespaced_client = Redis::Namespace.new(:flipper, :redis => client)
39
- adapter = Flipper::Adapters::Redis.new(namespaced_client)
37
+ adapter = Flipper::Adapters::Redis.new(client)
40
38
  flipper = Flipper.new(adapter)
41
39
 
42
40
  # Register a few groups.
@@ -47,40 +45,44 @@ Flipper.register(:early_access) { |thing| thing.early_access? }
47
45
  User = Struct.new(:flipper_id)
48
46
 
49
47
  flipper[:stats].enable
50
- flipper[:stats].enable flipper.group(:admins)
51
- flipper[:stats].enable flipper.group(:early_access)
52
- flipper[:stats].enable User.new('25')
53
- flipper[:stats].enable User.new('90')
54
- flipper[:stats].enable User.new('180')
55
- flipper[:stats].enable flipper.random(15)
56
- flipper[:stats].enable flipper.actors(45)
48
+ flipper[:stats].enable_group :admins
49
+ flipper[:stats].enable_group :early_access
50
+ flipper[:stats].enable_actor User.new('25')
51
+ flipper[:stats].enable_actor User.new('90')
52
+ flipper[:stats].enable_actor User.new('180')
53
+ flipper[:stats].enable_percentage_of_time 15
54
+ flipper[:stats].enable_percentage_of_actors 45
57
55
 
58
56
  flipper[:search].enable
59
57
 
60
58
  print 'all keys: '
61
- pp namespaced_client.keys
59
+ pp client.keys
62
60
  # all keys: ["stats", "flipper_features", "search"]
61
+ puts
63
62
 
64
63
  print "known flipper features: "
65
- pp namespaced_client.smembers("flipper_features")
64
+ pp client.smembers("flipper_features")
66
65
  # known flipper features: ["stats", "search"]
66
+ puts
67
67
 
68
68
  puts 'stats keys'
69
- pp namespaced_client.hgetall('stats')
69
+ pp client.hgetall('stats')
70
70
  # stats keys
71
71
  # {"boolean"=>"true",
72
72
  # "groups/admins"=>"1",
73
73
  # "actors/25"=>"1",
74
- # "percentage_of_random"=>"15",
74
+ # "percentage_of_time"=>"15",
75
75
  # "percentage_of_actors"=>"45",
76
76
  # "groups/early_access"=>"1",
77
77
  # "actors/90"=>"1",
78
78
  # "actors/180"=>"1"}
79
+ puts
79
80
 
80
81
  puts 'search keys'
81
- pp namespaced_client.hgetall('search')
82
+ pp client.hgetall('search')
82
83
  # search keys
83
84
  # {"boolean"=>"true"}
85
+ puts
84
86
 
85
87
  puts 'flipper get of feature'
86
88
  pp adapter.get(flipper[:stats])
@@ -89,25 +91,7 @@ pp adapter.get(flipper[:stats])
89
91
  # :groups=>#<Set: {"admins", "early_access"}>,
90
92
  # :actors=>#<Set: {"25", "90", "180"}>,
91
93
  # :percentage_of_actors=>"45",
92
- # :percentage_of_random=>"15"}
93
- ```
94
-
95
- ## `script/bootstrap`
96
-
97
- This script will get all the dependencies ready so you can start hacking.
98
-
99
- ```
100
- # to learn more about script/bootstrap
101
- script/bootstrap help
102
- ```
103
-
104
- ## `script/test`
105
-
106
- For your convenience, there is a script to run the tests. It will also perform `script/bootstrap`, which bundles and all that jazz.
107
-
108
- ```
109
- # to learn more about script test
110
- script/test help
94
+ # :percentage_of_time=>"15"}
111
95
  ```
112
96
 
113
97
  ## Contributing
@@ -6,7 +6,11 @@ lib_path = root_path.join('lib')
6
6
  $:.unshift(lib_path)
7
7
 
8
8
  require 'flipper/adapters/redis'
9
- client = Redis.new
9
+ options = {}
10
+ if ENV['BOXEN_REDIS_URL']
11
+ options[:url] = ENV['BOXEN_REDIS_URL']
12
+ end
13
+ client = Redis.new(options)
10
14
  adapter = Flipper::Adapters::Redis.new(client)
11
15
  flipper = Flipper.new(adapter)
12
16
 
@@ -7,11 +7,13 @@ lib_path = root_path.join('lib')
7
7
  $:.unshift(lib_path)
8
8
 
9
9
  require 'flipper/adapters/redis'
10
- require 'redis/namespace'
11
10
 
12
- client = Redis.new
13
- namespaced_client = Redis::Namespace.new(:flipper, :redis => client)
14
- adapter = Flipper::Adapters::Redis.new(namespaced_client)
11
+ options = {}
12
+ if ENV['BOXEN_REDIS_URL']
13
+ options[:url] = ENV['BOXEN_REDIS_URL']
14
+ end
15
+ client = Redis.new(options)
16
+ adapter = Flipper::Adapters::Redis.new(client)
15
17
  flipper = Flipper.new(adapter)
16
18
 
17
19
  # Register a few groups.
@@ -22,33 +24,33 @@ Flipper.register(:early_access) { |thing| thing.early_access? }
22
24
  User = Struct.new(:flipper_id)
23
25
 
24
26
  flipper[:stats].enable
25
- flipper[:stats].enable flipper.group(:admins)
26
- flipper[:stats].enable flipper.group(:early_access)
27
- flipper[:stats].enable User.new('25')
28
- flipper[:stats].enable User.new('90')
29
- flipper[:stats].enable User.new('180')
30
- flipper[:stats].enable flipper.random(15)
31
- flipper[:stats].enable flipper.actors(45)
27
+ flipper[:stats].enable_group :admins
28
+ flipper[:stats].enable_group :early_access
29
+ flipper[:stats].enable_actor User.new('25')
30
+ flipper[:stats].enable_actor User.new('90')
31
+ flipper[:stats].enable_actor User.new('180')
32
+ flipper[:stats].enable_percentage_of_time 15
33
+ flipper[:stats].enable_percentage_of_actors 45
32
34
 
33
35
  flipper[:search].enable
34
36
 
35
37
  print 'all keys: '
36
- pp namespaced_client.keys
38
+ pp client.keys
37
39
  # all keys: ["stats", "flipper_features", "search"]
38
40
  puts
39
41
 
40
42
  print "known flipper features: "
41
- pp namespaced_client.smembers("flipper_features")
43
+ pp client.smembers("flipper_features")
42
44
  # known flipper features: ["stats", "search"]
43
45
  puts
44
46
 
45
47
  puts 'stats keys'
46
- pp namespaced_client.hgetall('stats')
48
+ pp client.hgetall('stats')
47
49
  # stats keys
48
50
  # {"boolean"=>"true",
49
51
  # "groups/admins"=>"1",
50
52
  # "actors/25"=>"1",
51
- # "percentage_of_random"=>"15",
53
+ # "percentage_of_time"=>"15",
52
54
  # "percentage_of_actors"=>"45",
53
55
  # "groups/early_access"=>"1",
54
56
  # "actors/90"=>"1",
@@ -56,7 +58,7 @@ pp namespaced_client.hgetall('stats')
56
58
  puts
57
59
 
58
60
  puts 'search keys'
59
- pp namespaced_client.hgetall('search')
61
+ pp client.hgetall('search')
60
62
  # search keys
61
63
  # {"boolean"=>"true"}
62
64
  puts
@@ -68,4 +70,4 @@ pp adapter.get(flipper[:stats])
68
70
  # :groups=>#<Set: {"admins", "early_access"}>,
69
71
  # :actors=>#<Set: {"25", "90", "180"}>,
70
72
  # :percentage_of_actors=>"45",
71
- # :percentage_of_random=>"15"}
73
+ # :percentage_of_time=>"15"}
@@ -1,20 +1,24 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/flipper/adapters/redis/version', __FILE__)
2
+ require File.expand_path('../lib/flipper/version', __FILE__)
3
+
4
+ flipper_redis_files = lambda { |file|
5
+ file =~ /redis/
6
+ }
3
7
 
4
8
  Gem::Specification.new do |gem|
5
- gem.name = "flipper-redis"
6
- gem.version = Flipper::Adapters::Redis::VERSION
7
9
  gem.authors = ["John Nunemaker"]
8
10
  gem.email = ["nunemaker@gmail.com"]
9
- gem.description = %q{Redis adapter for Flipper}
10
- gem.summary = %q{Redis adapter for Flipper}
11
- gem.homepage = "http://jnunemaker.github.com/flipper-redis"
12
- gem.require_paths = ["lib"]
11
+ gem.summary = "Redis adapter for Flipper"
12
+ gem.description = "Redis adapter for Flipper"
13
+ gem.license = "MIT"
14
+ gem.homepage = "https://github.com/jnunemaker/flipper"
13
15
 
14
- gem.files = `git ls-files`.split($/)
15
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.files = `git ls-files`.split("\n").select(&flipper_redis_files) + ["lib/flipper/version.rb"]
17
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_redis_files)
18
+ gem.name = "flipper-redis"
19
+ gem.require_paths = ["lib"]
20
+ gem.version = Flipper::VERSION
17
21
 
18
- gem.add_dependency 'flipper', '~> 0.7.0.beta1'
22
+ gem.add_dependency 'flipper', "~> #{Flipper::VERSION}"
19
23
  gem.add_dependency 'redis', '>= 2.2', '< 4.0.0'
20
24
  end
@@ -28,14 +28,14 @@ module Flipper
28
28
 
29
29
  # Public: Adds a feature to the set of known features.
30
30
  def add(feature)
31
- @client.sadd FeaturesKey, feature.name
31
+ @client.sadd FeaturesKey, feature.key
32
32
  true
33
33
  end
34
34
 
35
35
  # Public: Removes a feature from the set of known features.
36
36
  def remove(feature)
37
37
  @client.multi do
38
- @client.srem FeaturesKey, feature.name
38
+ @client.srem FeaturesKey, feature.key
39
39
  @client.del feature.key
40
40
  end
41
41
  true
@@ -0,0 +1,3 @@
1
+ module Flipper
2
+ VERSION = "0.7.0.beta4"
3
+ 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.7.0.beta1
4
+ version: 0.7.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2015-04-28 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.7.0.beta1
19
+ version: 0.7.0.beta4
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.7.0.beta1
26
+ version: 0.7.0.beta4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: redis
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -51,26 +51,17 @@ executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
- - ".gitignore"
55
- - ".travis.yml"
56
- - Gemfile
57
- - Guardfile
58
- - LICENSE
59
- - README.md
60
- - Rakefile
61
- - examples/basic.rb
62
- - examples/internals.rb
54
+ - docs/redis/README.md
55
+ - examples/redis/basic.rb
56
+ - examples/redis/internals.rb
63
57
  - flipper-redis.gemspec
64
58
  - lib/flipper-redis.rb
65
59
  - lib/flipper/adapters/redis.rb
66
- - lib/flipper/adapters/redis/version.rb
67
- - script/bootstrap
68
- - script/release
69
- - script/test
70
- - spec/flipper/redis_spec.rb
71
- - spec/helper.rb
72
- homepage: http://jnunemaker.github.com/flipper-redis
73
- licenses: []
60
+ - lib/flipper/version.rb
61
+ - spec/flipper/adapters/redis_spec.rb
62
+ homepage: https://github.com/jnunemaker/flipper
63
+ licenses:
64
+ - MIT
74
65
  metadata: {}
75
66
  post_install_message:
76
67
  rdoc_options: []
@@ -93,5 +84,4 @@ signing_key:
93
84
  specification_version: 4
94
85
  summary: Redis adapter for Flipper
95
86
  test_files:
96
- - spec/flipper/redis_spec.rb
97
- - spec/helper.rb
87
+ - spec/flipper/adapters/redis_spec.rb
data/.gitignore DELETED
@@ -1,18 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- log
data/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.8.7
4
- - ree
5
- - 1.9.3
6
- notifications:
7
- email: false
8
- bundler_args: --without guard
9
- before_script: sudo service redis-server status
10
- services:
11
- - redis-server
data/Gemfile DELETED
@@ -1,13 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
3
-
4
- gem 'redis-namespace', :require => false
5
- gem 'rake'
6
- gem 'rspec'
7
-
8
- group(:guard) do
9
- gem 'guard'
10
- gem 'guard-rspec'
11
- gem 'guard-bundler'
12
- gem 'rb-fsevent'
13
- end
data/Guardfile DELETED
@@ -1,18 +0,0 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
- guard 'bundler' do
5
- watch('Gemfile')
6
- watch(/^.+\.gemspec/)
7
- end
8
-
9
- rspec_options = {
10
- :all_after_pass => false,
11
- :all_on_start => false,
12
- }
13
-
14
- guard 'rspec', rspec_options do
15
- watch(%r{^spec/.+_spec\.rb$}) { "spec" }
16
- watch(%r{^lib/(.+)\.rb$}) { "spec" }
17
- watch('spec/helper.rb') { "spec" }
18
- end
data/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2012 John Nunemaker
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile DELETED
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env rake
2
- require 'rspec/core/rake_task'
3
- RSpec::Core::RakeTask.new
4
-
5
- task :default => :spec
@@ -1,7 +0,0 @@
1
- module Flipper
2
- module Adapters
3
- class Redis
4
- VERSION = "0.7.0.beta1"
5
- end
6
- end
7
- end
data/script/bootstrap DELETED
@@ -1,21 +0,0 @@
1
- #!/bin/sh
2
- #/ Usage: bootstrap [bundle options]
3
- #/
4
- #/ Bundle install the dependencies.
5
- #/
6
- #/ Examples:
7
- #/
8
- #/ bootstrap
9
- #/ bootstrap --local
10
- #/
11
-
12
- set -e
13
- cd $(dirname "$0")/..
14
-
15
- [ "$1" = "--help" -o "$1" = "-h" -o "$1" = "help" ] && {
16
- grep '^#/' <"$0"| cut -c4-
17
- exit 0
18
- }
19
-
20
- rm -rf .bundle/{binstubs,config}
21
- bundle install --binstubs .bundle/binstubs --path .bundle --quiet "$@"
data/script/release DELETED
@@ -1,42 +0,0 @@
1
- #!/bin/sh
2
- #/ Usage: release
3
- #/
4
- #/ Tag the version in the repo and push the gem.
5
- #/
6
-
7
- set -e
8
- cd $(dirname "$0")/..
9
-
10
- [ "$1" = "--help" -o "$1" = "-h" -o "$1" = "help" ] && {
11
- grep '^#/' <"$0"| cut -c4-
12
- exit 0
13
- }
14
-
15
- gem_name=flipper-redis
16
-
17
- # Build a new gem archive.
18
- rm -rf $gem_name-*.gem
19
- gem build -q $gem_name.gemspec
20
-
21
- # Make sure we're on the master branch.
22
- (git branch | grep -q '* master') || {
23
- echo "Only release from the master branch."
24
- exit 1
25
- }
26
-
27
- # Figure out what version we're releasing.
28
- tag=v`ls $gem_name-*.gem | sed "s/^$gem_name-\(.*\)\.gem$/\1/"`
29
-
30
- echo "Releasing $tag"
31
-
32
- # Make sure we haven't released this version before.
33
- git fetch -t origin
34
-
35
- (git tag -l | grep -q "$tag") && {
36
- echo "Whoops, there's already a '${tag}' tag."
37
- exit 1
38
- }
39
-
40
- # Tag it and bag it.
41
- gem push $gem_name-*.gem && git tag "$tag" &&
42
- git push origin master && git push origin "$tag"
data/script/test DELETED
@@ -1,23 +0,0 @@
1
- #!/bin/sh
2
- #/ Usage: test [individual test file]
3
- #/
4
- #/ Bootstrap and run all tests or an individual test.
5
- #/
6
- #/ Examples:
7
- #/
8
- #/ # run all tests
9
- #/ test
10
- #/
11
- #/ # run individual test
12
- #/ test test/controller_instrumentation_test.rb
13
- #/
14
-
15
- set -e
16
- cd $(dirname "$0")/..
17
-
18
- [ "$1" = "--help" -o "$1" = "-h" -o "$1" = "help" ] && {
19
- grep '^#/' <"$0"| cut -c4-
20
- exit 0
21
- }
22
-
23
- script/bootstrap && bundle exec rake spec
data/spec/helper.rb DELETED
@@ -1,11 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- require 'flipper-redis'
4
-
5
- RSpec.configure do |config|
6
- config.filter_run :focused => true
7
- config.alias_example_to :fit, :focused => true
8
- config.alias_example_to :xit, :pending => true
9
- config.run_all_when_everything_filtered = true
10
- config.fail_fast = true
11
- end