this_feature 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -6
- data/README.md +27 -38
- data/docs/flipper.html +1087 -0
- data/docs/flipper.md +41 -0
- data/docs/memory.md +65 -0
- data/docs/splitio.md +0 -0
- data/docs/writing_an_adapter.md +1 -0
- data/lib/this_feature.rb +4 -0
- data/lib/this_feature/adapters/base.rb +0 -5
- data/lib/this_feature/configuration.rb +5 -2
- data/lib/this_feature/version.rb +1 -1
- metadata +11 -6
data/docs/flipper.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# ThisFeature - Flipper Adapter
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
gem 'this_feature-adapters-flipper
|
7
|
+
```
|
8
|
+
|
9
|
+
## Configuration
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
# config/initializers/this_feature.rb
|
13
|
+
require 'this_feature'
|
14
|
+
require 'this_feature/adapters/flipper'
|
15
|
+
|
16
|
+
ThisFeature.configure do |config|
|
17
|
+
adapter = ThisFeature::Adapters::Flipper.new
|
18
|
+
config.adapters = [adapter]
|
19
|
+
config.default_adapter = adapter
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
An existing Flipper client can be optionally passed to the initializer:
|
24
|
+
|
25
|
+
```
|
26
|
+
ThisFeature::Adapters::Flipper.new(client: my_existing_client)
|
27
|
+
```
|
28
|
+
|
29
|
+
|
30
|
+
## API
|
31
|
+
|
32
|
+
The Flipper adapter supports the public API of `ThisFeature`.
|
33
|
+
|
34
|
+
The `context` argument is supported, but not `data`.
|
35
|
+
|
36
|
+
Read the following notes as well:
|
37
|
+
|
38
|
+
- **on?** / **off?**: Under the hood, calls `flipper_id` method on the `context`, if one was given.
|
39
|
+
- **control?** / **present?**: Flipper doesn't have a concept of "control", so we just implement it as `!present?`
|
40
|
+
|
41
|
+
It is possible to support `on!` and `off!` from Flipper but that's not implemented yet.
|
data/docs/memory.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# ThisFeature - Memory Adapter
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
This adapter is included with the core gem:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'this_feature
|
9
|
+
```
|
10
|
+
|
11
|
+
## Configuration
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
# config/initializers/this_feature.rb
|
15
|
+
require 'this_feature'
|
16
|
+
require 'this_feature/adapters/memory'
|
17
|
+
|
18
|
+
ThisFeature.configure do |config|
|
19
|
+
adapter = ThisFeature::Adapters::Memory.new
|
20
|
+
config.adapters = [adapter]
|
21
|
+
config.default_adapter = adapter
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
The initializer takes an optional `context_key_method` argument. This is only relevant when using `context` -
|
26
|
+
it specifies a method name which should be called on the context object to determine its identity.
|
27
|
+
For example:
|
28
|
+
|
29
|
+
```
|
30
|
+
# Say you have this method which you want to use as the "identity" of a context object:
|
31
|
+
module FeatureFlaggable
|
32
|
+
def this_feature_id
|
33
|
+
"#{self.class}-#{self.id}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Then you would refer to it like so in the initializer:
|
38
|
+
ThisFeature::Adapters::Memory.new(context_key_method: :this_feature_id)
|
39
|
+
```
|
40
|
+
|
41
|
+
If this option is ommitted, then the context object uses its `self` as its "identity".
|
42
|
+
|
43
|
+
## API
|
44
|
+
|
45
|
+
The Memory adapter supports the public API of `ThisFeature`.
|
46
|
+
|
47
|
+
The `context` argument is supported, but not `data`.
|
48
|
+
|
49
|
+
Read the following notes as well:
|
50
|
+
|
51
|
+
- **on?** / **off?**: Under the hood, calls `flipper_id` method on the `context`, if one was given.
|
52
|
+
|
53
|
+
- **control?** is not yet implemented
|
54
|
+
|
55
|
+
We also support two additional methods here that aren't present on the main adapter yet:
|
56
|
+
|
57
|
+
- **on!** / **off!**
|
58
|
+
|
59
|
+
Usage example of these:
|
60
|
+
|
61
|
+
```
|
62
|
+
# If you have configured the in-memory adapter as the default
|
63
|
+
ThisFeature.default_adapter.on!(:flag_name, context: user) # with context
|
64
|
+
ThisFeature.default_adapter.off!(:flag_name) # without context
|
65
|
+
```
|
data/docs/splitio.md
ADDED
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
todo
|
data/lib/this_feature.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
1
|
class ThisFeature
|
3
2
|
class Configuration
|
4
|
-
attr_writer :adapters, :default_adapter
|
3
|
+
attr_writer :adapters, :default_adapter, :test_adapter
|
5
4
|
|
6
5
|
def init
|
7
6
|
validate_adapters!
|
@@ -20,5 +19,9 @@ class ThisFeature
|
|
20
19
|
def default_adapter
|
21
20
|
@default_adapter ||= adapters.first
|
22
21
|
end
|
22
|
+
|
23
|
+
def test_adapter
|
24
|
+
@test_adapter ||= Adapters::Memory.new
|
25
|
+
end
|
23
26
|
end
|
24
27
|
end
|
data/lib/this_feature/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: this_feature
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Pleaner
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -127,6 +127,11 @@ files:
|
|
127
127
|
- Rakefile
|
128
128
|
- bin/console
|
129
129
|
- bin/setup
|
130
|
+
- docs/flipper.html
|
131
|
+
- docs/flipper.md
|
132
|
+
- docs/memory.md
|
133
|
+
- docs/splitio.md
|
134
|
+
- docs/writing_an_adapter.md
|
130
135
|
- lib/this_feature.rb
|
131
136
|
- lib/this_feature/adapters.rb
|
132
137
|
- lib/this_feature/adapters/base.rb
|
@@ -145,7 +150,7 @@ licenses: []
|
|
145
150
|
metadata:
|
146
151
|
homepage_uri: https://github.com/hoverinc/this_feature
|
147
152
|
source_code_uri: https://github.com/hoverinc/this_feature
|
148
|
-
post_install_message:
|
153
|
+
post_install_message:
|
149
154
|
rdoc_options: []
|
150
155
|
require_paths:
|
151
156
|
- lib
|
@@ -160,8 +165,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
165
|
- !ruby/object:Gem::Version
|
161
166
|
version: '0'
|
162
167
|
requirements: []
|
163
|
-
rubygems_version: 3.
|
164
|
-
signing_key:
|
168
|
+
rubygems_version: 3.0.3
|
169
|
+
signing_key:
|
165
170
|
specification_version: 4
|
166
171
|
summary: Feature flag control
|
167
172
|
test_files: []
|