flipper-api 0.24.0 → 0.24.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/flipper/api/v1/actions/feature.rb +2 -1
- data/lib/flipper/api/v1/actions/features.rb +2 -1
- data/lib/flipper/api/v1/decorators/feature.rb +11 -8
- data/lib/flipper/api.rb +3 -2
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/api/v1/decorators/feature_spec.rb +27 -0
- data/spec/flipper/api_spec.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 498a3561809183d8cfdc15aa77c221e80578e220de9b97365df9645ad61e47dc
|
4
|
+
data.tar.gz: f4755ea4711c5f4220203d67eaa0518e6f2365a069dc9302cfaac2c48ed5b927
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcc285c9297786310f91250503b37e521accb20c67cdab671326824bcad5ea870fc0e89b6828e57adfb9a7189be592908cb70e20aed014d4d2862fa5e8e31962
|
7
|
+
data.tar.gz: 4721e66c96afb93ace4361cc4955b731ab246d7d37a2432ef7d392a8ac738202950f60ca9dd25e3cd1b14d2ffd4ea5f44524ac2e1877e3000d0957d3ee9d7cdc
|
@@ -12,8 +12,9 @@ module Flipper
|
|
12
12
|
|
13
13
|
def get
|
14
14
|
return json_error_response(:feature_not_found) unless feature_exists?(feature_name)
|
15
|
+
exclude_gates = params['exclude_gates']&.downcase == "true"
|
15
16
|
feature = Decorators::Feature.new(flipper[feature_name])
|
16
|
-
json_response(feature.as_json)
|
17
|
+
json_response(feature.as_json(exclude_gates: exclude_gates))
|
17
18
|
end
|
18
19
|
|
19
20
|
def delete
|
@@ -10,6 +10,7 @@ module Flipper
|
|
10
10
|
|
11
11
|
def get
|
12
12
|
keys = params['keys']
|
13
|
+
exclude_gates = params['exclude_gates']&.downcase == "true"
|
13
14
|
features = if keys
|
14
15
|
names = keys.split(',')
|
15
16
|
if names.empty?
|
@@ -26,7 +27,7 @@ module Flipper
|
|
26
27
|
end
|
27
28
|
|
28
29
|
decorated_features = features.map do |feature|
|
29
|
-
Decorators::Feature.new(feature).as_json
|
30
|
+
Decorators::Feature.new(feature).as_json(exclude_gates: exclude_gates)
|
30
31
|
end
|
31
32
|
|
32
33
|
json_response(features: decorated_features)
|
@@ -10,17 +10,20 @@ module Flipper
|
|
10
10
|
alias_method :feature, :__getobj__
|
11
11
|
|
12
12
|
# Public: Returns instance as hash that is ready to be json dumped.
|
13
|
-
def as_json
|
14
|
-
|
15
|
-
gates_json = gates.map do |gate|
|
16
|
-
Decorators::Gate.new(gate, gate_values[gate.key]).as_json
|
17
|
-
end
|
18
|
-
|
19
|
-
{
|
13
|
+
def as_json(exclude_gates: false)
|
14
|
+
result = {
|
20
15
|
'key' => key,
|
21
16
|
'state' => state.to_s,
|
22
|
-
'gates' => gates_json,
|
23
17
|
}
|
18
|
+
|
19
|
+
unless exclude_gates
|
20
|
+
gate_values = feature.adapter.get(self)
|
21
|
+
result['gates'] = gates.map do |gate|
|
22
|
+
Decorators::Gate.new(gate, gate_values[gate.key]).as_json
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
result
|
24
27
|
end
|
25
28
|
end
|
26
29
|
end
|
data/lib/flipper/api.rb
CHANGED
@@ -17,8 +17,9 @@ module Flipper
|
|
17
17
|
builder.use Flipper::Api::Middleware, env_key: env_key
|
18
18
|
builder.run app
|
19
19
|
klass = self
|
20
|
-
|
21
|
-
|
20
|
+
app = builder.to_app
|
21
|
+
app.define_singleton_method(:inspect) { klass.inspect } # pretty rake routes output
|
22
|
+
app
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
data/lib/flipper/version.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
RSpec.describe Flipper::Api::V1::Decorators::Feature do
|
2
|
+
describe "#as_json" do
|
3
|
+
context "with exclude_gates set to true" do
|
4
|
+
subject { described_class.new(flipper[:my_feature]).as_json(exclude_gates: true) }
|
5
|
+
|
6
|
+
it "returns json WITHOUT feature gate data" do
|
7
|
+
expect(subject.keys).to_not include("gates")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context "with exclude_gates set to false" do
|
12
|
+
subject { described_class.new(flipper[:my_feature]).as_json(exclude_gates: false) }
|
13
|
+
|
14
|
+
it "returns json WITH feature gate data" do
|
15
|
+
expect(subject.keys).to include("gates")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "without exclude_gates set" do
|
20
|
+
subject { described_class.new(flipper[:my_feature]).as_json }
|
21
|
+
|
22
|
+
it "returns json WITH feature gate data" do
|
23
|
+
expect(subject.keys).to include("gates")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/spec/flipper/api_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipper-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.24.
|
4
|
+
version: 0.24.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.24.
|
39
|
+
version: 0.24.1
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.24.
|
46
|
+
version: 0.24.1
|
47
47
|
description:
|
48
48
|
email:
|
49
49
|
- nunemaker@gmail.com
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- spec/flipper/api/v1/actions/groups_gate_spec.rb
|
85
85
|
- spec/flipper/api/v1/actions/percentage_of_actors_gate_spec.rb
|
86
86
|
- spec/flipper/api/v1/actions/percentage_of_time_gate_spec.rb
|
87
|
+
- spec/flipper/api/v1/decorators/feature_spec.rb
|
87
88
|
- spec/flipper/api_spec.rb
|
88
89
|
homepage: https://github.com/jnunemaker/flipper
|
89
90
|
licenses:
|
@@ -121,4 +122,5 @@ test_files:
|
|
121
122
|
- spec/flipper/api/v1/actions/groups_gate_spec.rb
|
122
123
|
- spec/flipper/api/v1/actions/percentage_of_actors_gate_spec.rb
|
123
124
|
- spec/flipper/api/v1/actions/percentage_of_time_gate_spec.rb
|
125
|
+
- spec/flipper/api/v1/decorators/feature_spec.rb
|
124
126
|
- spec/flipper/api_spec.rb
|