flipper-mongo 0.6.0 → 0.7.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/{README.md → docs/mongo/README.md} +12 -11
- data/examples/{basic.rb → mongo/basic.rb} +2 -1
- data/examples/{internals.rb → mongo/internals.rb} +11 -10
- data/flipper-mongo.gemspec +16 -12
- data/lib/flipper/adapters/mongo.rb +6 -5
- data/lib/flipper/version.rb +3 -0
- data/spec/flipper/adapters/mongo_spec.rb +23 -0
- metadata +25 -44
- data/.gitignore +0 -18
- data/.travis.yml +0 -10
- data/Gemfile +0 -14
- data/Guardfile +0 -13
- data/LICENSE +0 -22
- data/Rakefile +0 -7
- data/lib/flipper/adapters/mongo/version.rb +0 -7
- data/spec/helper.rb +0 -17
- data/spec/mongo_spec.rb +0 -15
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f465468fd0c1372940c01805c0c839e65eb613c6
|
4
|
+
data.tar.gz: f62867edb69a1587da05653e91b4a70f2a6b61b1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 76640e9b9c64e6b8f49f47ef2998f92176bd78a3cbd65a09e2fdc05354cff34b6e6ac4c20812955be3c9cd4d6464cb73f9fdf0f9d60c6b61f413c77b2027ba4c
|
7
|
+
data.tar.gz: 8935520b6b9fa4bf44c9e3a09dbb88c1221e8065adbd648cc6079824f62b01d8aa15aa74e879b532e945f26c7167385d4a08f3ba2ae4c4f286f28e34e7033b2d
|
@@ -20,7 +20,7 @@ Or install it yourself with:
|
|
20
20
|
|
21
21
|
```ruby
|
22
22
|
require 'flipper/adapters/mongo'
|
23
|
-
collection = Mongo::
|
23
|
+
collection = Mongo::Client.new(["127.0.0.1:27017"], database: 'testing')['flipper']
|
24
24
|
adapter = Flipper::Adapters::Mongo.new(collection)
|
25
25
|
flipper = Flipper.new(adapter)
|
26
26
|
# profit...
|
@@ -32,7 +32,7 @@ Each feature is stored in a document, which means getting a feature is single qu
|
|
32
32
|
|
33
33
|
```ruby
|
34
34
|
require 'flipper/adapters/mongo'
|
35
|
-
collection = Mongo::
|
35
|
+
collection = Mongo::Client.new(["127.0.0.1:27017"], database: 'testing')['flipper']
|
36
36
|
adapter = Flipper::Adapters::Mongo.new(collection)
|
37
37
|
flipper = Flipper.new(adapter)
|
38
38
|
|
@@ -44,13 +44,13 @@ Flipper.register(:early_access) { |thing| thing.early_access? }
|
|
44
44
|
User = Struct.new(:flipper_id)
|
45
45
|
|
46
46
|
flipper[:stats].enable
|
47
|
-
flipper[:stats].
|
48
|
-
flipper[:stats].
|
49
|
-
flipper[:stats].
|
50
|
-
flipper[:stats].
|
51
|
-
flipper[:stats].
|
52
|
-
flipper[:stats].
|
53
|
-
flipper[:stats].
|
47
|
+
flipper[:stats].enable_group :admins
|
48
|
+
flipper[:stats].enable_group :early_access
|
49
|
+
flipper[:stats].enable_actor User.new('25')
|
50
|
+
flipper[:stats].enable_actor User.new('90')
|
51
|
+
flipper[:stats].enable_actor User.new('180')
|
52
|
+
flipper[:stats].enable_percentage_of_time 15
|
53
|
+
flipper[:stats].enable_percentage_of_actors 45
|
54
54
|
|
55
55
|
flipper[:search].enable
|
56
56
|
|
@@ -62,9 +62,10 @@ pp collection.find.to_a
|
|
62
62
|
# "boolean"=>"true",
|
63
63
|
# "groups"=>["admins", "early_access"],
|
64
64
|
# "percentage_of_actors"=>"45",
|
65
|
-
# "
|
65
|
+
# "percentage_of_time"=>"15"},
|
66
66
|
# {"_id"=>"flipper_features", "features"=>["stats", "search"]},
|
67
67
|
# {"_id"=>"search", "boolean"=>"true"}]
|
68
|
+
puts
|
68
69
|
|
69
70
|
puts 'flipper get of feature'
|
70
71
|
pp adapter.get(flipper[:stats])
|
@@ -73,7 +74,7 @@ pp adapter.get(flipper[:stats])
|
|
73
74
|
# :groups=>#<Set: {"admins", "early_access"}>,
|
74
75
|
# :actors=>#<Set: {"25", "90", "180"}>,
|
75
76
|
# :percentage_of_actors=>"45",
|
76
|
-
# :
|
77
|
+
# :percentage_of_time=>"15"}
|
77
78
|
```
|
78
79
|
|
79
80
|
## Contributing
|
@@ -6,7 +6,8 @@ lib_path = root_path.join('lib')
|
|
6
6
|
$:.unshift(lib_path)
|
7
7
|
|
8
8
|
require 'flipper/adapters/mongo'
|
9
|
-
|
9
|
+
Mongo::Logger.logger.level = Logger::INFO
|
10
|
+
collection = Mongo::Client.new(["127.0.0.1:#{ENV["BOXEN_MONGODB_PORT"] || 27017}"], :database => 'testing')['flipper']
|
10
11
|
adapter = Flipper::Adapters::Mongo.new(collection)
|
11
12
|
flipper = Flipper.new(adapter)
|
12
13
|
|
@@ -7,7 +7,8 @@ lib_path = root_path.join('lib')
|
|
7
7
|
$:.unshift(lib_path)
|
8
8
|
|
9
9
|
require 'flipper/adapters/mongo'
|
10
|
-
|
10
|
+
Mongo::Logger.logger.level = Logger::INFO
|
11
|
+
collection = Mongo::Client.new(["127.0.0.1:#{ENV["BOXEN_MONGODB_PORT"] || 27017}"], :database => 'testing')['flipper']
|
11
12
|
adapter = Flipper::Adapters::Mongo.new(collection)
|
12
13
|
flipper = Flipper.new(adapter)
|
13
14
|
|
@@ -19,13 +20,13 @@ Flipper.register(:early_access) { |thing| thing.early_access? }
|
|
19
20
|
User = Struct.new(:flipper_id)
|
20
21
|
|
21
22
|
flipper[:stats].enable
|
22
|
-
flipper[:stats].
|
23
|
-
flipper[:stats].
|
24
|
-
flipper[:stats].
|
25
|
-
flipper[:stats].
|
26
|
-
flipper[:stats].
|
27
|
-
flipper[:stats].
|
28
|
-
flipper[:stats].
|
23
|
+
flipper[:stats].enable_group :admins
|
24
|
+
flipper[:stats].enable_group :early_access
|
25
|
+
flipper[:stats].enable_actor User.new('25')
|
26
|
+
flipper[:stats].enable_actor User.new('90')
|
27
|
+
flipper[:stats].enable_actor User.new('180')
|
28
|
+
flipper[:stats].enable_percentage_of_time 15
|
29
|
+
flipper[:stats].enable_percentage_of_actors 45
|
29
30
|
|
30
31
|
flipper[:search].enable
|
31
32
|
|
@@ -37,7 +38,7 @@ pp collection.find.to_a
|
|
37
38
|
# "boolean"=>"true",
|
38
39
|
# "groups"=>["admins", "early_access"],
|
39
40
|
# "percentage_of_actors"=>"45",
|
40
|
-
# "
|
41
|
+
# "percentage_of_time"=>"15"},
|
41
42
|
# {"_id"=>"flipper_features", "features"=>["stats", "search"]},
|
42
43
|
# {"_id"=>"search", "boolean"=>"true"}]
|
43
44
|
puts
|
@@ -49,4 +50,4 @@ pp adapter.get(flipper[:stats])
|
|
49
50
|
# :groups=>#<Set: {"admins", "early_access"}>,
|
50
51
|
# :actors=>#<Set: {"25", "90", "180"}>,
|
51
52
|
# :percentage_of_actors=>"45",
|
52
|
-
# :
|
53
|
+
# :percentage_of_time=>"15"}
|
data/flipper-mongo.gemspec
CHANGED
@@ -1,20 +1,24 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('../lib/flipper/
|
2
|
+
require File.expand_path('../lib/flipper/version', __FILE__)
|
3
|
+
|
4
|
+
flipper_mongo_files = lambda { |file|
|
5
|
+
file =~ /mongo/
|
6
|
+
}
|
3
7
|
|
4
8
|
Gem::Specification.new do |gem|
|
5
|
-
gem.name = "flipper-mongo"
|
6
|
-
gem.version = Flipper::Adapters::Mongo::VERSION
|
7
9
|
gem.authors = ["John Nunemaker"]
|
8
10
|
gem.email = ["nunemaker@gmail.com"]
|
9
|
-
gem.
|
10
|
-
gem.
|
11
|
-
gem.
|
12
|
-
gem.
|
11
|
+
gem.summary = "Mongo adapter for Flipper"
|
12
|
+
gem.description = "Mongo adapter for Flipper"
|
13
|
+
gem.license = "MIT"
|
14
|
+
gem.homepage = "https://github.com/jnunemaker/flipper"
|
13
15
|
|
14
|
-
gem.files = `git ls-files`.split(
|
15
|
-
gem.
|
16
|
-
gem.
|
16
|
+
gem.files = `git ls-files`.split("\n").select(&flipper_mongo_files) + ["lib/flipper/version.rb"]
|
17
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n").select(&flipper_mongo_files)
|
18
|
+
gem.name = "flipper-mongo"
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
gem.version = Flipper::VERSION
|
17
21
|
|
18
|
-
gem.add_dependency 'flipper',
|
19
|
-
gem.add_dependency 'mongo', '~>
|
22
|
+
gem.add_dependency 'flipper', "~> #{Flipper::VERSION}"
|
23
|
+
gem.add_dependency 'mongo', '~> 2.0'
|
20
24
|
end
|
@@ -25,13 +25,13 @@ module Flipper
|
|
25
25
|
|
26
26
|
# Public: Adds a feature to the set of known features.
|
27
27
|
def add(feature)
|
28
|
-
update FeaturesKey, '$addToSet' => {'features' => feature.
|
28
|
+
update FeaturesKey, '$addToSet' => {'features' => feature.key}
|
29
29
|
true
|
30
30
|
end
|
31
31
|
|
32
32
|
# Public: Removes a feature from the set of known features.
|
33
33
|
def remove(feature)
|
34
|
-
update FeaturesKey, '$pull' => {'features' => feature.
|
34
|
+
update FeaturesKey, '$pull' => {'features' => feature.key}
|
35
35
|
clear feature
|
36
36
|
true
|
37
37
|
end
|
@@ -39,6 +39,7 @@ module Flipper
|
|
39
39
|
# Public: Clears all the gate values for a feature.
|
40
40
|
def clear(feature)
|
41
41
|
delete feature.key
|
42
|
+
true
|
42
43
|
end
|
43
44
|
|
44
45
|
# Public: Gets the values for all gates for a given feature.
|
@@ -115,18 +116,18 @@ module Flipper
|
|
115
116
|
|
116
117
|
# Private
|
117
118
|
def find(key)
|
118
|
-
@collection.
|
119
|
+
@collection.find(criteria(key)).limit(1).first || {}
|
119
120
|
end
|
120
121
|
|
121
122
|
# Private
|
122
123
|
def update(key, updates)
|
123
124
|
options = {:upsert => true}
|
124
|
-
@collection.
|
125
|
+
@collection.find(criteria(key)).update_one(updates, options)
|
125
126
|
end
|
126
127
|
|
127
128
|
# Private
|
128
129
|
def delete(key)
|
129
|
-
@collection.
|
130
|
+
@collection.find(criteria(key)).delete_one
|
130
131
|
end
|
131
132
|
|
132
133
|
# Private
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'flipper/adapters/mongo'
|
3
|
+
require 'flipper/spec/shared_adapter_specs'
|
4
|
+
|
5
|
+
Mongo::Logger.logger.level = Logger::INFO
|
6
|
+
|
7
|
+
describe Flipper::Adapters::Mongo do
|
8
|
+
let(:collection) {
|
9
|
+
Mongo::Client.new(["127.0.0.1:#{ENV["BOXEN_MONGODB_PORT"] || 27017}"], :database => 'testing')['testing']
|
10
|
+
}
|
11
|
+
|
12
|
+
subject { described_class.new(collection) }
|
13
|
+
|
14
|
+
before do
|
15
|
+
begin
|
16
|
+
collection.drop
|
17
|
+
rescue Mongo::Error::OperationFailure
|
18
|
+
end
|
19
|
+
collection.create
|
20
|
+
end
|
21
|
+
|
22
|
+
it_should_behave_like 'a flipper adapter'
|
23
|
+
end
|
metadata
CHANGED
@@ -1,48 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipper-mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.7.0.beta4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- John Nunemaker
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-04-28 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: flipper
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
19
|
+
version: 0.7.0.beta4
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
26
|
+
version: 0.7.0.beta4
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: mongo
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
33
|
+
version: '2.0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version: '
|
40
|
+
version: '2.0'
|
46
41
|
description: Mongo adapter for Flipper
|
47
42
|
email:
|
48
43
|
- nunemaker@gmail.com
|
@@ -50,51 +45,37 @@ executables: []
|
|
50
45
|
extensions: []
|
51
46
|
extra_rdoc_files: []
|
52
47
|
files:
|
53
|
-
- .
|
54
|
-
- .
|
55
|
-
-
|
56
|
-
- Guardfile
|
57
|
-
- LICENSE
|
58
|
-
- README.md
|
59
|
-
- Rakefile
|
60
|
-
- examples/basic.rb
|
61
|
-
- examples/internals.rb
|
48
|
+
- docs/mongo/README.md
|
49
|
+
- examples/mongo/basic.rb
|
50
|
+
- examples/mongo/internals.rb
|
62
51
|
- flipper-mongo.gemspec
|
63
52
|
- lib/flipper-mongo.rb
|
64
53
|
- lib/flipper/adapters/mongo.rb
|
65
|
-
- lib/flipper/
|
66
|
-
- spec/
|
67
|
-
|
68
|
-
|
69
|
-
|
54
|
+
- lib/flipper/version.rb
|
55
|
+
- spec/flipper/adapters/mongo_spec.rb
|
56
|
+
homepage: https://github.com/jnunemaker/flipper
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
70
60
|
post_install_message:
|
71
61
|
rdoc_options: []
|
72
62
|
require_paths:
|
73
63
|
- lib
|
74
64
|
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
65
|
requirements:
|
77
|
-
- -
|
66
|
+
- - ">="
|
78
67
|
- !ruby/object:Gem::Version
|
79
68
|
version: '0'
|
80
|
-
segments:
|
81
|
-
- 0
|
82
|
-
hash: 2022872060542852797
|
83
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
-
none: false
|
85
70
|
requirements:
|
86
|
-
- -
|
71
|
+
- - ">"
|
87
72
|
- !ruby/object:Gem::Version
|
88
|
-
version:
|
89
|
-
segments:
|
90
|
-
- 0
|
91
|
-
hash: 2022872060542852797
|
73
|
+
version: 1.3.1
|
92
74
|
requirements: []
|
93
75
|
rubyforge_project:
|
94
|
-
rubygems_version:
|
76
|
+
rubygems_version: 2.2.2
|
95
77
|
signing_key:
|
96
|
-
specification_version:
|
78
|
+
specification_version: 4
|
97
79
|
summary: Mongo adapter for Flipper
|
98
80
|
test_files:
|
99
|
-
- spec/
|
100
|
-
- spec/mongo_spec.rb
|
81
|
+
- spec/flipper/adapters/mongo_spec.rb
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Guardfile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# A sample Guardfile
|
2
|
-
# More info at https://github.com/guard/guard#readme
|
3
|
-
|
4
|
-
guard 'bundler' do
|
5
|
-
watch('Gemfile')
|
6
|
-
watch(/^.+\.gemspec/)
|
7
|
-
end
|
8
|
-
|
9
|
-
guard 'rspec' do
|
10
|
-
watch(%r{^spec/.+_spec\.rb$}) { "spec" }
|
11
|
-
watch(%r{^lib/(.+)\.rb$}) { "spec" }
|
12
|
-
watch('spec/helper.rb') { "spec" }
|
13
|
-
end
|
data/LICENSE
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2012 John Nunemaker
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
DELETED
data/spec/helper.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
$:.unshift(File.expand_path('../../lib', __FILE__))
|
2
|
-
|
3
|
-
require 'bundler'
|
4
|
-
Bundler.setup :default
|
5
|
-
require 'flipper-mongo'
|
6
|
-
|
7
|
-
RSpec.configure do |config|
|
8
|
-
config.filter_run :focused => true
|
9
|
-
config.alias_example_to :fit, :focused => true
|
10
|
-
config.alias_example_to :xit, :pending => true
|
11
|
-
config.run_all_when_everything_filtered = true
|
12
|
-
config.fail_fast = true
|
13
|
-
|
14
|
-
config.backtrace_clean_patterns = [
|
15
|
-
/rspec-(core|expectations)/,
|
16
|
-
]
|
17
|
-
end
|
data/spec/mongo_spec.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
require 'flipper/adapters/mongo'
|
3
|
-
require 'flipper/spec/shared_adapter_specs'
|
4
|
-
|
5
|
-
describe Flipper::Adapters::Mongo do
|
6
|
-
let(:collection) { Mongo::MongoClient.new.db('testing')['testing'] }
|
7
|
-
|
8
|
-
subject { described_class.new(collection) }
|
9
|
-
|
10
|
-
before do
|
11
|
-
collection.remove
|
12
|
-
end
|
13
|
-
|
14
|
-
it_should_behave_like 'a flipper adapter'
|
15
|
-
end
|