flipper-sequel 0.22.0 → 0.23.1

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: 5ed17230bf73572a1eb0d6e9d517e0a01a459f73a50ec0058f6977ad92c1e78a
4
- data.tar.gz: 0d372c287dbc20dc98558544165bc1b96c9cc553ace717be21157d991372a005
3
+ metadata.gz: 3084e4b1bd6b6d17895b97d1f00b106cec8c1ec89c5de102f1de6fa6895b7399
4
+ data.tar.gz: fe4b78beb82fc50a8f653e4b24c99b4b894712f0acadfb486fdc24b715a60067
5
5
  SHA512:
6
- metadata.gz: 4d4eb797141a7130d78f74b6b6daa2958f5216205f94da3660e65ae4c6d51aa20f6cbbcf46b65f20aa4c7349a9cf59938423ce1b116a4c24b17c8e43a768cdd9
7
- data.tar.gz: a94221243cdbf03ccf2f6d4bf3ec550921e6f15e06700005972f392ae25ff466876ecb5f9b079b9941bea70d64a1d53a5d22073f6a5be7118327ac12027ba08d
6
+ metadata.gz: ed31507597d48276d43721456b0c795ecbb2364db2497e4808199636c9df9d9f7a25d6fca19c62190734d6028cdb0e5b5ad3c486c47998dac794c862fa227502
7
+ data.tar.gz: 104164cf1b264504bd2ad5c1797538410aee1319fe19755f3f29b19da5a7f299d450d510b6668fff6a8f274bd1d8a3b1bc93f7d8bb3baedff425d003838922f1
@@ -179,7 +179,11 @@ module Flipper
179
179
  @gate_class.db.transaction do
180
180
  clear(feature) if clear_feature
181
181
  @gate_class.where(args).delete
182
- @gate_class.create(gate_attrs(feature, gate, thing))
182
+
183
+ begin
184
+ @gate_class.create(gate_attrs(feature, gate, thing))
185
+ rescue ::Sequel::UniqueConstraintViolation
186
+ end
183
187
  end
184
188
  end
185
189
 
@@ -1,3 +1,3 @@
1
1
  module Flipper
2
- VERSION = '0.22.0'.freeze
2
+ VERSION = '0.23.1'.freeze
3
3
  end
@@ -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.22.0
4
+ version: 0.23.1
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-07-08 00:00:00.000000000 Z
11
+ date: 2022-01-19 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.22.0
19
+ version: 0.23.1
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.22.0
26
+ version: 0.23.1
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.0.3
83
+ rubygems_version: 3.1.2
85
84
  signing_key:
86
85
  specification_version: 4
87
86
  summary: Sequel adapter for Flipper
@@ -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