this_feature 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/docs/memory.md +29 -8
- data/docs/splitio.md +35 -0
- data/lib/this_feature/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6fdd8f4258c9cca45bdf31d7370e100eb9175102ba565f3368f23a83edf8d46
|
4
|
+
data.tar.gz: 79c1cbce63fad4511b3a5828fcc90cecb609db1abf2047c01270f7246c1631be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8cb49d96981b3320399c856fcd5367e54fc478c9af60e4bfacbf6d2a54a990fa89db7344e8e1b342cbb2a764e57c7b6ca3f7dddec0247fa6f6521250f40f565
|
7
|
+
data.tar.gz: b3804fb6eb9f37a12e2a8a477ed730ca83ed2cdf7d1a419c39b75ba1d9a4d9243051ee292dfdc59a5d68a2cb3a5d901a2606455916a6a0a22f2b73a5aab27c50
|
data/README.md
CHANGED
@@ -63,7 +63,7 @@ These adapters do behave slightly differently, so make sure to read the followin
|
|
63
63
|
|
64
64
|
- [Flipper adapter](./docs/flipper.md)
|
65
65
|
- [Split.io adapter](./docs/splitio.md)
|
66
|
-
- [Memory adapter](./docs/memory.md) - **
|
66
|
+
- [Memory adapter](./docs/memory.md) - **designed for use in tests**
|
67
67
|
|
68
68
|
## Development
|
69
69
|
|
data/docs/memory.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
# ThisFeature - Memory Adapter
|
2
2
|
|
3
|
+
## Synopsis
|
4
|
+
|
5
|
+
Under the hood, the memory adapter stores data in a dictionary like so:
|
6
|
+
|
7
|
+
```
|
8
|
+
{
|
9
|
+
some_flag_name: {
|
10
|
+
global: false,
|
11
|
+
contexts: {
|
12
|
+
User1: true,
|
13
|
+
User2: false
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
```
|
18
|
+
|
19
|
+
Since it doesn't require actual DB lookups, it's faster, and works well for use
|
20
|
+
in test suites.
|
21
|
+
|
3
22
|
## Installation
|
4
23
|
|
5
24
|
This adapter is included with the core gem:
|
@@ -16,9 +35,9 @@ require 'this_feature'
|
|
16
35
|
require 'this_feature/adapters/memory'
|
17
36
|
|
18
37
|
ThisFeature.configure do |config|
|
19
|
-
|
20
|
-
config.adapters = [
|
21
|
-
config.default_adapter =
|
38
|
+
config.test_adapter = ThisFeature::Adapters::Memory.new
|
39
|
+
config.adapters = [config.test_adapter]
|
40
|
+
config.default_adapter = config.test_adapter
|
22
41
|
end
|
23
42
|
```
|
24
43
|
|
@@ -26,8 +45,9 @@ The initializer takes an optional `context_key_method` argument. This is only re
|
|
26
45
|
it specifies a method name which should be called on the context object to determine its identity.
|
27
46
|
For example:
|
28
47
|
|
29
|
-
```
|
30
|
-
# Say you have this method which you want to use as the "identity"
|
48
|
+
```ruby
|
49
|
+
# Say you have this method which you want to use as the "identity"
|
50
|
+
# of a context object (e.g. imagine this module is included onto User)
|
31
51
|
module FeatureFlaggable
|
32
52
|
def this_feature_id
|
33
53
|
"#{self.class}-#{self.id}"
|
@@ -48,7 +68,8 @@ The `context` argument is supported, but not `data`.
|
|
48
68
|
|
49
69
|
Read the following notes as well:
|
50
70
|
|
51
|
-
- **on?** / **off?**:
|
71
|
+
- **on?** / **off?**: If passed a `context` argument, uses the aformentioned logic
|
72
|
+
(`context_key_method`) to determine how it's handled.
|
52
73
|
|
53
74
|
- **control?** is not yet implemented
|
54
75
|
|
@@ -60,6 +81,6 @@ Usage example of these:
|
|
60
81
|
|
61
82
|
```
|
62
83
|
# If you have configured the in-memory adapter as the default
|
63
|
-
ThisFeature.
|
64
|
-
ThisFeature.
|
84
|
+
ThisFeature.test_adapter.on!(:flag_name, context: user) # with context
|
85
|
+
ThisFeature.test_adapter.off!(:flag_name) # without context
|
65
86
|
```
|
data/docs/splitio.md
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
# ThisFeature - Split Adapter
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
gem 'this_feature-adapters-split-io
|
7
|
+
```
|
8
|
+
|
9
|
+
## Configuration
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
# config/initializers/this_feature.rb
|
13
|
+
require 'this_feature'
|
14
|
+
require 'this_feature/adapters/split_io'
|
15
|
+
|
16
|
+
ThisFeature.configure do |config|
|
17
|
+
adapter = ThisFeature::Adapters::SplitIo.new
|
18
|
+
config.adapters = [adapter]
|
19
|
+
config.default_adapter = adapter
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
An existing Split client can be optionally passed to the initializer:
|
24
|
+
|
25
|
+
```
|
26
|
+
ThisFeature::Adapters::SplitIo.new(client: my_existing_client)
|
27
|
+
```
|
28
|
+
|
29
|
+
## API
|
30
|
+
|
31
|
+
The SplitIo adapter supports the public API of `ThisFeature`.
|
32
|
+
|
33
|
+
Both `context` and `data` are supported.
|
34
|
+
|
35
|
+
`control` is a native Split feature, so we perform a query to Split to get this info.
|
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.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Pleaner
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|