flipper 0.7.0.beta3 → 0.7.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +28 -0
- data/Gemfile +12 -4
- data/README.md +9 -249
- data/Rakefile +33 -2
- data/docs/Adapters.md +47 -0
- data/docs/Gates.md +130 -0
- data/docs/Instrumentation.md +27 -0
- data/docs/Optimization.md +27 -0
- data/flipper.gemspec +25 -5
- data/lib/flipper/adapters/decorator.rb +2 -0
- data/lib/flipper/adapters/instrumented.rb +2 -0
- data/lib/flipper/adapters/memoizable.rb +10 -22
- data/lib/flipper/adapters/memory.rb +3 -1
- data/lib/flipper/adapters/pstore.rb +2 -0
- data/lib/flipper/type.rb +5 -2
- data/lib/flipper/types/actor.rb +0 -8
- data/lib/flipper/types/boolean.rb +1 -5
- data/lib/flipper/types/group.rb +1 -5
- data/lib/flipper/types/percentage.rb +0 -13
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/adapters/memoizable_spec.rb +2 -7
- data/spec/flipper/adapters/pstore_spec.rb +4 -1
- data/spec/flipper/instrumentation/log_subscriber_spec.rb +1 -0
- data/spec/flipper/types/actor_spec.rb +5 -1
- data/spec/flipper/types/boolean_spec.rb +5 -0
- data/spec/helper.rb +1 -5
- data/spec/support/spec_helpers.rb +31 -0
- metadata +13 -13
- data/.gitignore +0 -18
- data/.rspec +0 -1
- data/.travis.yml +0 -8
- data/Guardfile +0 -21
- data/script/bootstrap +0 -21
- data/script/guard +0 -15
- data/script/release +0 -15
- data/script/test +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d5dff1f360e246357e95815a52280e51470883a
|
4
|
+
data.tar.gz: 82e1d70468ab4dc11fc333f8af544933e6b63bf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f06c93860e0e4a88dd523dd720f7871c407b23514db8312083a500a49cfcc20e58e7226ab3970bdcfd496a82005fa9a9e69c2e80e761d602bf8c7513b5ccbff
|
7
|
+
data.tar.gz: ebc6c08a8e9c3a92c8ed4b72754d0c3c9afc2caa43c80758ef40ed9c8e69b7a5af7cf05fdd1085d706dda415d0a71c3fd5c7c02273f6cfd0d0b4cc1d292cf313
|
data/Changelog.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
+
## master (0.7)
|
2
|
+
|
3
|
+
* Added Flipper.groups and Flipper.group_names
|
4
|
+
* Changed percentage_of_random to percentage_of_time
|
5
|
+
* Added enable/disable convenience methods for all gates (ie: enable_group, enable_actor, enable_percentage_of_actors, enable_percentage_of_time)
|
6
|
+
* Added value convenience methods (ie: boolean_value, groups_value, actors_value, etc.)
|
7
|
+
* Added Feature#gate_values for getting typecast adapter gate values
|
8
|
+
* Added Feature#enabled_gates and #disabled_gates for getting the gates that are enabled/disabled for the feature
|
9
|
+
* Remove Feature#description
|
10
|
+
* Added Flipper::Adapters::PStore
|
11
|
+
* Moved memoizable decorator to instance variable storage from class level thread local stuff. Now not thread safe, but we can make a thread safe version later.
|
12
|
+
|
13
|
+
UI
|
14
|
+
|
15
|
+
* Totally new. Works like a charm.
|
16
|
+
|
17
|
+
Mongo
|
18
|
+
|
19
|
+
* Updated to latest driver (~> 2.0)
|
20
|
+
|
21
|
+
## 0.6.3
|
22
|
+
|
23
|
+
* Minor bug fixes
|
24
|
+
|
25
|
+
## 0.6.2
|
26
|
+
|
27
|
+
* Added Flipper.group_exists?
|
28
|
+
|
1
29
|
## 0.6.1
|
2
30
|
|
3
31
|
* Added statsd support for instrumentation.
|
data/Gemfile
CHANGED
@@ -1,16 +1,24 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
-
gemspec
|
2
|
+
gemspec :name => 'flipper'
|
3
|
+
|
4
|
+
Dir['flipper-*.gemspec'].each do |gemspec|
|
5
|
+
plugin = gemspec.scan(/flipper-(.*)\.gemspec/).flatten.first
|
6
|
+
gemspec(:name => "flipper-#{plugin}", :development_group => plugin)
|
7
|
+
end
|
3
8
|
|
4
9
|
gem 'rake', '~> 10.4.2'
|
5
|
-
gem 'metriks', '~> 0.9.9'
|
6
|
-
gem '
|
10
|
+
gem 'metriks', '~> 0.9.9'
|
11
|
+
gem 'shotgun', '~> 0.9'
|
12
|
+
gem 'statsd-ruby', '~> 1.2.1'
|
7
13
|
gem 'rspec', '~> 2.14'
|
8
14
|
gem 'rack-test', '~> 0.6.3'
|
9
|
-
gem 'activesupport', '~> 4.2.0'
|
15
|
+
gem 'activesupport', '~> 4.2.0'
|
10
16
|
|
11
17
|
group(:guard) do
|
12
18
|
gem 'guard', '~> 2.12.5'
|
13
19
|
gem 'guard-rspec', '~> 4.5.0'
|
14
20
|
gem 'guard-bundler', '~> 2.1.0'
|
21
|
+
gem 'guard-coffeescript', '~> 2.0.1'
|
22
|
+
gem 'guard-sass', '~> 1.6.0'
|
15
23
|
gem 'rb-fsevent', '~> 0.9.4'
|
16
24
|
end
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
![flipper logo](https://raw.githubusercontent.com/jnunemaker/flipper
|
1
|
+
![flipper logo](https://raw.githubusercontent.com/jnunemaker/flipper/master/lib/flipper/ui/public/images/logo.png)
|
2
2
|
|
3
3
|
<pre>
|
4
4
|
__
|
@@ -35,7 +35,7 @@ Or install it yourself with:
|
|
35
35
|
|
36
36
|
$ gem install flipper
|
37
37
|
|
38
|
-
##
|
38
|
+
## Examples
|
39
39
|
|
40
40
|
The goal of the API for flipper was to have everything revolve around features and what ways they can be enabled. Start with top level and dig into a feature, then dig in further and enable that feature for a given type of access, as opposed to thinking about how the feature will be accessed first (ie: `stats.enable` vs `activate_group(:stats, ...)`).
|
41
41
|
|
@@ -61,251 +61,17 @@ end
|
|
61
61
|
|
62
62
|
puts 'Enabling Search...'
|
63
63
|
search.enable
|
64
|
-
|
65
|
-
# check if that feature is enabled again
|
66
|
-
if search.enabled?
|
67
|
-
puts 'Search away!'
|
68
|
-
else
|
69
|
-
puts 'No search for you!'
|
70
|
-
end
|
71
|
-
```
|
72
|
-
|
73
|
-
Of course there are more [examples for you to peruse](https://github.com/jnunemaker/flipper/tree/master/examples).
|
74
|
-
|
75
|
-
## Types
|
76
|
-
|
77
|
-
Out of the box several types of enabling are supported. They are checked in this order:
|
78
|
-
|
79
|
-
### 1. Boolean
|
80
|
-
|
81
|
-
All on or all off. Think top level things like `:stats`, `:search`, `:logging`, etc. Also, an easy way to release a new feature as once a feature is boolean enabled it is on for every situation.
|
82
|
-
|
83
|
-
```ruby
|
84
|
-
flipper = Flipper.new(adapter)
|
85
|
-
flipper[:stats].enable # turn on
|
86
|
-
flipper[:stats].disable # turn off
|
87
|
-
flipper[:stats].enabled? # check
|
88
|
-
```
|
89
|
-
|
90
|
-
### 2. Group
|
91
|
-
|
92
|
-
Turn on feature based on value of block. Super flexible way to turn on a feature for multiple things (users, people, accounts, etc.)
|
93
|
-
|
94
|
-
```ruby
|
95
|
-
Flipper.register(:admins) do |actor|
|
96
|
-
actor.respond_to?(:admin?) && actor.admin?
|
97
|
-
end
|
98
|
-
|
99
|
-
flipper = Flipper.new(adapter)
|
100
|
-
|
101
|
-
flipper[:stats].enable flipper.group(:admins) # turn on for admins
|
102
|
-
flipper[:stats].disable flipper.group(:admins) # turn off for admins
|
103
|
-
|
104
|
-
person = Person.find(params[:id])
|
105
|
-
flipper[:stats].enabled? person # check if enabled, returns true if person.admin? is true
|
106
|
-
|
107
|
-
# you can also use shortcut methods
|
108
|
-
flipper.enable_group :stats, :admins
|
109
|
-
flipper.disable_group :stats, :admins
|
110
|
-
flipper[:stats].enable_group :admins
|
111
|
-
flipper[:stats].disable_group :admins
|
112
|
-
```
|
113
|
-
|
114
|
-
There is no requirement that the thing yielded to the block be a user model or whatever. It can be anything you want, therefore it is a good idea to check that the thing passed into the group block actually responds to what you are trying.
|
115
|
-
|
116
|
-
### 3. Individual Actor
|
117
|
-
|
118
|
-
Turn feature on for individual thing. Think enable feature for someone to test or for a buddy. The only requirement for an individual actor is that it must respond to `flipper_id`.
|
119
|
-
|
120
|
-
```ruby
|
121
|
-
flipper = Flipper.new(adapter)
|
122
|
-
|
123
|
-
flipper[:stats].enable user
|
124
|
-
flipper[:stats].enabled? user # true
|
125
|
-
|
126
|
-
flipper[:stats].disable user
|
127
|
-
flipper[:stats].enabled? user # false
|
128
|
-
|
129
|
-
# you can enable anything, does not need to be user or person
|
130
|
-
flipper[:search].enable group
|
131
|
-
flipper[:search].enabled? group
|
132
|
-
|
133
|
-
# you can also use shortcut methods
|
134
|
-
flipper.enable_actor :search, user
|
135
|
-
flipper.disable_actor :search, user
|
136
|
-
flipper[:search].enable_actor user
|
137
|
-
flipper[:search].disable_actor user
|
138
|
-
```
|
139
|
-
|
140
|
-
The key is to make sure you do not enable two different types of objects for the same feature. Imagine that user has a `flipper_id` of 6 and group has a `flipper_id` of 6. Enabling search for user would automatically enable it for group, as they both have a `flipper_id` of 6.
|
141
|
-
|
142
|
-
The one exception to this rule is if you have globally unique `flipper_ids`, such as UUIDs. If your `flipper_ids` are unique globally in your entire system, enabling two different types should be safe. Another way around this is to prefix the `flipper_id` with the class name like this:
|
143
|
-
|
144
|
-
```ruby
|
145
|
-
class User
|
146
|
-
def flipper_id
|
147
|
-
"User:#{id}"
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
class Group
|
152
|
-
def flipper_id
|
153
|
-
"Group:#{id}"
|
154
|
-
end
|
155
|
-
end
|
156
64
|
```
|
157
65
|
|
158
|
-
|
159
|
-
|
160
|
-
Turn this on for a percentage of actors (think user, member, account, group, whatever). Consistently on or off for this user as long as percentage increases. Think slow rollout of a new feature to a percentage of things.
|
161
|
-
|
162
|
-
```ruby
|
163
|
-
flipper = Flipper.new(adapter)
|
164
|
-
|
165
|
-
# returns a percentage of actors instance set to 10
|
166
|
-
percentage = flipper.actors(10)
|
167
|
-
|
168
|
-
# turn stats on for 10 percent of users in the system
|
169
|
-
flipper[:stats].enable percentage
|
66
|
+
Of course there are more [examples for you to peruse](examples/). You could also check out the [DSL](lib/flipper/dsl.rb) and [Feature](lib/flipper/feature.rb) classes for code/docs.
|
170
67
|
|
171
|
-
|
172
|
-
# user.flipper_id.to_s to ensure enabled distribution is smooth
|
173
|
-
flipper[:stats].enabled? user
|
174
|
-
|
175
|
-
# you can also use shortcut methods
|
176
|
-
flipper.enable_percentage_of_actors :search, 10
|
177
|
-
flipper.disable_percentage_of_actors :search # sets to 0
|
178
|
-
flipper[:search].enable_percentage_of_actors 10
|
179
|
-
flipper[:search].disable_percentage_of_actors # sets to 0
|
180
|
-
```
|
68
|
+
## Docs
|
181
69
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
flipper = Flipper.new(adapter)
|
188
|
-
|
189
|
-
# get percentage of time instance set to 5
|
190
|
-
percentage = flipper.time(5)
|
191
|
-
|
192
|
-
# turn on logging for 5 percent of the time
|
193
|
-
# could be on during one request and off the next
|
194
|
-
# could even be on first time in request and off second time
|
195
|
-
flipper[:logging].enable percentage
|
196
|
-
|
197
|
-
# you can also use shortcut methods
|
198
|
-
flipper.enable_percentage_of_time :search, 5
|
199
|
-
flipper.disable_percentage_of_time :search # sets to 0
|
200
|
-
flipper[:search].enable_percentage_of_time 5
|
201
|
-
flipper[:search].disable_percentage_of_time # sets to 0
|
202
|
-
```
|
203
|
-
|
204
|
-
Timeness is not a good idea for enabling new features in the UI. Most of the time you want a feature on or off for a user, but there are definitely times when I have found percentage of time to be very useful.
|
205
|
-
|
206
|
-
## Adapters
|
207
|
-
|
208
|
-
I plan on supporting [in-memory](https://github.com/jnunemaker/flipper/blob/master/lib/flipper/adapters/memory.rb), [Mongo](https://github.com/jnunemaker/flipper-mongo), and [Redis](https://github.com/jnunemaker/flipper-redis) as adapters for flipper. Others are welcome, so please let me know if you create one.
|
209
|
-
|
210
|
-
* [memory adapter](https://github.com/jnunemaker/flipper/blob/master/lib/flipper/adapters/memory.rb) – great for tests
|
211
|
-
* [Mongo adapter](https://github.com/jnunemaker/flipper-mongo)
|
212
|
-
* [Redis adapter](https://github.com/jnunemaker/flipper-redis)
|
213
|
-
* [Cassanity adapter](https://github.com/jnunemaker/flipper-cassanity)
|
214
|
-
* [Active Record 4 adapter](https://github.com/bgentry/flipper-activerecord)
|
215
|
-
* [Active Record 3 adapter](https://github.com/jproudman/flipper-activerecord)
|
216
|
-
|
217
|
-
The basic API for an adapter is this:
|
218
|
-
|
219
|
-
* `features` - Get the set of known features.
|
220
|
-
* `add(feature)` - Add a feature to the set of known features.
|
221
|
-
* `remove(feature)` - Remove a feature from the set of known features.
|
222
|
-
* `clear(feature)` - Clear all gate values for a feature.
|
223
|
-
* `get(feature)` - Get all gate values for a feature.
|
224
|
-
* `enable(feature, gate, thing)` - Enable a gate for a thing.
|
225
|
-
* `disable(feature, gate, thing)` - Disable a gate for a thing.
|
226
|
-
|
227
|
-
If you would like to make your own adapter, there are shared adapter specs that you can use to verify that you have everything working correctly.
|
228
|
-
|
229
|
-
For example, here is what the in-memory adapter spec looks like:
|
230
|
-
|
231
|
-
```ruby
|
232
|
-
require 'helper'
|
233
|
-
require 'flipper/adapters/memory'
|
234
|
-
|
235
|
-
# The shared specs are included with the flipper gem so you can use them in
|
236
|
-
# separate adapter specific gems.
|
237
|
-
require 'flipper/spec/shared_adapter_specs'
|
238
|
-
|
239
|
-
describe Flipper::Adapters::Memory do
|
240
|
-
|
241
|
-
# an instance of the new adapter you are trying to create
|
242
|
-
subject { described_class.new }
|
243
|
-
|
244
|
-
# include the shared specs that the subject must pass
|
245
|
-
it_should_behave_like 'a flipper adapter'
|
246
|
-
end
|
247
|
-
```
|
248
|
-
|
249
|
-
A good place to start when creating your own adapter is to copy one of the adapters mentioned above and replace the client specific code with whatever client you are attempting to adapt.
|
250
|
-
|
251
|
-
I would also recommend setting `fail_fast = true` in your RSpec configuration as that will just give you one failure at a time to work through. It is also handy to have the shared adapter spec file open.
|
252
|
-
|
253
|
-
## Instrumentation
|
254
|
-
|
255
|
-
Flipper comes with automatic instrumentation. By default these work with ActiveSupport::Notifications, but only require the pieces of ActiveSupport that are needed and only do so if you actually attempt to require the instrumentation files listed below.
|
256
|
-
|
257
|
-
To use the log subscriber:
|
258
|
-
|
259
|
-
```ruby
|
260
|
-
# Gemfile
|
261
|
-
gem "activesupport"
|
262
|
-
|
263
|
-
# config/initializers/flipper.rb (or wherever you want it)
|
264
|
-
require "flipper/instrumentation/log_subscriber"
|
265
|
-
```
|
266
|
-
|
267
|
-
To use the statsd instrumentation:
|
268
|
-
|
269
|
-
```ruby
|
270
|
-
# Gemfile
|
271
|
-
gem "activesupport"
|
272
|
-
gem "statsd-ruby"
|
273
|
-
|
274
|
-
# config/initializers/flipper.rb (or wherever you want it)
|
275
|
-
require "flipper/instrumentation/statsd"
|
276
|
-
Flipper::Instrumentation::StatsdSubscriber.client = Statsd.new # or whatever your statsd instance is
|
277
|
-
```
|
278
|
-
|
279
|
-
You can also do whatever you want with the instrumented events. Check out [this example](https://github.com/jnunemaker/flipper/blob/master/examples/instrumentation.rb) for more.
|
280
|
-
|
281
|
-
|
282
|
-
## Optimization
|
283
|
-
|
284
|
-
One optimization that flipper provides is a memoizing middleware. The memoizing middleware ensures that you only make one adapter call per feature per request.
|
285
|
-
|
286
|
-
This means if you check the same feature over and over, it will only make one Mongo, Redis, or whatever call per feature for the length of the request.
|
287
|
-
|
288
|
-
You can use the middleware from a Rails initializer like so:
|
289
|
-
|
290
|
-
```ruby
|
291
|
-
# create flipper dsl instance, see above Usage for more details
|
292
|
-
flipper = Flipper.new(...)
|
293
|
-
|
294
|
-
require 'flipper/middleware/memoizer'
|
295
|
-
config.middleware.use Flipper::Middleware::Memoizer, flipper
|
296
|
-
```
|
297
|
-
|
298
|
-
If you set your flipper instance up in an initializer, you can pass a block to the middleware and it will lazily load the instance the first time the middleware is invoked.
|
299
|
-
|
300
|
-
```ruby
|
301
|
-
# config/initializers/flipper.rb
|
302
|
-
$flipper = Flipper.new(...)
|
303
|
-
|
304
|
-
# config/application.rb
|
305
|
-
config.middleware.use Flipper::Middleware::Memoizer, lambda { $flipper }
|
306
|
-
```
|
307
|
-
|
308
|
-
**Note**: Be sure that the middleware is high enough up in your stack that all feature checks are wrapped.
|
70
|
+
* [Gates](docs/Gates.md) - Boolean, Groups, Actors, % of Actors, and % of Time
|
71
|
+
* [Adapters](docs/Adapters.md) - Mongo, Redis, Cassandra, Active Record...
|
72
|
+
* [Instrumentation](docs/Instrumentation.md) - ActiveSupport::Notifications, Statsd and Metriks
|
73
|
+
* [Optimization](docs/Optimization.md) - Memoization middleware
|
74
|
+
* [Web Interface](docs/ui/README.md) - Point and click...
|
309
75
|
|
310
76
|
## Contributing
|
311
77
|
|
@@ -320,9 +86,3 @@ config.middleware.use Flipper::Middleware::Memoizer, lambda { $flipper }
|
|
320
86
|
1. Update the version to be whatever it should be and commit.
|
321
87
|
2. `script/release`
|
322
88
|
3. Profit.
|
323
|
-
|
324
|
-
[![Build Status](https://travis-ci.org/jnunemaker/flipper.svg?branch=master)](https://travis-ci.org/jnunemaker/flipper)
|
325
|
-
|
326
|
-
## Coming Soon™
|
327
|
-
|
328
|
-
* [Web UI](https://github.com/jnunemaker/flipper-ui) (think Resque UI for features toggling/status)
|
data/Rakefile
CHANGED
@@ -1,7 +1,38 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
-
|
2
|
+
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "flipper/version"
|
4
|
+
|
5
|
+
# gem install pkg/*.gem
|
6
|
+
# gem uninstall flipper flipper-ui flipper-redis
|
7
|
+
desc 'Build gem into the pkg directory'
|
8
|
+
task :build do
|
9
|
+
FileUtils.rm_rf('pkg')
|
10
|
+
Dir['*.gemspec'].each do |gemspec|
|
11
|
+
system "gem build #{gemspec}"
|
12
|
+
end
|
13
|
+
FileUtils.mkdir_p('pkg')
|
14
|
+
FileUtils.mv(Dir['*.gem'], 'pkg')
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Tags version, pushes to remote, and pushes gem'
|
18
|
+
task :release => :build do
|
19
|
+
sh 'git', 'tag', "v#{Flipper::VERSION}"
|
20
|
+
sh "git push origin master"
|
21
|
+
sh "git push origin v#{Flipper::VERSION}"
|
22
|
+
sh "ls pkg/*.gem | xargs -n 1 gem push"
|
23
|
+
end
|
3
24
|
|
4
25
|
require "rspec/core/rake_task"
|
5
|
-
RSpec::Core::RakeTask.new
|
26
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
27
|
+
t.rspec_opts = %w(--color)
|
28
|
+
end
|
29
|
+
|
30
|
+
namespace :spec do
|
31
|
+
desc "Run specs for UI queue"
|
32
|
+
RSpec::Core::RakeTask.new(:ui) do |t|
|
33
|
+
t.rspec_opts = %w(--color)
|
34
|
+
t.pattern = ["spec/flipper/ui/**/*_spec.rb", "spec/flipper/ui_spec.rb"]
|
35
|
+
end
|
36
|
+
end
|
6
37
|
|
7
38
|
task :default => :spec
|
data/docs/Adapters.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Adapters
|
2
|
+
|
3
|
+
I plan on supporting the adapters in the flipper repo. Other adapters are welcome, so please let me know if you create one.
|
4
|
+
|
5
|
+
* [memory adapter](https://github.com/jnunemaker/flipper/blob/master/lib/flipper/adapters/memory.rb) – great for tests
|
6
|
+
* [PStore adapter](https://github.com/jnunemaker/flipper/blob/master/lib/flipper/adapters/pstore.rb) – great for when a local file is enough
|
7
|
+
* [Mongo adapter](https://github.com/jnunemaker/flipper/blob/master/docs/mongo)
|
8
|
+
* [Redis adapter](https://github.com/jnunemaker/flipper/blob/master/docs/redis)
|
9
|
+
* [Cassanity adapter](https://github.com/jnunemaker/flipper-cassanity)
|
10
|
+
* [Active Record 4 adapter](https://github.com/bgentry/flipper-activerecord)
|
11
|
+
* [Active Record 3 adapter](https://github.com/jproudman/flipper-activerecord)
|
12
|
+
|
13
|
+
The basic API for an adapter is this:
|
14
|
+
|
15
|
+
* `features` - Get the set of known features.
|
16
|
+
* `add(feature)` - Add a feature to the set of known features.
|
17
|
+
* `remove(feature)` - Remove a feature from the set of known features.
|
18
|
+
* `clear(feature)` - Clear all gate values for a feature.
|
19
|
+
* `get(feature)` - Get all gate values for a feature.
|
20
|
+
* `enable(feature, gate, thing)` - Enable a gate for a thing.
|
21
|
+
* `disable(feature, gate, thing)` - Disable a gate for a thing.
|
22
|
+
|
23
|
+
If you would like to make your own adapter, there are shared adapter specs that you can use to verify that you have everything working correctly.
|
24
|
+
|
25
|
+
For example, here is what the in-memory adapter spec looks like:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'helper'
|
29
|
+
require 'flipper/adapters/memory'
|
30
|
+
|
31
|
+
# The shared specs are included with the flipper gem so you can use them in
|
32
|
+
# separate adapter specific gems.
|
33
|
+
require 'flipper/spec/shared_adapter_specs'
|
34
|
+
|
35
|
+
describe Flipper::Adapters::Memory do
|
36
|
+
|
37
|
+
# an instance of the new adapter you are trying to create
|
38
|
+
subject { described_class.new }
|
39
|
+
|
40
|
+
# include the shared specs that the subject must pass
|
41
|
+
it_should_behave_like 'a flipper adapter'
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
A good place to start when creating your own adapter is to copy one of the adapters mentioned above and replace the client specific code with whatever client you are attempting to adapt.
|
46
|
+
|
47
|
+
I would also recommend setting `fail_fast = true` in your RSpec configuration as that will just give you one failure at a time to work through. It is also handy to have the shared adapter spec file open.
|
data/docs/Gates.md
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
# Gates
|
2
|
+
|
3
|
+
Out of the box several types of enabling are supported. They are checked in this order:
|
4
|
+
|
5
|
+
## 1. Boolean
|
6
|
+
|
7
|
+
All on or all off. Think top level things like `:stats`, `:search`, `:logging`, etc. Also, an easy way to release a new feature as once a feature is boolean enabled it is on for every situation.
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
flipper = Flipper.new(adapter)
|
11
|
+
flipper[:stats].enable # turn on
|
12
|
+
flipper[:stats].disable # turn off
|
13
|
+
flipper[:stats].enabled? # check
|
14
|
+
```
|
15
|
+
|
16
|
+
## 2. Group
|
17
|
+
|
18
|
+
Turn on feature based on value of block. Super flexible way to turn on a feature for multiple things (users, people, accounts, etc.)
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
Flipper.register(:admins) do |actor|
|
22
|
+
actor.respond_to?(:admin?) && actor.admin?
|
23
|
+
end
|
24
|
+
|
25
|
+
flipper = Flipper.new(adapter)
|
26
|
+
|
27
|
+
flipper[:stats].enable flipper.group(:admins) # turn on for admins
|
28
|
+
flipper[:stats].disable flipper.group(:admins) # turn off for admins
|
29
|
+
|
30
|
+
person = Person.find(params[:id])
|
31
|
+
flipper[:stats].enabled? person # check if enabled, returns true if person.admin? is true
|
32
|
+
|
33
|
+
# you can also use shortcut methods
|
34
|
+
flipper.enable_group :stats, :admins
|
35
|
+
flipper.disable_group :stats, :admins
|
36
|
+
flipper[:stats].enable_group :admins
|
37
|
+
flipper[:stats].disable_group :admins
|
38
|
+
```
|
39
|
+
|
40
|
+
There is no requirement that the thing yielded to the block be a user model or whatever. It can be anything you want, therefore it is a good idea to check that the thing passed into the group block actually responds to what you are trying.
|
41
|
+
|
42
|
+
## 3. Individual Actor
|
43
|
+
|
44
|
+
Turn feature on for individual thing. Think enable feature for someone to test or for a buddy. The only requirement for an individual actor is that it must respond to `flipper_id`.
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
flipper = Flipper.new(adapter)
|
48
|
+
|
49
|
+
flipper[:stats].enable user
|
50
|
+
flipper[:stats].enabled? user # true
|
51
|
+
|
52
|
+
flipper[:stats].disable user
|
53
|
+
flipper[:stats].enabled? user # false
|
54
|
+
|
55
|
+
# you can enable anything, does not need to be user or person
|
56
|
+
flipper[:search].enable group
|
57
|
+
flipper[:search].enabled? group
|
58
|
+
|
59
|
+
# you can also use shortcut methods
|
60
|
+
flipper.enable_actor :search, user
|
61
|
+
flipper.disable_actor :search, user
|
62
|
+
flipper[:search].enable_actor user
|
63
|
+
flipper[:search].disable_actor user
|
64
|
+
```
|
65
|
+
|
66
|
+
The key is to make sure you do not enable two different types of objects for the same feature. Imagine that user has a `flipper_id` of 6 and group has a `flipper_id` of 6. Enabling search for user would automatically enable it for group, as they both have a `flipper_id` of 6.
|
67
|
+
|
68
|
+
The one exception to this rule is if you have globally unique `flipper_ids`, such as UUIDs. If your `flipper_ids` are unique globally in your entire system, enabling two different types should be safe. Another way around this is to prefix the `flipper_id` with the class name like this:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
class User
|
72
|
+
def flipper_id
|
73
|
+
"User:#{id}"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class Group
|
78
|
+
def flipper_id
|
79
|
+
"Group:#{id}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
```
|
83
|
+
|
84
|
+
## 4. Percentage of Actors
|
85
|
+
|
86
|
+
Turn this on for a percentage of actors (think user, member, account, group, whatever). Consistently on or off for this user as long as percentage increases. Think slow rollout of a new feature to a percentage of things.
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
flipper = Flipper.new(adapter)
|
90
|
+
|
91
|
+
# returns a percentage of actors instance set to 10
|
92
|
+
percentage = flipper.actors(10)
|
93
|
+
|
94
|
+
# turn stats on for 10 percent of users in the system
|
95
|
+
flipper[:stats].enable percentage
|
96
|
+
|
97
|
+
# checks if actor's flipper_id is in the enabled percentage by hashing
|
98
|
+
# user.flipper_id.to_s to ensure enabled distribution is smooth
|
99
|
+
flipper[:stats].enabled? user
|
100
|
+
|
101
|
+
# you can also use shortcut methods
|
102
|
+
flipper.enable_percentage_of_actors :search, 10
|
103
|
+
flipper.disable_percentage_of_actors :search # sets to 0
|
104
|
+
flipper[:search].enable_percentage_of_actors 10
|
105
|
+
flipper[:search].disable_percentage_of_actors # sets to 0
|
106
|
+
```
|
107
|
+
|
108
|
+
## 5. Percentage of Time
|
109
|
+
|
110
|
+
Turn this on for a percentage of time. Think load testing new features behind the scenes and such.
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
flipper = Flipper.new(adapter)
|
114
|
+
|
115
|
+
# get percentage of time instance set to 5
|
116
|
+
percentage = flipper.time(5)
|
117
|
+
|
118
|
+
# turn on logging for 5 percent of the time
|
119
|
+
# could be on during one request and off the next
|
120
|
+
# could even be on first time in request and off second time
|
121
|
+
flipper[:logging].enable percentage
|
122
|
+
|
123
|
+
# you can also use shortcut methods
|
124
|
+
flipper.enable_percentage_of_time :search, 5
|
125
|
+
flipper.disable_percentage_of_time :search # sets to 0
|
126
|
+
flipper[:search].enable_percentage_of_time 5
|
127
|
+
flipper[:search].disable_percentage_of_time # sets to 0
|
128
|
+
```
|
129
|
+
|
130
|
+
Timeness is not a good idea for enabling new features in the UI. Most of the time you want a feature on or off for a user, but there are definitely times when I have found percentage of time to be very useful.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Instrumentation
|
2
|
+
|
3
|
+
Flipper comes with automatic instrumentation. By default these work with ActiveSupport::Notifications, but only require the pieces of ActiveSupport that are needed and only do so if you actually attempt to require the instrumentation files listed below.
|
4
|
+
|
5
|
+
To use the log subscriber:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
# Gemfile
|
9
|
+
gem "activesupport"
|
10
|
+
|
11
|
+
# config/initializers/flipper.rb (or wherever you want it)
|
12
|
+
require "flipper/instrumentation/log_subscriber"
|
13
|
+
```
|
14
|
+
|
15
|
+
To use the statsd instrumentation:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
# Gemfile
|
19
|
+
gem "activesupport"
|
20
|
+
gem "statsd-ruby"
|
21
|
+
|
22
|
+
# config/initializers/flipper.rb (or wherever you want it)
|
23
|
+
require "flipper/instrumentation/statsd"
|
24
|
+
Flipper::Instrumentation::StatsdSubscriber.client = Statsd.new # or whatever your statsd instance is
|
25
|
+
```
|
26
|
+
|
27
|
+
You can also do whatever you want with the instrumented events. Check out [this example](https://github.com/jnunemaker/flipper/blob/master/examples/instrumentation.rb) for more.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Optimization
|
2
|
+
|
3
|
+
One optimization that flipper provides is a memoizing middleware. The memoizing middleware ensures that you only make one adapter call per feature per request.
|
4
|
+
|
5
|
+
This means if you check the same feature over and over, it will only make one Mongo, Redis, or whatever call per feature for the length of the request.
|
6
|
+
|
7
|
+
You can use the middleware from a Rails initializer like so:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
# create flipper dsl instance, see above Usage for more details
|
11
|
+
flipper = Flipper.new(...)
|
12
|
+
|
13
|
+
require 'flipper/middleware/memoizer'
|
14
|
+
config.middleware.use Flipper::Middleware::Memoizer, flipper
|
15
|
+
```
|
16
|
+
|
17
|
+
If you set your flipper instance up in an initializer, you can pass a block to the middleware and it will lazily load the instance the first time the middleware is invoked.
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
# config/initializers/flipper.rb
|
21
|
+
$flipper = Flipper.new(...)
|
22
|
+
|
23
|
+
# config/application.rb
|
24
|
+
config.middleware.use Flipper::Middleware::Memoizer, lambda { $flipper }
|
25
|
+
```
|
26
|
+
|
27
|
+
**Note**: Be sure that the middleware is high enough up in your stack that all feature checks are wrapped.
|
data/flipper.gemspec
CHANGED
@@ -1,17 +1,37 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
require File.expand_path('../lib/flipper/version', __FILE__)
|
3
3
|
|
4
|
+
plugin_files = []
|
5
|
+
plugin_test_files = []
|
6
|
+
|
7
|
+
Dir['flipper-*.gemspec'].map { |gemspec|
|
8
|
+
spec = eval(File.read(gemspec))
|
9
|
+
plugin_files << spec.files
|
10
|
+
plugin_test_files << spec.files
|
11
|
+
}
|
12
|
+
|
13
|
+
ignored_files = plugin_files
|
14
|
+
ignored_files << Dir['script/*']
|
15
|
+
ignored_files << ".travis.yml"
|
16
|
+
ignored_files << ".gitignore"
|
17
|
+
ignored_files << "Guardfile"
|
18
|
+
ignored_files.flatten!.uniq!
|
19
|
+
|
20
|
+
ignored_test_files = plugin_test_files
|
21
|
+
ignored_test_files.flatten!.uniq!
|
22
|
+
|
4
23
|
Gem::Specification.new do |gem|
|
5
24
|
gem.authors = ["John Nunemaker"]
|
6
25
|
gem.email = ["nunemaker@gmail.com"]
|
7
|
-
gem.summary = %q{Feature flipper for
|
8
|
-
gem.
|
26
|
+
gem.summary = %q{Feature flipper for ANYTHING}
|
27
|
+
gem.description = %q{Feature flipper is the act of enabling/disabling features in your application, ideally without re-deploying or changing anything in your code base. Flipper makes this extremely easy to do with any backend you would like to use.}
|
28
|
+
gem.homepage = "https://github.com/jnunemaker/flipper"
|
29
|
+
gem.license = "MIT"
|
9
30
|
|
10
31
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
11
|
-
gem.files = `git ls-files`.split("\n")
|
12
|
-
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
32
|
+
gem.files = `git ls-files`.split("\n") - ignored_files + ["lib/flipper/version.rb"]
|
33
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - ignored_test_files
|
13
34
|
gem.name = "flipper"
|
14
35
|
gem.require_paths = ["lib"]
|
15
36
|
gem.version = Flipper::VERSION
|
16
|
-
gem.license = "MIT"
|
17
37
|
end
|
@@ -2,6 +2,8 @@ require 'flipper/decorator'
|
|
2
2
|
|
3
3
|
module Flipper
|
4
4
|
module Adapters
|
5
|
+
# Public: Adapter super class for decorating another adapter. Used internally
|
6
|
+
# in flipper for the instrumented, memoizable and operation logger adapters.
|
5
7
|
class Decorator < ::Flipper::Decorator
|
6
8
|
include Adapter
|
7
9
|
end
|
@@ -3,6 +3,8 @@ require 'flipper/instrumenters/noop'
|
|
3
3
|
|
4
4
|
module Flipper
|
5
5
|
module Adapters
|
6
|
+
# Internal: Adapter that wraps another adapter and instruments all adapter
|
7
|
+
# operations. Used by flipper dsl to provide instrumentatin for flipper.
|
6
8
|
class Instrumented < Decorator
|
7
9
|
# Private: The name of instrumentation events.
|
8
10
|
InstrumentationName = "adapter_operation.#{InstrumentationNamespace}"
|
@@ -2,28 +2,20 @@ require 'flipper/adapters/decorator'
|
|
2
2
|
|
3
3
|
module Flipper
|
4
4
|
module Adapters
|
5
|
+
# Internal: Adapter that wraps another adapter with the ability to memoize
|
6
|
+
# adapter calls in memory. Used by flipper dsl and the memoizer middleware
|
7
|
+
# to make it possible to memoize adapter calls for the duration of a request.
|
5
8
|
class Memoizable < Decorator
|
6
9
|
FeaturesKey = :flipper_features
|
7
10
|
|
8
11
|
# Internal
|
9
|
-
|
10
|
-
Thread.current[:flipper_memoize_cache] ||= {}
|
11
|
-
end
|
12
|
-
|
13
|
-
# Internal
|
14
|
-
def self.memoizing?
|
15
|
-
!!Thread.current[:flipper_memoize]
|
16
|
-
end
|
17
|
-
|
18
|
-
# Internal
|
19
|
-
def self.memoize=(value)
|
20
|
-
cache.clear
|
21
|
-
Thread.current[:flipper_memoize] = value
|
22
|
-
end
|
12
|
+
attr_reader :cache
|
23
13
|
|
24
14
|
# Public
|
25
|
-
def initialize(adapter)
|
15
|
+
def initialize(adapter, cache = nil)
|
26
16
|
super(adapter)
|
17
|
+
@cache = cache || {}
|
18
|
+
@memoize = false
|
27
19
|
end
|
28
20
|
|
29
21
|
# Public
|
@@ -84,21 +76,17 @@ module Flipper
|
|
84
76
|
result
|
85
77
|
end
|
86
78
|
|
87
|
-
# Internal
|
88
|
-
def cache
|
89
|
-
self.class.cache
|
90
|
-
end
|
91
|
-
|
92
79
|
# Internal: Turns local caching on/off.
|
93
80
|
#
|
94
81
|
# value - The Boolean that decides if local caching is on.
|
95
82
|
def memoize=(value)
|
96
|
-
|
83
|
+
cache.clear
|
84
|
+
@memoize = value
|
97
85
|
end
|
98
86
|
|
99
87
|
# Internal: Returns true for using local cache, false for not.
|
100
88
|
def memoizing?
|
101
|
-
|
89
|
+
!!@memoize
|
102
90
|
end
|
103
91
|
end
|
104
92
|
end
|
@@ -2,6 +2,8 @@ require 'set'
|
|
2
2
|
|
3
3
|
module Flipper
|
4
4
|
module Adapters
|
5
|
+
# Public: Adapter for storing everything in memory (ie: Hash).
|
6
|
+
# Useful for tests/specs.
|
5
7
|
class Memory
|
6
8
|
include Adapter
|
7
9
|
|
@@ -23,7 +25,7 @@ module Flipper
|
|
23
25
|
|
24
26
|
# Public: Adds a feature to the set of known features.
|
25
27
|
def add(feature)
|
26
|
-
features.add(feature.
|
28
|
+
features.add(feature.key)
|
27
29
|
true
|
28
30
|
end
|
29
31
|
|
data/lib/flipper/type.rb
CHANGED
data/lib/flipper/types/actor.rb
CHANGED
@@ -3,17 +3,9 @@ module Flipper
|
|
3
3
|
class Actor < Type
|
4
4
|
def self.wrappable?(thing)
|
5
5
|
return false if thing.nil?
|
6
|
-
return true if thing.is_a?(Flipper::Types::Actor)
|
7
6
|
thing.respond_to?(:flipper_id)
|
8
7
|
end
|
9
8
|
|
10
|
-
def self.wrap(thing)
|
11
|
-
return thing if thing.is_a?(self)
|
12
|
-
new(thing)
|
13
|
-
end
|
14
|
-
|
15
|
-
attr_reader :value
|
16
|
-
|
17
9
|
def initialize(thing)
|
18
10
|
if thing.nil?
|
19
11
|
raise ArgumentError.new("thing cannot be nil")
|
data/lib/flipper/types/group.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Flipper
|
2
2
|
module Types
|
3
3
|
class Group < Type
|
4
|
-
|
5
4
|
def self.wrap(group_or_name)
|
6
5
|
return group_or_name if group_or_name.is_a?(self)
|
7
6
|
Flipper.group(group_or_name)
|
@@ -11,16 +10,13 @@ module Flipper
|
|
11
10
|
|
12
11
|
def initialize(name, &block)
|
13
12
|
@name = name.to_sym
|
13
|
+
@value = @name
|
14
14
|
@block = block
|
15
15
|
end
|
16
16
|
|
17
17
|
def match?(*args)
|
18
18
|
@block.call(*args) == true
|
19
19
|
end
|
20
|
-
|
21
|
-
def value
|
22
|
-
@name
|
23
|
-
end
|
24
20
|
end
|
25
21
|
end
|
26
22
|
end
|
@@ -1,14 +1,6 @@
|
|
1
1
|
module Flipper
|
2
2
|
module Types
|
3
3
|
class Percentage < Type
|
4
|
-
|
5
|
-
def self.wrap(value)
|
6
|
-
return value if value.is_a?(self)
|
7
|
-
new(value)
|
8
|
-
end
|
9
|
-
|
10
|
-
attr_reader :value
|
11
|
-
|
12
4
|
def initialize(value)
|
13
5
|
value = Typecast.to_integer(value)
|
14
6
|
|
@@ -18,11 +10,6 @@ module Flipper
|
|
18
10
|
|
19
11
|
@value = value
|
20
12
|
end
|
21
|
-
|
22
|
-
def eql?(other)
|
23
|
-
self.class.eql?(other.class) && value == other.value
|
24
|
-
end
|
25
|
-
alias_method :==, :eql?
|
26
13
|
end
|
27
14
|
end
|
28
15
|
end
|
data/lib/flipper/version.rb
CHANGED
@@ -5,16 +5,11 @@ require 'flipper/spec/shared_adapter_specs'
|
|
5
5
|
|
6
6
|
describe Flipper::Adapters::Memoizable do
|
7
7
|
let(:features_key) { described_class::FeaturesKey }
|
8
|
-
|
9
8
|
let(:adapter) { Flipper::Adapters::Memory.new }
|
10
9
|
let(:flipper) { Flipper.new(adapter) }
|
11
|
-
let(:cache) {
|
12
|
-
|
13
|
-
after do
|
14
|
-
described_class.memoize = nil
|
15
|
-
end
|
10
|
+
let(:cache) { {} }
|
16
11
|
|
17
|
-
subject { described_class.new(adapter) }
|
12
|
+
subject { described_class.new(adapter, cache) }
|
18
13
|
|
19
14
|
it_should_behave_like 'a flipper adapter'
|
20
15
|
|
@@ -3,7 +3,10 @@ require 'flipper/adapters/pstore'
|
|
3
3
|
require 'flipper/spec/shared_adapter_specs'
|
4
4
|
|
5
5
|
describe Flipper::Adapters::PStore do
|
6
|
-
subject {
|
6
|
+
subject {
|
7
|
+
dir = FlipperRoot.join("tmp").tap { |d| d.mkpath }
|
8
|
+
described_class.new(dir.join("flipper.pstore"))
|
9
|
+
}
|
7
10
|
|
8
11
|
it_should_behave_like 'a flipper adapter'
|
9
12
|
|
@@ -28,10 +28,14 @@ describe Flipper::Types::Actor do
|
|
28
28
|
described_class.wrappable?(actor).should eq(true)
|
29
29
|
end
|
30
30
|
|
31
|
-
it "returns true if responds to
|
31
|
+
it "returns true if responds to flipper_id" do
|
32
32
|
thing = thing_class.new(10)
|
33
33
|
described_class.wrappable?(thing).should eq(true)
|
34
34
|
end
|
35
|
+
|
36
|
+
it "returns false if nil" do
|
37
|
+
described_class.wrappable?(nil).should be(false)
|
38
|
+
end
|
35
39
|
end
|
36
40
|
|
37
41
|
describe ".wrap" do
|
data/spec/helper.rb
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
$:.unshift(File.expand_path('../../lib', __FILE__))
|
2
2
|
|
3
3
|
require 'pathname'
|
4
|
-
require 'logger'
|
5
|
-
|
6
4
|
FlipperRoot = Pathname(__FILE__).dirname.join('..').expand_path
|
7
|
-
lib_path = FlipperRoot.join('lib')
|
8
|
-
log_path = FlipperRoot.join('log')
|
9
|
-
log_path.mkpath
|
10
5
|
|
11
6
|
require 'rubygems'
|
12
7
|
require 'bundler'
|
@@ -14,6 +9,7 @@ require 'bundler'
|
|
14
9
|
Bundler.setup(:default)
|
15
10
|
|
16
11
|
require 'flipper'
|
12
|
+
require 'flipper-ui'
|
17
13
|
|
18
14
|
Dir[FlipperRoot.join("spec/support/**/*.rb")].each { |f| require f }
|
19
15
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'flipper/adapters/memory'
|
3
|
+
require 'rack/test'
|
4
|
+
|
5
|
+
module SpecHelpers
|
6
|
+
def self.included(base)
|
7
|
+
base.let(:flipper) { build_flipper }
|
8
|
+
base.let(:app) { build_app(flipper) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def build_app(flipper)
|
12
|
+
Flipper::UI.app(flipper, secret: "test")
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_flipper(adapter = build_memory_adapter)
|
16
|
+
Flipper.new(adapter)
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_memory_adapter
|
20
|
+
Flipper::Adapters::Memory.new
|
21
|
+
end
|
22
|
+
|
23
|
+
def json_response
|
24
|
+
JSON.load(last_response.body)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
RSpec.configure do |config|
|
29
|
+
config.include Rack::Test::Methods
|
30
|
+
config.include SpecHelpers
|
31
|
+
end
|
metadata
CHANGED
@@ -1,31 +1,33 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.0.
|
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-
|
11
|
+
date: 2015-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: Feature flipper is the act of enabling/disabling features in your application,
|
14
|
+
ideally without re-deploying or changing anything in your code base. Flipper makes
|
15
|
+
this extremely easy to do with any backend you would like to use.
|
14
16
|
email:
|
15
17
|
- nunemaker@gmail.com
|
16
18
|
executables: []
|
17
19
|
extensions: []
|
18
20
|
extra_rdoc_files: []
|
19
21
|
files:
|
20
|
-
- ".gitignore"
|
21
|
-
- ".rspec"
|
22
|
-
- ".travis.yml"
|
23
22
|
- Changelog.md
|
24
23
|
- Gemfile
|
25
|
-
- Guardfile
|
26
24
|
- LICENSE
|
27
25
|
- README.md
|
28
26
|
- Rakefile
|
27
|
+
- docs/Adapters.md
|
28
|
+
- docs/Gates.md
|
29
|
+
- docs/Instrumentation.md
|
30
|
+
- docs/Optimization.md
|
29
31
|
- examples/basic.rb
|
30
32
|
- examples/dsl.rb
|
31
33
|
- examples/example_setup.rb
|
@@ -74,10 +76,6 @@ files:
|
|
74
76
|
- lib/flipper/types/percentage_of_actors.rb
|
75
77
|
- lib/flipper/types/percentage_of_time.rb
|
76
78
|
- lib/flipper/version.rb
|
77
|
-
- script/bootstrap
|
78
|
-
- script/guard
|
79
|
-
- script/release
|
80
|
-
- script/test
|
81
79
|
- spec/flipper/adapters/instrumented_spec.rb
|
82
80
|
- spec/flipper/adapters/memoizable_spec.rb
|
83
81
|
- spec/flipper/adapters/memory_spec.rb
|
@@ -110,7 +108,8 @@ files:
|
|
110
108
|
- spec/helper.rb
|
111
109
|
- spec/integration_spec.rb
|
112
110
|
- spec/support/fake_udp_socket.rb
|
113
|
-
|
111
|
+
- spec/support/spec_helpers.rb
|
112
|
+
homepage: https://github.com/jnunemaker/flipper
|
114
113
|
licenses:
|
115
114
|
- MIT
|
116
115
|
metadata: {}
|
@@ -133,7 +132,7 @@ rubyforge_project:
|
|
133
132
|
rubygems_version: 2.2.2
|
134
133
|
signing_key:
|
135
134
|
specification_version: 4
|
136
|
-
summary: Feature flipper for
|
135
|
+
summary: Feature flipper for ANYTHING
|
137
136
|
test_files:
|
138
137
|
- spec/flipper/adapters/instrumented_spec.rb
|
139
138
|
- spec/flipper/adapters/memoizable_spec.rb
|
@@ -167,3 +166,4 @@ test_files:
|
|
167
166
|
- spec/helper.rb
|
168
167
|
- spec/integration_spec.rb
|
169
168
|
- spec/support/fake_udp_socket.rb
|
169
|
+
- spec/support/spec_helpers.rb
|
data/.gitignore
DELETED
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
data/.travis.yml
DELETED
data/Guardfile
DELETED
@@ -1,21 +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
|
-
:failed_mode => :keep,
|
13
|
-
:cmd => "bundle exec rspec",
|
14
|
-
}
|
15
|
-
|
16
|
-
guard 'rspec', rspec_options do
|
17
|
-
watch(%r{^spec/.+_spec\.rb$}) { "spec" }
|
18
|
-
watch(%r{^lib/(.+)\.rb$}) { "spec" }
|
19
|
-
watch(%r{shared_adapter_specs\.rb$}) { "spec" }
|
20
|
-
watch('spec/helper.rb') { "spec" }
|
21
|
-
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/guard
DELETED
data/script/release
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
#/ Usage: release
|
3
|
-
#/
|
4
|
-
#/ Package and release the gem to rubyforge.
|
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
|
-
script/bootstrap && bundle exec rake release
|
data/script/test
DELETED
@@ -1,30 +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 spec/qu_spec.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
|
-
specs="spec/"
|
24
|
-
|
25
|
-
if [ $# -gt 0 ]
|
26
|
-
then
|
27
|
-
specs=$@
|
28
|
-
fi
|
29
|
-
|
30
|
-
script/bootstrap && bundle exec rspec $specs
|