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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a403acdc5b237a26d9b056342aab9bc4dc769f0637f0590fc92f4048cc61b31
4
- data.tar.gz: c52237113cbaca943efa097e0f842149a4a5d1b9d69714ed6a0ed4f61655397d
3
+ metadata.gz: 791c1620bf28b30186573a6505fe599e3f94c07811f3e12975b8ec5915048dcf
4
+ data.tar.gz: 0c3e4f3b56112fd42b1a3155c1a2344ef83542c7d1c5eef85a6c4b683ff07e0f
5
5
  SHA512:
6
- metadata.gz: e489144b55ab01ee1907a4cf10e8077f9124c2692dc45db5abd51f53e809ec45dc04fc88773ff2cf16e673950aef84bb78e89af6a138a234549744680848f22f
7
- data.tar.gz: 2d0ac58887709a23d91e83043a1599b03855b85089e5f399d8749b9dbd0b0c2fb69362b6e825c660591e67ed5b4f5bb75ab0efdb8b5f904b02e7bb99a158ad09
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.default do
31
+ config.adapter do
32
32
  collection = Mongo::Client.new(ENV["MONGO_URL"])["flipper"]
33
- Flipper.new(Flipper::Adapters::Mongo.new(collection))
33
+ Flipper::Adapters::Mongo.new(collection)
34
34
  end
35
35
  end
36
36
  ```
@@ -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
- flipper[:stats].enable
7
+ Flipper[:stats].enable
11
8
 
12
- if flipper[:stats].enabled?
9
+ if Flipper[:stats].enabled?
13
10
  puts "Enabled!"
14
11
  else
15
12
  puts "Disabled!"
16
13
  end
17
14
 
18
- flipper[:stats].disable
15
+ Flipper[:stats].disable
19
16
 
20
- if flipper[:stats].enabled?
17
+ if Flipper[:stats].enabled?
21
18
  puts "Enabled!"
22
19
  else
23
20
  puts "Disabled!"
@@ -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
- flipper[:stats].enable
19
- flipper[:stats].enable_group :admins
20
- flipper[:stats].enable_group :early_access
21
- flipper[:stats].enable_actor User.new('25')
22
- flipper[:stats].enable_actor User.new('90')
23
- flipper[:stats].enable_actor User.new('180')
24
- flipper[:stats].enable_percentage_of_time 15
25
- flipper[:stats].enable_percentage_of_actors 45
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
- flipper[:search].enable
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(flipper[:stats])
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
@@ -1,3 +1,3 @@
1
1
  module Flipper
2
- VERSION = '0.21.0.rc1'.freeze
2
+ VERSION = '0.21.0.rc2'.freeze
3
3
  end
@@ -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-mongo.rb'
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.rc1
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-01 00:00:00.000000000 Z
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.rc1
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.rc1
26
+ version: 0.21.0.rc2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mongo
29
29
  requirement: !ruby/object:Gem::Requirement