feature_creep 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- feature_creep (0.1.2)
4
+ feature_creep (0.2.0)
5
5
  redis
6
6
 
7
7
  GEM
@@ -23,18 +23,22 @@ class FeatureCreep
23
23
 
24
24
  # Activate Methods
25
25
  def activate_globally(feature)
26
+ add_feature(feature)
26
27
  @datastore.activate_globally(feature)
27
28
  end
28
29
 
29
30
  def activate_scope(feature, scope)
31
+ add_feature(feature)
30
32
  @datastore.activate_scope(feature, scope)
31
33
  end
32
34
 
33
35
  def activate_agent_id(feature, agent_id)
36
+ add_feature(feature)
34
37
  @datastore.activate_agent_id(feature, agent_id)
35
38
  end
36
39
 
37
40
  def activate_percentage(feature, percentage)
41
+ add_feature(feature)
38
42
  @datastore.activate_percentage(feature, percentage)
39
43
  end
40
44
 
@@ -108,6 +112,10 @@ class FeatureCreep
108
112
  @datastore.add_feature(feature)
109
113
  end
110
114
 
115
+ def remove_feature(feature)
116
+ @datastore.remove_feature(feature)
117
+ end
118
+
111
119
  def info(feature = nil)
112
120
  @info.call(self,feature)
113
121
  end
@@ -6,57 +6,50 @@ class FeatureCreep
6
6
  @redis = datastore || Redis.new
7
7
  end
8
8
 
9
+ # Activate Methods
9
10
  def activate_globally(feature)
10
- add_feature(feature)
11
11
  @redis.sadd(global_key, feature)
12
12
  end
13
13
 
14
- def deactivate_globally(feature)
15
- @redis.srem(global_key, feature)
16
- end
17
-
18
14
  def activate_scope(feature, scope)
19
- add_feature(feature)
20
15
  @redis.sadd(scope_key(feature), scope)
21
16
  end
22
17
 
23
- def deactivate_scope(feature, scope)
24
- @redis.srem(scope_key(feature), scope)
18
+ def activate_agent_id(feature, agent_id)
19
+ @redis.sadd(agent_id_key(feature), agent_id)
25
20
  end
26
21
 
27
- def deactivate_all(feature)
28
- @redis.del(scope_key(feature))
29
- @redis.del(agent_id_key(feature))
30
- @redis.del(percentage_key(feature))
31
- deactivate_globally(feature)
22
+ def activate_percentage(feature, percentage)
23
+ @redis.set(percentage_key(feature), percentage)
32
24
  end
33
25
 
34
- def activate_agent_id(feature, agent_id)
35
- add_feature(feature)
36
- @redis.sadd(agent_id_key(feature), agent_id)
26
+ # Deactivate Methods
27
+ def deactivate_globally(feature)
28
+ @redis.srem(global_key, feature)
29
+ end
30
+
31
+ def deactivate_scope(feature, scope)
32
+ @redis.srem(scope_key(feature), scope)
37
33
  end
38
34
 
39
35
  def deactivate_agent_id(feature, agent_id)
40
36
  @redis.srem(agent_id_key(feature), agent_id)
41
37
  end
42
38
 
43
- def active?(feature, agent_id = nil)
44
- if agent_id
45
- active_globally?(feature) ||
46
- agent_id_in_active_scope?(feature, agent_id) ||
47
- agent_id_active?(feature, agent_id) ||
48
- agent_id_within_active_percentage?(feature, agent_id)
49
- else
50
- active_globally?(feature)
51
- end
39
+ def deactivate_percentage(feature)
40
+ @redis.del(percentage_key(feature))
52
41
  end
53
42
 
54
- def activate_percentage(feature, percentage)
55
- @redis.set(percentage_key(feature), percentage)
43
+ def deactivate_all(feature)
44
+ @redis.del(scope_key(feature))
45
+ @redis.del(agent_id_key(feature))
46
+ @redis.del(percentage_key(feature))
47
+ deactivate_globally(feature)
56
48
  end
57
49
 
58
- def deactivate_percentage(feature)
59
- @redis.del(percentage_key(feature))
50
+ # Reporting Methods
51
+ def active_global_features
52
+ (@redis.smembers(global_key) || []).map(&:to_sym)
60
53
  end
61
54
 
62
55
  def active_scopes(feature)
@@ -67,14 +60,11 @@ class FeatureCreep
67
60
  @redis.smembers(agent_id_key(feature))
68
61
  end
69
62
 
70
- def active_global_features
71
- (@redis.smembers(global_key) || []).map(&:to_sym)
72
- end
73
-
74
63
  def active_percentage(feature)
75
64
  @redis.get(percentage_key(feature))
76
65
  end
77
66
 
67
+ # Boolean Methods
78
68
  def active_globally?(feature)
79
69
  @redis.sismember(global_key, feature)
80
70
  end
@@ -89,6 +79,7 @@ class FeatureCreep
89
79
  agent_id % 100 < percentage.to_i
90
80
  end
91
81
 
82
+ # Utility Methods
92
83
  def features
93
84
  @redis.smembers(@key_prefix).map(&:to_sym)
94
85
  end
@@ -97,6 +88,10 @@ class FeatureCreep
97
88
  @redis.sadd(@key_prefix, feature)
98
89
  end
99
90
 
91
+ def remove_feature(feature)
92
+ @redis.srem(@key_prefix, feature)
93
+ end
94
+
100
95
  private
101
96
  def key(name)
102
97
  "#{@key_prefix}:#{name}"
@@ -1,3 +1,3 @@
1
1
  class FeatureCreep
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feature_creep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: