flipper-mongo 0.28.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/flipper-mongo.gemspec +3 -3
- data/lib/flipper/adapters/mongo.rb +23 -14
- data/lib/flipper/version.rb +11 -1
- data/spec/flipper/adapters/mongo_spec.rb +3 -2
- metadata +13 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b12087eef71d7aef815da329b2989efb2779b0eeb3f9a128dca152bea0c5112e
|
4
|
+
data.tar.gz: 2f78bb6f3949583e20cc4ffb5a2b2f40cbb1db8a665038a14d7013c3e797fce5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c48a16bb81774574bdeaffb51f3e6ab08c0b93ae17db9dc7d181b2f159b53ca320bdebe208059eac4daf7148c0980e975559f81f12e2cf5ac12609d254e2161
|
7
|
+
data.tar.gz: 561bdf4904e5c30a5b3c59a1c079f2932d94b3f612dfe090adbed484ccde0acb760dd59b02f9f421f256f6a129da0119cdec6f2935e7d7111d73c3f7ded319ca
|
data/flipper-mongo.gemspec
CHANGED
@@ -8,10 +8,10 @@ end
|
|
8
8
|
|
9
9
|
Gem::Specification.new do |gem|
|
10
10
|
gem.authors = ['John Nunemaker']
|
11
|
-
gem.email =
|
12
|
-
gem.summary = 'Mongo adapter for Flipper'
|
11
|
+
gem.email = 'support@flippercloud.io'
|
12
|
+
gem.summary = 'Mongo feature flag adapter for Flipper'
|
13
13
|
gem.license = 'MIT'
|
14
|
-
gem.homepage = 'https://
|
14
|
+
gem.homepage = 'https://www.flippercloud.io/docs/adapters/mongo'
|
15
15
|
|
16
16
|
gem.files = `git ls-files`.split("\n").select(&flipper_mongo_files) + ['lib/flipper/version.rb']
|
17
17
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_mongo_files)
|
@@ -7,18 +7,12 @@ module Flipper
|
|
7
7
|
class Mongo
|
8
8
|
include ::Flipper::Adapter
|
9
9
|
|
10
|
-
# Private: The key that stores the set of known features.
|
11
|
-
FeaturesKey = :flipper_features
|
12
|
-
|
13
|
-
# Public: The name of the adapter.
|
14
|
-
attr_reader :name
|
15
|
-
|
16
10
|
# Public: The name of the collection storing the feature data.
|
17
11
|
attr_reader :collection
|
18
12
|
|
19
13
|
def initialize(collection)
|
20
14
|
@collection = collection
|
21
|
-
@
|
15
|
+
@features_key = :flipper_features
|
22
16
|
end
|
23
17
|
|
24
18
|
# Public: The set of known features.
|
@@ -28,13 +22,13 @@ module Flipper
|
|
28
22
|
|
29
23
|
# Public: Adds a feature to the set of known features.
|
30
24
|
def add(feature)
|
31
|
-
update
|
25
|
+
update @features_key, '$addToSet' => { 'features' => feature.key }
|
32
26
|
true
|
33
27
|
end
|
34
28
|
|
35
29
|
# Public: Removes a feature from the set of known features.
|
36
30
|
def remove(feature)
|
37
|
-
update
|
31
|
+
update @features_key, '$pull' => { 'features' => feature.key }
|
38
32
|
clear feature
|
39
33
|
true
|
40
34
|
end
|
@@ -65,8 +59,8 @@ module Flipper
|
|
65
59
|
# Public: Enables a gate for a given thing.
|
66
60
|
#
|
67
61
|
# feature - The Flipper::Feature for the gate.
|
68
|
-
# gate - The Flipper::Gate to
|
69
|
-
# thing - The Flipper::Type being
|
62
|
+
# gate - The Flipper::Gate to enable.
|
63
|
+
# thing - The Flipper::Type being enabled for the gate.
|
70
64
|
#
|
71
65
|
# Returns true.
|
72
66
|
def enable(feature, gate, thing)
|
@@ -84,6 +78,10 @@ module Flipper
|
|
84
78
|
update feature.key, '$addToSet' => {
|
85
79
|
gate.key.to_s => thing.value.to_s,
|
86
80
|
}
|
81
|
+
when :json
|
82
|
+
update feature.key, '$set' => {
|
83
|
+
gate.key.to_s => Typecast.to_json(thing.value),
|
84
|
+
}
|
87
85
|
else
|
88
86
|
unsupported_data_type gate.data_type
|
89
87
|
end
|
@@ -103,9 +101,17 @@ module Flipper
|
|
103
101
|
when :boolean
|
104
102
|
delete feature.key
|
105
103
|
when :integer
|
106
|
-
update feature.key, '$set' => {
|
104
|
+
update feature.key, '$set' => {
|
105
|
+
gate.key.to_s => thing.value.to_s,
|
106
|
+
}
|
107
107
|
when :set
|
108
|
-
update feature.key, '$pull' => {
|
108
|
+
update feature.key, '$pull' => {
|
109
|
+
gate.key.to_s => thing.value.to_s,
|
110
|
+
}
|
111
|
+
when :json
|
112
|
+
update feature.key, '$set' => {
|
113
|
+
gate.key.to_s => nil,
|
114
|
+
}
|
109
115
|
else
|
110
116
|
unsupported_data_type gate.data_type
|
111
117
|
end
|
@@ -116,7 +122,7 @@ module Flipper
|
|
116
122
|
private
|
117
123
|
|
118
124
|
def read_feature_keys
|
119
|
-
find(
|
125
|
+
find(@features_key).fetch('features') { Set.new }.to_set
|
120
126
|
end
|
121
127
|
|
122
128
|
def read_many_features(features)
|
@@ -167,6 +173,9 @@ module Flipper
|
|
167
173
|
doc[gate.key.to_s]
|
168
174
|
when :set
|
169
175
|
doc.fetch(gate.key.to_s) { Set.new }.to_set
|
176
|
+
when :json
|
177
|
+
value = doc[gate.key.to_s]
|
178
|
+
Typecast.from_json(value)
|
170
179
|
else
|
171
180
|
unsupported_data_type gate.data_type
|
172
181
|
end
|
data/lib/flipper/version.rb
CHANGED
@@ -1,3 +1,13 @@
|
|
1
1
|
module Flipper
|
2
|
-
VERSION = '
|
2
|
+
VERSION = '1.2.0'.freeze
|
3
|
+
|
4
|
+
REQUIRED_RUBY_VERSION = '2.6'.freeze
|
5
|
+
NEXT_REQUIRED_RUBY_VERSION = '3.0'.freeze
|
6
|
+
|
7
|
+
REQUIRED_RAILS_VERSION = '5.2'.freeze
|
8
|
+
NEXT_REQUIRED_RAILS_VERSION = '6.1.0'.freeze
|
9
|
+
|
10
|
+
def self.deprecated_ruby_version?
|
11
|
+
Gem::Version.new(RUBY_VERSION) < Gem::Version.new(NEXT_REQUIRED_RUBY_VERSION)
|
12
|
+
end
|
3
13
|
end
|
@@ -32,7 +32,8 @@ RSpec.describe Flipper::Adapters::Mongo do
|
|
32
32
|
|
33
33
|
load 'flipper/adapters/mongo.rb'
|
34
34
|
|
35
|
-
|
36
|
-
|
35
|
+
with_env "MONGO_URL" => ENV.fetch("MONGO_URL", "mongodb://127.0.0.1:27017/testing") do
|
36
|
+
expect(Flipper.adapter.adapter).to be_a(Flipper::Adapters::Mongo)
|
37
|
+
end
|
37
38
|
end
|
38
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipper-mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.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:
|
11
|
+
date: 2024-01-11 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:
|
19
|
+
version: 1.2.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:
|
26
|
+
version: 1.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mongo
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,8 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.0'
|
41
41
|
description:
|
42
|
-
email:
|
43
|
-
- nunemaker@gmail.com
|
42
|
+
email: support@flippercloud.io
|
44
43
|
executables: []
|
45
44
|
extensions: []
|
46
45
|
extra_rdoc_files: []
|
@@ -53,11 +52,15 @@ files:
|
|
53
52
|
- lib/flipper/version.rb
|
54
53
|
- spec/flipper/adapters/mongo_spec.rb
|
55
54
|
- test/adapters/mongo_test.rb
|
56
|
-
homepage: https://
|
55
|
+
homepage: https://www.flippercloud.io/docs/adapters/mongo
|
57
56
|
licenses:
|
58
57
|
- MIT
|
59
58
|
metadata:
|
60
|
-
|
59
|
+
documentation_uri: https://www.flippercloud.io/docs
|
60
|
+
homepage_uri: https://www.flippercloud.io
|
61
|
+
source_code_uri: https://github.com/flippercloud/flipper
|
62
|
+
bug_tracker_uri: https://github.com/flippercloud/flipper/issues
|
63
|
+
changelog_uri: https://github.com/flippercloud/flipper/releases/tag/v1.2.0
|
61
64
|
post_install_message:
|
62
65
|
rdoc_options: []
|
63
66
|
require_paths:
|
@@ -73,10 +76,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
76
|
- !ruby/object:Gem::Version
|
74
77
|
version: '0'
|
75
78
|
requirements: []
|
76
|
-
rubygems_version: 3.3
|
79
|
+
rubygems_version: 3.5.3
|
77
80
|
signing_key:
|
78
81
|
specification_version: 4
|
79
|
-
summary: Mongo adapter for Flipper
|
82
|
+
summary: Mongo feature flag adapter for Flipper
|
80
83
|
test_files:
|
81
84
|
- spec/flipper/adapters/mongo_spec.rb
|
82
85
|
- test/adapters/mongo_test.rb
|