flipper-sequel 0.10.2 → 0.11.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/sequel/README.md +1 -1
- data/flipper-sequel.gemspec +11 -11
- data/lib/flipper/adapters/sequel.rb +22 -17
- data/lib/flipper/version.rb +1 -1
- data/lib/generators/flipper/templates/sequel_migration.rb +4 -5
- data/spec/flipper/adapters/sequel_spec.rb +1 -1
- data/test/adapters/sequel_test.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97719a3b02001fa2a41c5d2df3c1a41529946581
|
4
|
+
data.tar.gz: 82a6ab85e1d35f13b2844b1c15f455c42e974c26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e7f2d381bb3bf56d64bd64dad06a6deb4c76574cf9d0a2fac4291f94bfe0686fab41633f2b2fd6819d2a45f41822e7433cab7df7c49d6ad0c4757fe8f32cc12
|
7
|
+
data.tar.gz: 4cdd6c49c10ea4c2b6b6091eca8e78b212b664a028ad73b123ee25ddc7cf0ed00f709a45052d31cb4a7880808ee3bc2258d6db7a55ec9c8d3557ccfa6b1c93d7
|
data/docs/sequel/README.md
CHANGED
data/flipper-sequel.gemspec
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
require File.expand_path('../lib/flipper/version', __FILE__)
|
3
3
|
|
4
|
-
flipper_sequel_files =
|
4
|
+
flipper_sequel_files = ->(file) { file =~ /sequel/ }
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
|
-
gem.authors = [
|
8
|
-
gem.email = [
|
9
|
-
gem.summary =
|
10
|
-
gem.description =
|
11
|
-
gem.license =
|
12
|
-
gem.homepage =
|
7
|
+
gem.authors = ['John Nunemaker']
|
8
|
+
gem.email = ['nunemaker@gmail.com']
|
9
|
+
gem.summary = 'Sequel adapter for Flipper'
|
10
|
+
gem.description = 'Sequel adapter for Flipper'
|
11
|
+
gem.license = 'MIT'
|
12
|
+
gem.homepage = 'https://github.com/jnunemaker/flipper'
|
13
13
|
|
14
14
|
extra_files = [
|
15
|
-
|
15
|
+
'lib/flipper/version.rb',
|
16
16
|
]
|
17
17
|
gem.files = `git ls-files`.split("\n").select(&flipper_sequel_files) + extra_files
|
18
18
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_sequel_files)
|
19
|
-
gem.name =
|
20
|
-
gem.require_paths = [
|
19
|
+
gem.name = 'flipper-sequel'
|
20
|
+
gem.require_paths = ['lib']
|
21
21
|
gem.version = Flipper::VERSION
|
22
22
|
|
23
23
|
gem.add_dependency 'flipper', "~> #{Flipper::VERSION}"
|
24
|
-
gem.add_dependency 'sequel',
|
24
|
+
gem.add_dependency 'sequel', '>= 4.0.0', '< 5'
|
25
25
|
end
|
@@ -9,11 +9,15 @@ module Flipper
|
|
9
9
|
|
10
10
|
# Private: Do not use outside of this adapter.
|
11
11
|
class Feature < ::Sequel::Model(:flipper_features)
|
12
|
+
unrestrict_primary_key
|
13
|
+
|
12
14
|
plugin :timestamps, update_on_create: true
|
13
15
|
end
|
14
16
|
|
15
17
|
# Private: Do not use outside of this adapter.
|
16
18
|
class Gate < ::Sequel::Model(:flipper_gates)
|
19
|
+
unrestrict_primary_key
|
20
|
+
|
17
21
|
plugin :timestamps, update_on_create: true
|
18
22
|
end
|
19
23
|
|
@@ -77,7 +81,7 @@ module Flipper
|
|
77
81
|
|
78
82
|
def get_multi(features)
|
79
83
|
db_gates = @gate_class.where(feature_key: features.map(&:key)).to_a
|
80
|
-
grouped_db_gates = db_gates.group_by
|
84
|
+
grouped_db_gates = db_gates.group_by(&:feature_key)
|
81
85
|
result = {}
|
82
86
|
features.each do |feature|
|
83
87
|
result[feature.key] = result_for_feature(feature, grouped_db_gates[feature.key])
|
@@ -98,7 +102,7 @@ module Flipper
|
|
98
102
|
@gate_class.db.transaction do
|
99
103
|
args = {
|
100
104
|
feature_key: feature.key,
|
101
|
-
key: gate.key.to_s
|
105
|
+
key: gate.key.to_s,
|
102
106
|
}
|
103
107
|
@gate_class.where(args).delete
|
104
108
|
|
@@ -128,7 +132,7 @@ module Flipper
|
|
128
132
|
@gate_class.db.transaction do
|
129
133
|
args = {
|
130
134
|
feature_key: feature.key.to_s,
|
131
|
-
key: gate.key.to_s
|
135
|
+
key: gate.key.to_s,
|
132
136
|
}
|
133
137
|
@gate_class.where(args).delete
|
134
138
|
|
@@ -154,27 +158,28 @@ module Flipper
|
|
154
158
|
{
|
155
159
|
feature_key: feature.key.to_s,
|
156
160
|
key: gate.key.to_s,
|
157
|
-
value: thing.value.to_s
|
161
|
+
value: thing.value.to_s,
|
158
162
|
}
|
159
163
|
end
|
160
164
|
|
161
165
|
def result_for_feature(feature, db_gates)
|
162
166
|
db_gates ||= []
|
163
167
|
feature.gates.each_with_object({}) do |gate, result|
|
164
|
-
result[gate.key] =
|
165
|
-
|
166
|
-
|
167
|
-
db_gate.
|
168
|
+
result[gate.key] =
|
169
|
+
case gate.data_type
|
170
|
+
when :boolean
|
171
|
+
if db_gate = db_gates.detect { |db_gate| db_gate.key == gate.key.to_s }
|
172
|
+
db_gate.value
|
173
|
+
end
|
174
|
+
when :integer
|
175
|
+
if db_gate = db_gates.detect { |db_gate| db_gate.key == gate.key.to_s }
|
176
|
+
db_gate.value
|
177
|
+
end
|
178
|
+
when :set
|
179
|
+
db_gates.select { |db_gate| db_gate.key == gate.key.to_s }.map(&:value).to_set
|
180
|
+
else
|
181
|
+
unsupported_data_type gate.data_type
|
168
182
|
end
|
169
|
-
when :integer
|
170
|
-
if db_gate = db_gates.detect { |db_gate| db_gate.key == gate.key.to_s }
|
171
|
-
db_gate.value
|
172
|
-
end
|
173
|
-
when :set
|
174
|
-
db_gates.select { |db_gate| db_gate.key == gate.key.to_s }.map(&:value).to_set
|
175
|
-
else
|
176
|
-
unsupported_data_type gate.data_type
|
177
|
-
end
|
178
183
|
end
|
179
184
|
end
|
180
185
|
end
|
data/lib/flipper/version.rb
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
class CreateFlipperTablesSequel < Sequel::Migration
|
2
2
|
def up
|
3
|
-
create_table :flipper_features do |
|
4
|
-
String :key, null: false
|
3
|
+
create_table :flipper_features do |_t|
|
4
|
+
String :key, primary_key: true, null: false
|
5
5
|
DateTime :created_at, null: false
|
6
6
|
DateTime :updated_at, null: false
|
7
7
|
end
|
8
|
-
add_index :flipper_features, :key, unique: true
|
9
8
|
|
10
|
-
create_table :flipper_gates do |
|
9
|
+
create_table :flipper_gates do |_t|
|
11
10
|
String :feature_key, null: false
|
12
11
|
String :key, null: false
|
13
12
|
String :value
|
14
13
|
DateTime :created_at, null: false
|
15
14
|
DateTime :updated_at, null: false
|
15
|
+
primary_key [:feature_key, :key, :value]
|
16
16
|
end
|
17
|
-
add_index :flipper_gates, [:feature_key, :key, :value], unique: true
|
18
17
|
end
|
19
18
|
|
20
19
|
def down
|
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.11.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-02 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.11.0.beta1
|
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.11.0.beta1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sequel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,12 +76,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: '0'
|
77
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- - "
|
79
|
+
- - ">"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
81
|
+
version: 1.3.1
|
82
82
|
requirements: []
|
83
83
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.
|
84
|
+
rubygems_version: 2.5.2
|
85
85
|
signing_key:
|
86
86
|
specification_version: 4
|
87
87
|
summary: Sequel adapter for Flipper
|