flipper-mongo 0.20.4 → 0.21.0.rc1
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 +14 -5
- data/examples/mongo/basic.rb +1 -5
- data/examples/mongo/internals.rb +1 -5
- data/lib/flipper-mongo.rb +13 -0
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/adapters/mongo_spec.rb +14 -1
- data/test/adapters/mongo_test.rb +3 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a403acdc5b237a26d9b056342aab9bc4dc769f0637f0590fc92f4048cc61b31
|
4
|
+
data.tar.gz: c52237113cbaca943efa097e0f842149a4a5d1b9d69714ed6a0ed4f61655397d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e489144b55ab01ee1907a4cf10e8077f9124c2692dc45db5abd51f53e809ec45dc04fc88773ff2cf16e673950aef84bb78e89af6a138a234549744680848f22f
|
7
|
+
data.tar.gz: 2d0ac58887709a23d91e83043a1599b03855b85089e5f399d8749b9dbd0b0c2fb69362b6e825c660591e67ed5b4f5bb75ab0efdb8b5f904b02e7bb99a158ad09
|
data/docs/mongo/README.md
CHANGED
@@ -18,12 +18,21 @@ Or install it yourself with:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
+
In most cases, all you need to do is require the adapter. You must set the `MONGO_URL` or `FLIPPER_MONGO_URL` environment vairable to specify which Mongo database to connect to.
|
22
|
+
|
21
23
|
```ruby
|
22
|
-
require 'flipper
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
require 'flipper-mongo`
|
25
|
+
```
|
26
|
+
|
27
|
+
**If you need to customize the adapter**, you can add this to an initializer:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
Flipper.configure do |config|
|
31
|
+
config.default do
|
32
|
+
collection = Mongo::Client.new(ENV["MONGO_URL"])["flipper"]
|
33
|
+
Flipper.new(Flipper::Adapters::Mongo.new(collection))
|
34
|
+
end
|
35
|
+
end
|
27
36
|
```
|
28
37
|
|
29
38
|
## Internals
|
data/examples/mongo/basic.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'bundler/setup'
|
2
2
|
require 'logger'
|
3
3
|
|
4
|
-
root_path = Pathname(__FILE__).dirname.join('..').expand_path
|
5
|
-
lib_path = root_path.join('lib')
|
6
|
-
$:.unshift(lib_path)
|
7
|
-
|
8
4
|
require 'flipper/adapters/mongo'
|
9
5
|
Mongo::Logger.logger.level = Logger::INFO
|
10
6
|
collection = Mongo::Client.new(["127.0.0.1:#{ENV["MONGODB_PORT"] || 27017}"], :database => 'testing')['flipper']
|
data/examples/mongo/internals.rb
CHANGED
@@ -1,11 +1,7 @@
|
|
1
|
+
require 'bundler/setup'
|
1
2
|
require 'pp'
|
2
|
-
require 'pathname'
|
3
3
|
require 'logger'
|
4
4
|
|
5
|
-
root_path = Pathname(__FILE__).dirname.join('..').expand_path
|
6
|
-
lib_path = root_path.join('lib')
|
7
|
-
$:.unshift(lib_path)
|
8
|
-
|
9
5
|
require 'flipper/adapters/mongo'
|
10
6
|
Mongo::Logger.logger.level = Logger::INFO
|
11
7
|
collection = Mongo::Client.new(["127.0.0.1:#{ENV["MONGODB_PORT"] || 27017}"], :database => 'testing')['flipper']
|
data/lib/flipper-mongo.rb
CHANGED
@@ -1 +1,14 @@
|
|
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
|
data/lib/flipper/version.rb
CHANGED
@@ -11,17 +11,30 @@ RSpec.describe Flipper::Adapters::Mongo do
|
|
11
11
|
let(:port) { ENV['MONGODB_PORT'] || 27017 }
|
12
12
|
|
13
13
|
let(:client) do
|
14
|
-
|
14
|
+
logger = Logger.new('/dev/null')
|
15
|
+
Mongo::Client.new(["#{host}:#{port}"], server_selection_timeout: 0.01, database: 'testing', logger: logger)
|
15
16
|
end
|
16
17
|
let(:collection) { client['testing'] }
|
17
18
|
|
18
19
|
before do
|
19
20
|
begin
|
20
21
|
collection.drop
|
22
|
+
rescue Mongo::Error::NoServerAvailable
|
23
|
+
ENV['CI'] ? raise : skip('Mongo not available')
|
21
24
|
rescue Mongo::Error::OperationFailure
|
22
25
|
end
|
23
26
|
collection.create
|
24
27
|
end
|
25
28
|
|
26
29
|
it_should_behave_like 'a flipper adapter'
|
30
|
+
|
31
|
+
it 'configures itself on load' do
|
32
|
+
Flipper.configuration = nil
|
33
|
+
Flipper.instance = nil
|
34
|
+
|
35
|
+
load 'flipper-mongo.rb'
|
36
|
+
|
37
|
+
ENV["MONGO_URL"] ||= "mongodb://127.0.0.1:27017/testing"
|
38
|
+
expect(Flipper.adapter.adapter).to be_a(Flipper::Adapters::Mongo)
|
39
|
+
end
|
27
40
|
end
|
data/test/adapters/mongo_test.rb
CHANGED
@@ -9,13 +9,15 @@ class MongoTest < MiniTest::Test
|
|
9
9
|
port = '27017'
|
10
10
|
logger = Logger.new('/dev/null')
|
11
11
|
client = Mongo::Client.new(["#{host}:#{port}"],
|
12
|
-
server_selection_timeout:
|
12
|
+
server_selection_timeout: 0.01,
|
13
13
|
database: 'testing',
|
14
14
|
logger: logger)
|
15
15
|
collection = client['testing']
|
16
16
|
begin
|
17
17
|
collection.drop
|
18
18
|
collection.create
|
19
|
+
rescue Mongo::Error::NoServerAvailable
|
20
|
+
ENV['CI'] ? raise : skip('Mongo not available')
|
19
21
|
rescue Mongo::Error::OperationFailure
|
20
22
|
end
|
21
23
|
@adapter = Flipper::Adapters::Mongo.new(collection)
|
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.
|
4
|
+
version: 0.21.0.rc1
|
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-
|
11
|
+
date: 2021-05-01 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.21.0.rc1
|
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.21.0.rc1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mongo
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,9 +70,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
70
|
version: '0'
|
71
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.3.1
|
76
76
|
requirements: []
|
77
77
|
rubygems_version: 3.0.3
|
78
78
|
signing_key:
|