ar_rollout 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +21 -2
- data/lib/ar_rollout.rb +31 -0
- data/lib/ar_rollout/helper.rb +6 -4
- data/lib/ar_rollout/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -88,6 +88,23 @@ rake rollout:activate_group[my_new_amazing_feature,all]
|
|
88
88
|
So, in your controller/view you can use the helper method `rollout? :my_new_amazing_feature`, which will test if the
|
89
89
|
`current_user` is enabled to that feature.
|
90
90
|
|
91
|
+
In your *_controller.rb:
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
before_filter :rollout
|
95
|
+
around_filter :degrade
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def rollout
|
100
|
+
redirect_to root_url, alert: "Feature unavailable" unless rollout? :phone
|
101
|
+
end
|
102
|
+
|
103
|
+
def degrade
|
104
|
+
degrade_feature(:phone) { yield }
|
105
|
+
end
|
106
|
+
```
|
107
|
+
|
91
108
|
List known features with:
|
92
109
|
|
93
110
|
`ArRollout.features`
|
@@ -98,16 +115,18 @@ List known features with:
|
|
98
115
|
|
99
116
|
- Optimize user lookup
|
100
117
|
- Optimize database structure
|
101
|
-
- Add #info
|
102
118
|
- Merge ArRollout and Rollout class methods
|
103
119
|
- Autodetection of new features from code, before rollout begins
|
104
120
|
|
121
|
+
## Version 0.0.7 - 16 Aug 2012
|
122
|
+
- Add `ArRollout.info`
|
123
|
+
|
105
124
|
## Version 0.0.4 - 16 Aug 2012
|
106
125
|
- Add percentage support
|
107
126
|
- Add feature list with `ArRollout.features`
|
108
127
|
|
109
128
|
## Version 0.0.3 - 16 Aug 2012
|
110
|
-
- Add `deactivate_all` method and rake task
|
129
|
+
- Add `ArRollout.deactivate_all` method and rake task
|
111
130
|
|
112
131
|
## Version 0.0.2 - 16 Aug 2012
|
113
132
|
- Add `:all` to default initializer
|
data/lib/ar_rollout.rb
CHANGED
@@ -45,6 +45,37 @@ module ArRollout
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
def self.degrade_feature(name)
|
49
|
+
yield
|
50
|
+
rescue StandardError => e
|
51
|
+
Rollout.where(name: name).each do |rollout|
|
52
|
+
rollout.increment!(:failure_count)
|
53
|
+
end
|
54
|
+
raise e
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.info(feature)
|
58
|
+
{
|
59
|
+
:percentage => (active_percentage(feature) || 0).to_i,
|
60
|
+
:groups => active_groups(feature).map { |g| g.to_sym },
|
61
|
+
:users => active_user_ids(feature)
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
def self.active_groups(feature)
|
67
|
+
Rollout.where('"name" = ? and "group" is not null', feature).map(&:group)
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.active_user_ids(feature)
|
71
|
+
Rollout.where('"name" = ? and "user_id" is not null', feature).map(&:user_id)
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.active_percentage(feature)
|
75
|
+
Rollout.where('"name" = ? and "percentage" is not null', feature).map(&:percentage).first
|
76
|
+
end
|
77
|
+
|
78
|
+
|
48
79
|
end
|
49
80
|
|
50
81
|
ActionController::Base.send :include, ArRollout::Controller::Helpers
|
data/lib/ar_rollout/helper.rb
CHANGED
@@ -3,13 +3,15 @@ module ArRollout
|
|
3
3
|
module Helpers
|
4
4
|
def self.included(base)
|
5
5
|
base.send :helper_method, :rollout?
|
6
|
+
base.send :helper_method, :degrade_feature?
|
6
7
|
end
|
7
8
|
|
8
|
-
# in vista rollout? :radio_feature
|
9
9
|
def rollout?(name)
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
ArRollout.active?(name, current_user)
|
11
|
+
end
|
12
|
+
|
13
|
+
def degrade_feature?(name)
|
14
|
+
ArRollout.degrade_feature?(name)
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
data/lib/ar_rollout/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar_rollout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-08-
|
14
|
+
date: 2012-08-17 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|