envato/flip — pull request #1 by madlep (2013-07-18 23:57:58+00:00)
Title: Envato wip (Don't merge!)

**DON'T MERGE THIS - NOT READY FOR UPSTREAM PR - JUST FOR COMMENT INTERNALLY BY ENVATO PEEPS**

**NOTE** This is a public PR based on Envato hax to flip - remember all comments here are public :smiley:

The flip gem has been severely hacked to bend it to our will. We'll need to tidy the major pieces of functionality up, and send through individual PRs upstream to https://github.com/pda/flip

# Major changes
- Added abstracted `AbstractStore` (currently just `RedisStore` implementation)
- Use `data_store` to store configuration params for each strategy/definition
- global strategy (similar to `DatabaseStrategy`, but using data store)
- pass options when `Flip.on?` DSL is called in client code. This allows usernames to be specified for feature flag decision logic
- added `DeterministicPercentageStrategy` to allow a feature to be ramped up - is deterministic based on modulus on some ID (probably user.id). This means the same users will always have access to a feature, instead of it being random everytime
- added `HostStrategy` to allow a feature to be turned on/off for a single domain name (e.g. with envato marketplaces http://themeforest.net http://codecanyon.net being served from same codebase, but with different domain names)
- added 'UsernameStrategy` to allow a feature to be turned on for a specified list of users.

# TODO

- [ ] split this out into smaller, cleaner PRs to merge upstream
- [ ] provide active record implementation of `AbstractStore`
- [ ] update generators to create app code that makes sense with this set up
- [ ] copy + paste admin views/controllers from envato marketplace (they've been copied there and hacked in the app directly - all the configuration UI lives there)
- [ ] `GlobalStrategy` spec needs updating (Still refers to `RedisStrategy` prior to refactoring into `GlobalStrategy`)
- [ ] make `DeterministicPercentageStrategy` do a hash code on the definition + id, so the same poor 1% of users aren't always the guinea pigs for experimental (broken ) new features
- [ ] `FeatureSet` and the way controller filters are done isn't thread safe. Ok for us for now, but would be nice to fix this up if we want to run it under multithreaded jruby.