flipper 0.11.0.beta4 → 0.11.0.beta5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/docs/Gates.md +2 -2
- data/docs/api/README.md +2 -2
- data/docs/http/README.md +1 -0
- data/examples/group_dynamic_lookup.rb +2 -2
- data/examples/percentage_of_actors_group.rb +1 -1
- data/lib/flipper/adapters/http.rb +2 -1
- data/lib/flipper/adapters/http/client.rb +2 -0
- data/lib/flipper/middleware/memoizer.rb +2 -1
- data/lib/flipper/middleware/setup_env.rb +3 -2
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/adapters/http_spec.rb +10 -0
- data/spec/support/spec_helpers.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d6d3fb5a81f8e36791a48a6475dfdbfc56ba65e
|
4
|
+
data.tar.gz: 82e678db59d539f2230fdc585511e6116495f682
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d986d350d0f87bfb6e36db9ffd347fb69e79bbae6656df0266b2b58186b8d794032fc3e08f9f3572de33dc32c09e33d1b3429ca5c787531c1259cd6f90f0b8b5
|
7
|
+
data.tar.gz: 9defcfe3b411db0252793d35a96cffb1979a8d42b12f533a3ed15f37e7e0fa2afe25262eb3353ea4a58be0d82d6d927e242a6b1325fe184fda3ad7865fdc35af
|
data/docs/Gates.md
CHANGED
@@ -92,13 +92,13 @@ The one exception to this rule is if you have globally unique `flipper_ids`, suc
|
|
92
92
|
```ruby
|
93
93
|
class User
|
94
94
|
def flipper_id
|
95
|
-
"User
|
95
|
+
"User;#{id}"
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
99
|
class Group
|
100
100
|
def flipper_id
|
101
|
-
"Group
|
101
|
+
"Group;#{id}"
|
102
102
|
end
|
103
103
|
end
|
104
104
|
```
|
data/docs/api/README.md
CHANGED
@@ -502,7 +502,7 @@ Successful disabling of the group will return a 200 HTTP status and the feature
|
|
502
502
|
**Request**
|
503
503
|
|
504
504
|
```
|
505
|
-
curl -X POST -d "flipper_id=User
|
505
|
+
curl -X POST -d "flipper_id=User;1" http://example.com/flipper/api/features/reports/actors
|
506
506
|
```
|
507
507
|
|
508
508
|
**Response**
|
@@ -557,7 +557,7 @@ Successful enabling of the actor will return a 200 HTTP status and the feature o
|
|
557
557
|
**Request**
|
558
558
|
|
559
559
|
```
|
560
|
-
curl -X DELETE -d "flipper_id=User
|
560
|
+
curl -X DELETE -d "flipper_id=User;1" http://example.com/flipper/api/features/reports/actors
|
561
561
|
```
|
562
562
|
|
563
563
|
**Response**
|
data/docs/http/README.md
CHANGED
@@ -32,3 +32,4 @@ flipper = Flipper.new(adapter)
|
|
32
32
|
* basic_auth_password: Basic Auth password.
|
33
33
|
* read_timeout: [number in seconds](https://docs.ruby-lang.org/en/2.3.0/Net/HTTP.html#attribute-i-read_timeout).
|
34
34
|
* open_timeout: [number in seconds](https://docs.ruby-lang.org/en/2.3.0/Net/HTTP.html#attribute-i-open_timeout).
|
35
|
+
* debug_output: Set an output stream for debugging (e.g. `debug_output: $stderr`). The output stream is passed on to [Net::HTTP#set_debug_output](https://ruby-doc.org/stdlib-2.4.1/libdoc/net/http/rdoc/Net/HTTP.html#method-i-set_debug_output).
|
@@ -9,7 +9,7 @@ stats = flipper[:stats]
|
|
9
9
|
|
10
10
|
# Register group
|
11
11
|
Flipper.register(:enabled_team_member) do |actor, context|
|
12
|
-
combos = context.actors_value.map { |flipper_id| flipper_id.split("
|
12
|
+
combos = context.actors_value.map { |flipper_id| flipper_id.split(";", 2) }
|
13
13
|
team_names = combos.select { |class_name, id| class_name == "Team" }.map { |class_name, id| id }
|
14
14
|
teams = team_names.map { |name| Team.find(name) }
|
15
15
|
teams.any? { |team| team.member?(actor) }
|
@@ -24,7 +24,7 @@ class User
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def flipper_id
|
27
|
-
"User
|
27
|
+
"User;#{@id}"
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -18,7 +18,8 @@ module Flipper
|
|
18
18
|
basic_auth_username: options[:basic_auth_username],
|
19
19
|
basic_auth_password: options[:basic_auth_password],
|
20
20
|
read_timeout: options[:read_timeout],
|
21
|
-
open_timeout: options[:open_timeout]
|
21
|
+
open_timeout: options[:open_timeout],
|
22
|
+
debug_output: options[:debug_output])
|
22
23
|
@name = :http
|
23
24
|
end
|
24
25
|
|
@@ -21,6 +21,7 @@ module Flipper
|
|
21
21
|
@basic_auth_password = options[:basic_auth_password]
|
22
22
|
@read_timeout = options[:read_timeout]
|
23
23
|
@open_timeout = options[:open_timeout]
|
24
|
+
@debug_output = options[:debug_output]
|
24
25
|
end
|
25
26
|
|
26
27
|
def get(path)
|
@@ -56,6 +57,7 @@ module Flipper
|
|
56
57
|
http = Net::HTTP.new(uri.host, uri.port)
|
57
58
|
http.read_timeout = @read_timeout if @read_timeout
|
58
59
|
http.open_timeout = @open_timeout if @open_timeout
|
60
|
+
http.set_debug_output(@debug_output) if @debug_output
|
59
61
|
|
60
62
|
if uri.scheme == HTTPS_SCHEME
|
61
63
|
http.use_ssl = true
|
@@ -29,6 +29,7 @@ module Flipper
|
|
29
29
|
|
30
30
|
@app = app
|
31
31
|
@opts = opts
|
32
|
+
@env_key = opts.fetch(:env_key, 'flipper')
|
32
33
|
end
|
33
34
|
|
34
35
|
def call(env)
|
@@ -48,7 +49,7 @@ module Flipper
|
|
48
49
|
end
|
49
50
|
|
50
51
|
def memoized_call(env)
|
51
|
-
flipper = env.fetch(
|
52
|
+
flipper = env.fetch(@env_key)
|
52
53
|
original = flipper.adapter.memoizing?
|
53
54
|
flipper.adapter.memoize = true
|
54
55
|
|
@@ -19,8 +19,9 @@ module Flipper
|
|
19
19
|
# # using with a block that yields a flipper instance
|
20
20
|
# use Flipper::Middleware::SetEnv, lambda { Flipper.new(...) }
|
21
21
|
#
|
22
|
-
def initialize(app, flipper_or_block)
|
22
|
+
def initialize(app, flipper_or_block, options = {})
|
23
23
|
@app = app
|
24
|
+
@env_key = options.fetch(:env_key, 'flipper')
|
24
25
|
|
25
26
|
if flipper_or_block.respond_to?(:call)
|
26
27
|
@flipper_block = flipper_or_block
|
@@ -30,7 +31,7 @@ module Flipper
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def call(env)
|
33
|
-
env[
|
34
|
+
env[@env_key] ||= flipper
|
34
35
|
@app.call(env)
|
35
36
|
end
|
36
37
|
|
data/lib/flipper/version.rb
CHANGED
@@ -119,6 +119,7 @@ RSpec.describe Flipper::Adapters::Http do
|
|
119
119
|
end
|
120
120
|
|
121
121
|
describe 'configuration' do
|
122
|
+
let(:debug_output) { object_double($stderr) }
|
122
123
|
let(:options) do
|
123
124
|
{
|
124
125
|
uri: URI('http://app.com/mount-point'),
|
@@ -127,6 +128,7 @@ RSpec.describe Flipper::Adapters::Http do
|
|
127
128
|
basic_auth_password: 'password',
|
128
129
|
read_timeout: 100,
|
129
130
|
open_timeout: 40,
|
131
|
+
debug_output: debug_output,
|
130
132
|
}
|
131
133
|
end
|
132
134
|
subject { described_class.new(options) }
|
@@ -151,6 +153,14 @@ RSpec.describe Flipper::Adapters::Http do
|
|
151
153
|
.with(basic_auth: %w(username password))
|
152
154
|
).to have_been_made.once
|
153
155
|
end
|
156
|
+
|
157
|
+
it 'allows client to set debug output' do
|
158
|
+
user_agent = Net::HTTP.new("app.com")
|
159
|
+
allow(Net::HTTP).to receive(:new).and_return(user_agent)
|
160
|
+
|
161
|
+
expect(user_agent).to receive(:set_debug_output).with(debug_output)
|
162
|
+
subject.get(feature)
|
163
|
+
end
|
154
164
|
end
|
155
165
|
|
156
166
|
def fixture_file(name)
|
@@ -8,14 +8,14 @@ module SpecHelpers
|
|
8
8
|
base.let(:app) { build_app(flipper) }
|
9
9
|
end
|
10
10
|
|
11
|
-
def build_app(flipper)
|
12
|
-
Flipper::UI.app(flipper) do |builder|
|
11
|
+
def build_app(flipper, options = {})
|
12
|
+
Flipper::UI.app(flipper, options) do |builder|
|
13
13
|
builder.use Rack::Session::Cookie, secret: 'test'
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def build_api(flipper)
|
18
|
-
Flipper::Api.app(flipper)
|
17
|
+
def build_api(flipper, options = {})
|
18
|
+
Flipper::Api.app(flipper, options)
|
19
19
|
end
|
20
20
|
|
21
21
|
def build_flipper(adapter = build_memory_adapter)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.0.
|
4
|
+
version: 0.11.0.beta5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Feature flipper is the act of enabling/disabling features in your application,
|
14
14
|
ideally without re-deploying or changing anything in your code base. Flipper makes
|