flipper-mongo 0.21.0.rc1 → 0.21.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/mongo/README.md +2 -2
- data/examples/mongo/basic.rb +5 -8
- data/examples/mongo/internals.rb +12 -15
- data/lib/flipper-mongo.rb +0 -13
- data/lib/flipper/adapters/mongo.rb +16 -0
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/adapters/mongo_spec.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 791c1620bf28b30186573a6505fe599e3f94c07811f3e12975b8ec5915048dcf
|
4
|
+
data.tar.gz: 0c3e4f3b56112fd42b1a3155c1a2344ef83542c7d1c5eef85a6c4b683ff07e0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ea34731290fb49e34bb5069a041f13beb7f633b36c5460c6fe442c409b3062a35286c1a0c4bd25d9ea96cd008959ef7f09dcdbbc931d4ef8df70cfa49cd417b
|
7
|
+
data.tar.gz: f6e829603c37184602c4e49d0c1ce22315f3ec0d66837d80d472df5be4fde9cf4b4ea4332834fa66a27c9d20b5a3a60d4c793ebf179d7c389abe33b86e68e773
|
data/docs/mongo/README.md
CHANGED
@@ -28,9 +28,9 @@ require 'flipper-mongo`
|
|
28
28
|
|
29
29
|
```ruby
|
30
30
|
Flipper.configure do |config|
|
31
|
-
config.
|
31
|
+
config.adapter do
|
32
32
|
collection = Mongo::Client.new(ENV["MONGO_URL"])["flipper"]
|
33
|
-
Flipper
|
33
|
+
Flipper::Adapters::Mongo.new(collection)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
```
|
data/examples/mongo/basic.rb
CHANGED
@@ -1,23 +1,20 @@
|
|
1
1
|
require 'bundler/setup'
|
2
2
|
require 'logger'
|
3
3
|
|
4
|
+
ENV["FLIPPER_MONGO_URL"] ||= "mongodb://127.0.0.1:#{ENV["MONGODB_PORT"] || 27017}"
|
4
5
|
require 'flipper/adapters/mongo'
|
5
|
-
Mongo::Logger.logger.level = Logger::INFO
|
6
|
-
collection = Mongo::Client.new(["127.0.0.1:#{ENV["MONGODB_PORT"] || 27017}"], :database => 'testing')['flipper']
|
7
|
-
adapter = Flipper::Adapters::Mongo.new(collection)
|
8
|
-
flipper = Flipper.new(adapter)
|
9
6
|
|
10
|
-
|
7
|
+
Flipper[:stats].enable
|
11
8
|
|
12
|
-
if
|
9
|
+
if Flipper[:stats].enabled?
|
13
10
|
puts "Enabled!"
|
14
11
|
else
|
15
12
|
puts "Disabled!"
|
16
13
|
end
|
17
14
|
|
18
|
-
|
15
|
+
Flipper[:stats].disable
|
19
16
|
|
20
|
-
if
|
17
|
+
if Flipper[:stats].enabled?
|
21
18
|
puts "Enabled!"
|
22
19
|
else
|
23
20
|
puts "Disabled!"
|
data/examples/mongo/internals.rb
CHANGED
@@ -2,11 +2,8 @@ require 'bundler/setup'
|
|
2
2
|
require 'pp'
|
3
3
|
require 'logger'
|
4
4
|
|
5
|
+
ENV["FLIPPER_MONGO_URL"] ||= "mongodb://127.0.0.1:#{ENV["MONGODB_PORT"] || 27017}"
|
5
6
|
require 'flipper/adapters/mongo'
|
6
|
-
Mongo::Logger.logger.level = Logger::INFO
|
7
|
-
collection = Mongo::Client.new(["127.0.0.1:#{ENV["MONGODB_PORT"] || 27017}"], :database => 'testing')['flipper']
|
8
|
-
adapter = Flipper::Adapters::Mongo.new(collection)
|
9
|
-
flipper = Flipper.new(adapter)
|
10
7
|
|
11
8
|
# Register a few groups.
|
12
9
|
Flipper.register(:admins) { |thing| thing.admin? }
|
@@ -15,19 +12,19 @@ Flipper.register(:early_access) { |thing| thing.early_access? }
|
|
15
12
|
# Create a user class that has flipper_id instance method.
|
16
13
|
User = Struct.new(:flipper_id)
|
17
14
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
Flipper[:stats].enable
|
16
|
+
Flipper[:stats].enable_group :admins
|
17
|
+
Flipper[:stats].enable_group :early_access
|
18
|
+
Flipper[:stats].enable_actor User.new('25')
|
19
|
+
Flipper[:stats].enable_actor User.new('90')
|
20
|
+
Flipper[:stats].enable_actor User.new('180')
|
21
|
+
Flipper[:stats].enable_percentage_of_time 15
|
22
|
+
Flipper[:stats].enable_percentage_of_actors 45
|
26
23
|
|
27
|
-
|
24
|
+
Flipper[:search].enable
|
28
25
|
|
29
26
|
puts 'all docs in collection'
|
30
|
-
pp collection.find.to_a
|
27
|
+
pp Flipper.adapter.adapter.collection.find.to_a
|
31
28
|
# all docs in collection
|
32
29
|
# [{"_id"=>"stats",
|
33
30
|
# "actors"=>["25", "90", "180"],
|
@@ -40,7 +37,7 @@ pp collection.find.to_a
|
|
40
37
|
puts
|
41
38
|
|
42
39
|
puts 'flipper get of feature'
|
43
|
-
pp adapter.get(
|
40
|
+
pp Flipper.adapter.get(Flipper[:stats])
|
44
41
|
# flipper get of feature
|
45
42
|
# {:boolean=>"true",
|
46
43
|
# :groups=>#<Set: {"admins", "early_access"}>,
|
data/lib/flipper-mongo.rb
CHANGED
@@ -1,14 +1 @@
|
|
1
1
|
require 'flipper/adapters/mongo'
|
2
|
-
|
3
|
-
Flipper.configure do |config|
|
4
|
-
config.default do
|
5
|
-
url = ENV["FLIPPER_MONGO_URL"] || ENV["MONGO_URL"]
|
6
|
-
collection = ENV["FLIPPER_MONGO_COLLECTION"] || "flipper"
|
7
|
-
|
8
|
-
unless url
|
9
|
-
raise ArgumentError, "The MONGO_URL environment variable must be set. For example: mongodb://127.0.0.1:27017/flipper"
|
10
|
-
end
|
11
|
-
|
12
|
-
Flipper.new(Flipper::Adapters::Mongo.new(Mongo::Client.new(url)[collection]))
|
13
|
-
end
|
14
|
-
end
|
@@ -13,6 +13,9 @@ module Flipper
|
|
13
13
|
# Public: The name of the adapter.
|
14
14
|
attr_reader :name
|
15
15
|
|
16
|
+
# Public: The name of the collection storing the feature data.
|
17
|
+
attr_reader :collection
|
18
|
+
|
16
19
|
def initialize(collection)
|
17
20
|
@collection = collection
|
18
21
|
@name = :mongo
|
@@ -173,3 +176,16 @@ module Flipper
|
|
173
176
|
end
|
174
177
|
end
|
175
178
|
end
|
179
|
+
|
180
|
+
Flipper.configure do |config|
|
181
|
+
config.adapter do
|
182
|
+
url = ENV["FLIPPER_MONGO_URL"] || ENV["MONGO_URL"]
|
183
|
+
collection = ENV["FLIPPER_MONGO_COLLECTION"] || "flipper"
|
184
|
+
|
185
|
+
unless url
|
186
|
+
raise ArgumentError, "The MONGO_URL environment variable must be set. For example: mongodb://127.0.0.1:27017/flipper"
|
187
|
+
end
|
188
|
+
|
189
|
+
Flipper::Adapters::Mongo.new(Mongo::Client.new(url)[collection])
|
190
|
+
end
|
191
|
+
end
|
data/lib/flipper/version.rb
CHANGED
@@ -32,7 +32,7 @@ RSpec.describe Flipper::Adapters::Mongo do
|
|
32
32
|
Flipper.configuration = nil
|
33
33
|
Flipper.instance = nil
|
34
34
|
|
35
|
-
load 'flipper
|
35
|
+
load 'flipper/adapters/mongo.rb'
|
36
36
|
|
37
37
|
ENV["MONGO_URL"] ||= "mongodb://127.0.0.1:27017/testing"
|
38
38
|
expect(Flipper.adapter.adapter).to be_a(Flipper::Adapters::Mongo)
|
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: 0.21.0.
|
4
|
+
version: 0.21.0.rc2
|
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-05-
|
11
|
+
date: 2021-05-08 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.21.0.
|
19
|
+
version: 0.21.0.rc2
|
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.21.0.
|
26
|
+
version: 0.21.0.rc2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mongo
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|