this_feature-adapters-split_io 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6cb0a20a6a7a888a624d86ca2e475d2b454ab83d38da2260f64bfde338e23372
4
- data.tar.gz: 0c641b2a19a9d6f3712d8f18d8ff9001cadf4b7b48049f43e5ab3ea600c56b93
3
+ metadata.gz: 8a46929b3ddedeb9808f8fc356b67cfaec1884c3c4a02475b83ceda7b492068e
4
+ data.tar.gz: a522ef64174ce87ea9bcf235999b7e2037ab7f669d1045dadbc211e1b3978484
5
5
  SHA512:
6
- metadata.gz: 5369ff715d49923f8bee08147b5d13c433c2579a02ceceafe960402b768c78c9ef384b6e13e28b760e370e054a2295c19f172cb3246516283d0035dce4266f10
7
- data.tar.gz: cd4b17fb6004eb290eb4ecdd950afa72a7f8235d62d1bec9d16cffd032086951471fa315b68eb02b7a039bf4958889ce2463860f42a3b65aa460dd191d5c7a64
6
+ metadata.gz: 07dfc5e0b5b9174d02311779e5b168968ffd7ff86fd58e627b96d1a7dd3725b4d5ddcd6c7d002c893ce53ca6569fe6f7436150561c478989b02a57fe5b36c030
7
+ data.tar.gz: 62832ca8bb289e3f070ff0831cfb1c971b6a7f02f347a843947cca8d5e41a1e0b21e69ed0f298d86c6ec32bc915df6a64ebfb002315d7a3bf8e5c4c0c46c81a2
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- this_feature (0.4.1)
5
- this_feature-adapters-flipper (0.4.1)
4
+ this_feature (0.5.0)
5
+ this_feature-adapters-flipper (0.5.0)
6
6
  flipper (~> 0.16)
7
7
  flipper-active_record (~> 0.16)
8
8
  this_feature
9
- this_feature-adapters-split_io (0.4.1)
9
+ this_feature-adapters-split_io (0.5.0)
10
10
  splitclient-rb
11
11
  this_feature
12
12
 
@@ -35,10 +35,10 @@ GEM
35
35
  diff-lcs (1.3)
36
36
  faraday (1.0.1)
37
37
  multipart-post (>= 1.2, < 3)
38
- flipper (0.18.0)
39
- flipper-active_record (0.18.0)
38
+ flipper (0.19.0)
39
+ flipper-active_record (0.19.0)
40
40
  activerecord (>= 5.0, < 7)
41
- flipper (~> 0.18.0)
41
+ flipper (~> 0.19.0)
42
42
  gem-release (2.1.1)
43
43
  hitimes (1.3.1)
44
44
  i18n (1.8.5)
data/README.md CHANGED
@@ -1,65 +1,44 @@
1
1
  # ThisFeature
2
2
 
3
- The purpose of ThisFeature is to have one way to use feature flags
3
+ **A common interface to interact with many feature flag providers.**
4
4
 
5
- ## Installation
5
+ Can be used to more easily migrate among providers.
6
+
7
+ If your code uses ThisFeature,
8
+ then you can just swap out the adapter without having to do a bunch of find-and-replace.
6
9
 
7
- Add this line to your application's `Gemfile`:
10
+ ## Installation
8
11
 
9
12
  ```ruby
10
13
  gem 'this_feature'
11
14
  ```
12
15
 
13
- And then execute:
14
-
15
- ```sh
16
- bundle
17
- ```
18
-
19
- Or install it yourself as:
20
-
21
- ```sh
22
- gem install this_feature
23
- ```
24
-
25
16
  ## Configuration
26
17
 
27
18
  ```ruby
28
19
  # config/initializers/this_feature.rb
29
20
  require 'this_feature'
21
+ require 'this_feature/adapters/memory'
30
22
 
31
23
  ThisFeature.configure do |config|
32
- config.adapters = [ThisFeature::Adapters::Memory]
33
- config.default_adapter = config.adapters.first
24
+ adapter = ThisFeature::Adapters::Memory.new
25
+ config.adapters = [adapter]
26
+ config.default_adapter = adapter
34
27
  end
35
28
  ```
36
29
 
37
30
  **NOTE**: When searching for the presence of a flag, adapters are queried in order. The default adapter is the fallback adapter used when a flag isn't present in any of the adapters.
38
31
 
39
-
40
- ### With Flipper
41
-
42
- ```ruby
43
- # config/initializers/this_feature.rb
44
- require 'this_feature/adapters/flipper'
45
-
46
- ThisFeature.configure do |config|
47
- config.adapters = [ThisFeature::Adapters::Flipper]
48
- config.default_adapter = config.adapters.first
49
- end
50
- ```
51
-
52
-
53
-
54
32
  ## Usage
55
33
 
56
34
  ### Flags
35
+
57
36
  ```ruby
58
- ThisFeature.flag('flag_name').on? # check if flag is turned on
59
- ThisFeature.flag('flag_name').off? # check if flag is turned off
60
- ThisFeature.flag('flag_name').control? # see if the adapter is using the control
61
- ThisFeature.flag('flag_name').on! # turn on the flag
62
- ThisFeature.flag('flag_name').off! # turn off the flag
37
+ ThisFeature.flag('flag_name').on? # is the flag is turned on?
38
+ ThisFeature.flag('flag_name').off? # is the flag is turned off?
39
+ ThisFeature.flag('flag_name').control? # is the adapter is using the control?
40
+ ThisFeature.flag('flag_name').present? # is the flag set at all?
41
+ ThisFeature.default_adapter # access the default adapter directly if needed
63
42
  ```
64
43
 
65
44
  ### Context
@@ -78,8 +57,13 @@ In case context is not sufficient, you can also pass a data hash.
78
57
  ThisFeature.flag('flag_name', context: context, data: { org_id: 1 }).on?
79
58
  ```
80
59
 
81
- ## TODO: Write documentation for the adapters (creating adapters, using memory adapter, using flipper adapter)
60
+ ## Available Adapters
61
+
62
+ These adapters do behave slightly differently, so make sure to read the following docs:
82
63
 
64
+ - [Flipper adapter](./docs/flipper.md)
65
+ - [Split.io adapter](./docs/splitio.md)
66
+ - [Memory adapter](./docs/memory.md) - **very helpful to use in tests**
83
67
 
84
68
  ## Development
85
69
 
@@ -90,6 +74,11 @@ You can run the tests with these commands in your Terminal:
90
74
  bundle install && bundle exec rspec
91
75
  ```
92
76
 
77
+ To write a new adapter, check the [Guide](./docs/writing_an_adapter.md).
78
+
93
79
  ## License
94
80
 
95
81
  ThisFeature is released under the [MIT License](https://choosealicense.com/licenses/mit).
82
+
83
+
84
+
@@ -34,4 +34,8 @@ class ThisFeature
34
34
  def self.adapters
35
35
  configuration.adapters
36
36
  end
37
+
38
+ def self.test_adapter
39
+ configuration.test_adapter
40
+ end
37
41
  end
@@ -1,11 +1,6 @@
1
1
  class ThisFeature
2
2
  module Adapters
3
3
  class Base
4
-
5
- def setup
6
- raise UnimplementedError.new(self, __method__)
7
- end
8
-
9
4
  def present?(flag_name)
10
5
  raise UnimplementedError.new(self, __method__)
11
6
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  class ThisFeature
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: this_feature-adapters-split_io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Pleaner
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-09-11 00:00:00.000000000 Z
12
+ date: 2020-09-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: this_feature