enabler 0.0.2 → 0.0.3

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: 81a5568c263c249d5c68726e559979f77c71d85c
4
- data.tar.gz: 8e2c9dec31542bc566abdde1dbf2bd4c2e6b455c
3
+ metadata.gz: 7292b10984446825ad2199ad40de2589136c203b
4
+ data.tar.gz: 9ef0a852a2c72b8a1dec129969731e6525946834
5
5
  SHA512:
6
- metadata.gz: b879b9fa5f9480de357d9bd6f1972a66ad7c428874358d118e5fa593ec41e83f7250290c9a56833f3be10fc340aeaf94bbdd5ebcadfbedfd4b15f87be53f24f6
7
- data.tar.gz: bdc32849784e5138dc7e7b59d09318775b41a92c03de83e07a22096b8644c47278470b51cf8a0afd4a60eba25aac37aea5190fb43d6f3d9fd8390d95ce752993
6
+ metadata.gz: 27d862408a5fb3547f41365ef5cd4e562302e2a5f6e69e9642147a522f8f9bf45d1e6f3bd938d3f27a3d4433c37d9a86579ac70942548d22e0a24dbc0ccb671a
7
+ data.tar.gz: 94f7ff34fbaaabd17e1f5535a6e4b4e969503234219ce54157b9aa3f553ce437dc7d0c266a07ab1d415a9cf418a0bebb37b2e87bc9f92b2a72acbd4ad60b845a
data/.gitignore CHANGED
@@ -32,3 +32,5 @@ build/
32
32
 
33
33
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
34
  .rvmrc
35
+
36
+ .DS_STORE
data/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Enabler
2
2
 
3
- Feature enabler
3
+ ### Granular Feature Enabling For Ruby Apps
4
+
5
+ There are a fair few feature flip gems out there. None of them had *exactly* the feature set I needed. Most either flipped features globally or worked only on the basis of a user class. I needed to be able to switch features on for users, teams of users OR entirely different models altogether E.G companies
6
+
7
+ The goal of this gem is to enable very *granular* control of which users/teams/companies/customers/cats have access to which features.
8
+
4
9
 
5
10
  ## Installation
6
11
 
@@ -18,7 +23,49 @@ Or install it yourself as:
18
23
 
19
24
  ## Usage
20
25
 
21
- TODO: Write usage instructions here
26
+ ### Configuration
27
+
28
+ Currently there is only one storage adapter - Redis
29
+
30
+ ```Ruby
31
+ Enabler.store = Enabler::Storage::Redis.new($redis)
32
+ ```
33
+
34
+ ### Rules
35
+
36
+ ```Ruby
37
+ Enabler.define_rule! :dance do |object|
38
+ object.is_cool?
39
+ end
40
+ ```
41
+
42
+ ### Specific Models
43
+
44
+ ```Ruby
45
+ Enabler.enable! :dance, User.first
46
+ ```
47
+
48
+ ### Check if feature enabled for object
49
+
50
+ ```Ruby
51
+ class NewFeatureController < ActionController::Base
52
+ def show
53
+ redirect_to '/home' unless Enabler.enabled? :new_feature, current_user
54
+ render_super_secret_awesome_new_feature
55
+ end
56
+ end
57
+ ```
58
+
59
+
60
+
61
+ ## TODO
62
+ * caching
63
+ * group definitions
64
+ * rake task to add feature for percentage of users
65
+ * ActiveRecord storage
66
+ * Mongo storage
67
+ * In memory storage
68
+
22
69
 
23
70
  ## Contributing
24
71
 
@@ -1,3 +1,3 @@
1
1
  module Enabler
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/enabler.rb CHANGED
@@ -26,7 +26,7 @@ module Enabler
26
26
  sym = feature.to_sym
27
27
  r = self.rule(sym)
28
28
  return false unless r
29
- r.enabled?(model)
29
+ r.enabled?(object)
30
30
  end
31
31
 
32
32
  def self.enable!(feature, object)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enabler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Roberts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-13 00:00:00.000000000 Z
11
+ date: 2014-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis