rollout 0.2.0 → 0.2.1

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.
data/README.rdoc CHANGED
@@ -73,6 +73,22 @@ Deactivate everybody at once:
73
73
 
74
74
  For some of our less stable features, we are actually measuring the error rate using redis, and deactivating them automatically when it raises above a certain threshold. It's pretty cool. See http://github.com/jamesgolick/degrade for the failure detection code.
75
75
 
76
+ == Namespacing
77
+
78
+ Rollout separates its keys from other keys on the Redis server using the "feature" keyspace.
79
+
80
+ You can namespace keys further to support multiple environments by using the http://github.com/defunkt/redis-namespace gem.
81
+
82
+ $ns = Redis::Namespace.new(Rails.env, :redis => $redis)
83
+ $rollout = Rollout.new($ns)
84
+ $rollout.activate_group(:chat, :all)
85
+
86
+ This example would use the "development:feature:chat:groups" key.
87
+
88
+ == Implementations in other languages
89
+
90
+ * Python: http://github.com/asenchi/proclaim
91
+
76
92
  == Note on Patches/Pull Requests
77
93
 
78
94
  * Fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/lib/rollout.rb CHANGED
@@ -62,7 +62,7 @@ class Rollout
62
62
  end
63
63
 
64
64
  def user_in_active_group?(feature, user)
65
- @redis.smembers(group_key(feature)).any? { |group| @groups[group].call(user) }
65
+ @redis.smembers(group_key(feature)).any? { |group| @groups.key?(group) && @groups[group].call(user) }
66
66
  end
67
67
 
68
68
  def user_active?(feature, user)
@@ -72,7 +72,6 @@ class Rollout
72
72
  def user_within_active_percentage?(feature, user)
73
73
  percentage = @redis.get(percentage_key(feature))
74
74
  return false if percentage.nil?
75
-
76
- user.id % 10 < percentage.to_i / 10
75
+ user.id % 100 < percentage.to_i
77
76
  end
78
77
  end
data/rollout.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rollout}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["James Golick"]
12
- s.date = %q{2010-07-18}
12
+ s.date = %q{2010-10-15}
13
13
  s.description = %q{Conditionally roll out features with redis.}
14
14
  s.email = %q{jamesgoick@gmail.com}
15
15
  s.extra_rdoc_files = [
data/spec/rollout_spec.rb CHANGED
@@ -19,6 +19,11 @@ describe "Rollout" do
19
19
  it "is not active for users for which the block evaluates to false" do
20
20
  @rollout.should_not be_active(:chat, stub(:id => 1))
21
21
  end
22
+
23
+ it "is not active if a group is found in Redis but not defined in Rollout" do
24
+ @rollout.activate_group(:chat, :fake)
25
+ @rollout.should_not be_active(:chat, stub(:id => 1))
26
+ end
22
27
  end
23
28
 
24
29
  describe "the default all group" do
@@ -107,10 +112,31 @@ describe "Rollout" do
107
112
  end
108
113
 
109
114
  it "activates the feature for that percentage of the users" do
110
- (1..120).select { |id| @rollout.active?(:chat, stub(:id => id)) }.length.should == 24
115
+ (1..120).select { |id| @rollout.active?(:chat, stub(:id => id)) }.length.should == 39
111
116
  end
112
117
  end
113
118
 
119
+ describe "activating a feature for a percentage of users" do
120
+ before do
121
+ @rollout.activate_percentage(:chat, 20)
122
+ end
123
+
124
+ it "activates the feature for that percentage of the users" do
125
+ (1..200).select { |id| @rollout.active?(:chat, stub(:id => id)) }.length.should == 40
126
+ end
127
+ end
128
+
129
+ describe "activating a feature for a percentage of users" do
130
+ before do
131
+ @rollout.activate_percentage(:chat, 5)
132
+ end
133
+
134
+ it "activates the feature for that percentage of the users" do
135
+ (1..100).select { |id| @rollout.active?(:chat, stub(:id => id)) }.length.should == 5
136
+ end
137
+ end
138
+
139
+
114
140
  describe "deactivating the percentage of users" do
115
141
  before do
116
142
  @rollout.activate_percentage(:chat, 100)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollout
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Golick
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-18 00:00:00 -07:00
18
+ date: 2010-10-15 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency