featurer 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 +4 -4
- data/.travis.yml +1 -0
- data/README.md +13 -1
- data/lib/featurer/adapters/redis.rb +8 -0
- data/lib/featurer/version.rb +1 -1
- data/spec/lib/featurer_spec.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cb600d87fa0d7bb593241b52b70d13b563a61f6
|
4
|
+
data.tar.gz: 5381460ea6488704484711d075b1d72357dc1c62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9fb938b9f5df59f8b71332d481b03845f3c6bd4179aa1619b7523002cc91c486240a8f40d0e0d29facbf5b811543b3740d751510725d4cb823deba64fc92260
|
7
|
+
data.tar.gz: 987eaefaaa92f73309581fa25a07286648613779a670651069f31ab8bda47c13809fc6d633e8167e8a3eed8c03685b7e9884fdc317a5a942798e4f5059492b15
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -52,7 +52,7 @@ Featurer.init
|
|
52
52
|
For different users:
|
53
53
|
|
54
54
|
```ruby
|
55
|
-
Featurer.register(:feature, [first_user_id,
|
55
|
+
Featurer.register(:feature, [first_user_id, second_user_id, third_user_id])
|
56
56
|
```
|
57
57
|
|
58
58
|
or single:
|
@@ -67,6 +67,12 @@ Then request the enabled feature:
|
|
67
67
|
Featurer.on?(:feature, user_id)
|
68
68
|
```
|
69
69
|
|
70
|
+
In order to remove a user from a feature:
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
Featurer.off(:feature, user_id)
|
74
|
+
```
|
75
|
+
|
70
76
|
#### Global feature
|
71
77
|
|
72
78
|
```ruby
|
@@ -79,6 +85,12 @@ Then request the enabled feature:
|
|
79
85
|
Featurer.on? :feature
|
80
86
|
```
|
81
87
|
|
88
|
+
In order to remove multiple users from a feature:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
Featurer.off(:feature, [first_user_id, second_user_id])
|
92
|
+
```
|
93
|
+
|
82
94
|
#### Deleting features
|
83
95
|
|
84
96
|
```ruby
|
@@ -18,6 +18,10 @@ module Featurer
|
|
18
18
|
fetch_from_set(feature, value)
|
19
19
|
end
|
20
20
|
|
21
|
+
def off(feature, value)
|
22
|
+
remove_from_set(feature, value)
|
23
|
+
end
|
24
|
+
|
21
25
|
def register(name, value = true)
|
22
26
|
# ensure old data is wiped
|
23
27
|
delete(name)
|
@@ -41,5 +45,9 @@ module Featurer
|
|
41
45
|
def fetch_from_set(name, id)
|
42
46
|
@redis.sismember(key(name), id)
|
43
47
|
end
|
48
|
+
|
49
|
+
def remove_from_set(name, id)
|
50
|
+
@redis.srem(key(name), id)
|
51
|
+
end
|
44
52
|
end
|
45
53
|
end
|
data/lib/featurer/version.rb
CHANGED
data/spec/lib/featurer_spec.rb
CHANGED
@@ -34,6 +34,22 @@ describe Featurer do
|
|
34
34
|
expect(Featurer.on?(:feature)).to be
|
35
35
|
expect(Featurer.on?(:feature, user_id)).to_not be
|
36
36
|
end
|
37
|
+
|
38
|
+
it 'should remove a single user from the feature' do
|
39
|
+
Featurer.register :feature, [user_id, user_id + 1]
|
40
|
+
Featurer.off :feature, user_id
|
41
|
+
|
42
|
+
expect(Featurer.on?(:feature, user_id)).to_not be
|
43
|
+
expect(Featurer.on?(:feature, user_id + 1)).to be
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should remove a multiple users from the feature' do
|
47
|
+
Featurer.register :feature, [user_id, user_id + 1]
|
48
|
+
|
49
|
+
Featurer.off :feature, [user_id, user_id + 1]
|
50
|
+
expect(Featurer.on?(:feature, user_id)).to_not be
|
51
|
+
expect(Featurer.on?(:feature, user_id + 1)).to_not be
|
52
|
+
end
|
37
53
|
end
|
38
54
|
|
39
55
|
describe 'global' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: featurer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alejandro El Informatico
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|