flipper-sequel 0.22.2 → 0.23.0
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/lib/flipper/version.rb +1 -1
- data/spec/flipper/adapters/sequel_spec.rb +0 -2
- metadata +5 -6
- data/docs/sequel/README.md +0 -103
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8e3f9947bf861064bf8986d7456aebd581a448d907fdcaff54c02c92ca2197f
|
4
|
+
data.tar.gz: a53796f762aaa927baafdfae6dfae234c5f27510069ea980ab64ee09430ac650
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 571d14ed54c82b7b6e6da8afb61a15fe9345ac4d7341d2f40a5036e2989caaff1ea9182cf19bf930c6815f41839af5f6909a4318dc8dce6cb963e4e5b2036578
|
7
|
+
data.tar.gz: 50447c3d780a7794cd3d0cb1469b99532517983657f071b809d4bf4d219b152bde2c622baeb5187dea6233a17e04c87cc8a1639504dd29284bd19ad862fef2a8
|
data/lib/flipper/version.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'helper'
|
2
1
|
require 'sequel'
|
3
2
|
|
4
3
|
Sequel::Model.db = Sequel.sqlite(':memory:')
|
@@ -6,7 +5,6 @@ Sequel.extension :migration, :core_extensions
|
|
6
5
|
|
7
6
|
require 'flipper/adapters/sequel'
|
8
7
|
require 'generators/flipper/templates/sequel_migration'
|
9
|
-
require 'flipper/spec/shared_adapter_specs'
|
10
8
|
|
11
9
|
RSpec.describe Flipper::Adapters::Sequel do
|
12
10
|
subject do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipper-sequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: flipper
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.23.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.23.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sequel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,7 +51,6 @@ executables: []
|
|
51
51
|
extensions: []
|
52
52
|
extra_rdoc_files: []
|
53
53
|
files:
|
54
|
-
- docs/sequel/README.md
|
55
54
|
- examples/sequel/basic.rb
|
56
55
|
- examples/sequel/internals.rb
|
57
56
|
- flipper-sequel.gemspec
|
@@ -81,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
80
|
- !ruby/object:Gem::Version
|
82
81
|
version: '0'
|
83
82
|
requirements: []
|
84
|
-
rubygems_version: 3.
|
83
|
+
rubygems_version: 3.1.2
|
85
84
|
signing_key:
|
86
85
|
specification_version: 4
|
87
86
|
summary: Sequel adapter for Flipper
|
data/docs/sequel/README.md
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
# Flipper Sequel
|
2
|
-
|
3
|
-
A [Sequel](https://github.com/jeremyevans/sequel) adapter for [Flipper](https://github.com/jnunemaker/flipper).
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'flipper-sequel'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself with:
|
16
|
-
|
17
|
-
$ gem install flipper-sequel
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
For your convenience, a sequel migration is provided to create the necessary tables. This migration will create two database tables - flipper_features and flipper_gates.
|
22
|
-
|
23
|
-
```ruby
|
24
|
-
require 'generators/flipper/templates/sequel_migration'
|
25
|
-
CreateFlipperTablesSequel.new(Sequel::Model.db).up
|
26
|
-
```
|
27
|
-
|
28
|
-
Once you have created and executed the migration, you can use the sequel adapter by simply requiring it:
|
29
|
-
|
30
|
-
```ruby
|
31
|
-
require 'flipper-sequel`
|
32
|
-
```
|
33
|
-
|
34
|
-
**If you need to customize the adapter**, you can add this to an initializer:
|
35
|
-
|
36
|
-
```ruby
|
37
|
-
Flipper.configure do |config|
|
38
|
-
config.adapter { Flipper::Adapters::Sequel.new }
|
39
|
-
end
|
40
|
-
```
|
41
|
-
|
42
|
-
## Internals
|
43
|
-
|
44
|
-
Each feature is stored as a row in a features table. Each gate is stored as a row in a gates table, related to the feature by the feature's key.
|
45
|
-
|
46
|
-
```ruby
|
47
|
-
require 'flipper/adapters/sequel'
|
48
|
-
adapter = Flipper::Adapters::Sequel.new
|
49
|
-
flipper = Flipper.new(adapter)
|
50
|
-
|
51
|
-
# Register a few groups.
|
52
|
-
Flipper.register(:admins) { |thing| thing.admin? }
|
53
|
-
Flipper.register(:early_access) { |thing| thing.early_access? }
|
54
|
-
|
55
|
-
# Create a user class that has flipper_id instance method.
|
56
|
-
User = Struct.new(:flipper_id)
|
57
|
-
|
58
|
-
flipper[:stats].enable
|
59
|
-
flipper[:stats].enable_group :admins
|
60
|
-
flipper[:stats].enable_group :early_access
|
61
|
-
flipper[:stats].enable_actor User.new('25')
|
62
|
-
flipper[:stats].enable_actor User.new('90')
|
63
|
-
flipper[:stats].enable_actor User.new('180')
|
64
|
-
flipper[:stats].enable_percentage_of_time 15
|
65
|
-
flipper[:stats].enable_percentage_of_actors 45
|
66
|
-
|
67
|
-
flipper[:search].enable
|
68
|
-
|
69
|
-
puts 'all rows in features table'
|
70
|
-
pp Flipper::Adapters::Sequel::Feature.all
|
71
|
-
#[#<Flipper::Adapters::Sequel::Feature @values={:key=>"stats", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>,
|
72
|
-
# #<Flipper::Adapters::Sequel::Feature @values={:key=>"search", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>]
|
73
|
-
puts
|
74
|
-
|
75
|
-
puts 'all rows in gates table'
|
76
|
-
pp Flipper::Adapters::Sequel::Gate.all
|
77
|
-
# [#<Flipper::Adapters::Sequel::Gate @values={:feature_key=>"stats", :key=>"boolean", :value=>"true", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>,
|
78
|
-
# #<Flipper::Adapters::Sequel::Gate @values={:feature_key=>"stats", :key=>"groups", :value=>"admins", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>,
|
79
|
-
# #<Flipper::Adapters::Sequel::Gate @values={:feature_key=>"stats", :key=>"groups", :value=>"early_access", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>,
|
80
|
-
# #<Flipper::Adapters::Sequel::Gate @values={:feature_key=>"stats", :key=>"actors", :value=>"25", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>,
|
81
|
-
# #<Flipper::Adapters::Sequel::Gate @values={:feature_key=>"stats", :key=>"actors", :value=>"90", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>,
|
82
|
-
# #<Flipper::Adapters::Sequel::Gate @values={:feature_key=>"stats", :key=>"actors", :value=>"180", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>,
|
83
|
-
# #<Flipper::Adapters::Sequel::Gate @values={:feature_key=>"stats", :key=>"percentage_of_time", :value=>"15", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>,
|
84
|
-
# #<Flipper::Adapters::Sequel::Gate @values={:feature_key=>"stats", :key=>"percentage_of_actors", :value=>"45", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>,
|
85
|
-
# #<Flipper::Adapters::Sequel::Gate @values={:feature_key=>"search", :key=>"boolean", :value=>"true", :created_at=>2016-11-19 13:57:48 -0500, :updated_at=>2016-11-19 13:57:48 -0500}>]
|
86
|
-
puts
|
87
|
-
|
88
|
-
puts 'flipper get of feature'
|
89
|
-
pp adapter.get(flipper[:stats])
|
90
|
-
# {:boolean=>"true",
|
91
|
-
# :groups=>#<Set: {"admins", "early_access"}>,
|
92
|
-
# :actors=>#<Set: {"180", "25", "90"}>,
|
93
|
-
# :percentage_of_actors=>"45",
|
94
|
-
# :percentage_of_time=>"15"}
|
95
|
-
```
|
96
|
-
|
97
|
-
## Contributing
|
98
|
-
|
99
|
-
1. Fork it
|
100
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
101
|
-
3. Commit your changes (`git commit -am 'Added some feature'`)
|
102
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
103
|
-
5. Create new Pull Request
|