featury 1.0.0.rc17 → 1.0.0.rc19
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/README.md +22 -7
- data/lib/featury/actions/action.rb +21 -2
- data/lib/featury/actions/collection.rb +24 -1
- data/lib/featury/actions/dsl.rb +2 -1
- data/lib/featury/info/dsl.rb +1 -0
- data/lib/featury/info/result.rb +30 -2
- data/lib/featury/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90d7f0c59fc6810d609fa806bb5fa60cda2894c66bacbfd8f6015c05f9d8d376
|
4
|
+
data.tar.gz: 21fbdbca92e6583fc9f02261c2de3344d1c91740b0dc72df6810c2102a9a907c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3909dee49e854c7c4b380f23a1f7fb70028a3c84c16d99bd1a1978f152d40684b28f5df2249cbd7c0627fb6b148b4f73a3967382e7914fe4186f683f26899d37
|
7
|
+
data.tar.gz: 513add3e16f4a5fabd4790ac161f3d5e6a2252c3580ec2f7be01d5219c5cfccfecce5cfe147a3b233b689facfe1469e553250c0315d82b48a41f6fb07ced2d1e
|
data/README.md
CHANGED
@@ -40,22 +40,26 @@ In such a scenario, the base class could potentially be structured as follows:
|
|
40
40
|
|
41
41
|
```ruby
|
42
42
|
class ApplicationFeature < Featury::Base
|
43
|
-
action :enabled? do |features:, **options|
|
43
|
+
action :enabled?, web: :enabled? do |features:, **options|
|
44
44
|
features.all? { |feature| Flipper.enabled?(feature, *options.values) }
|
45
45
|
end
|
46
46
|
|
47
|
-
action :disabled
|
47
|
+
action :disabled?, web: :regular do |features:, **options|
|
48
48
|
features.any? { |feature| !Flipper.enabled?(feature, *options.values) }
|
49
49
|
end
|
50
50
|
|
51
|
-
action :enable do |features:, **options|
|
51
|
+
action :enable, web: :enable do |features:, **options|
|
52
52
|
features.all? { |feature| Flipper.enable(feature, *options.values) }
|
53
53
|
end
|
54
54
|
|
55
|
-
action :disable do |features:, **options|
|
55
|
+
action :disable, web: :disable do |features:, **options|
|
56
56
|
features.all? { |feature| Flipper.disable(feature, *options.values) }
|
57
57
|
end
|
58
58
|
|
59
|
+
action :add do |features:, **options|
|
60
|
+
features.all? { |feature| Flipper.add(feature, *options.values) }
|
61
|
+
end
|
62
|
+
|
59
63
|
before do |action:, features:|
|
60
64
|
Slack::API::Notify.call!(action:, features:)
|
61
65
|
end
|
@@ -66,6 +70,16 @@ class ApplicationFeature < Featury::Base
|
|
66
70
|
end
|
67
71
|
```
|
68
72
|
|
73
|
+
#### About the `web:` key
|
74
|
+
|
75
|
+
The `web:` key in the action definition allows you to specify which method will be used for web interactions. This is useful for mapping internal action names to external endpoints or UI actions. For example:
|
76
|
+
|
77
|
+
- `enabled?` — the method that will be used in the web context to check the state of a feature flag;
|
78
|
+
- `enable` — the method that will be used in the web context to enable a feature flag;
|
79
|
+
- `disable` — the method that will be used in the web context to disable a feature flag.
|
80
|
+
|
81
|
+
This mapping helps you clearly separate internal logic from the interface exposed to web clients.
|
82
|
+
|
69
83
|
#### Features of your project
|
70
84
|
|
71
85
|
```ruby
|
@@ -154,9 +168,10 @@ info = User::OnboardingFeature.info
|
|
154
168
|
```
|
155
169
|
|
156
170
|
```ruby
|
157
|
-
info.
|
158
|
-
info.
|
159
|
-
info.
|
171
|
+
info.actions # Feature actions (all, web) of the current class.
|
172
|
+
info.features # Feature flags of the current class.
|
173
|
+
info.groups # Feature flag groups of the current class.
|
174
|
+
info.tree # Tree of feature flags from the current class.
|
160
175
|
```
|
161
176
|
|
162
177
|
## Contributing
|
@@ -3,12 +3,31 @@
|
|
3
3
|
module Featury
|
4
4
|
module Actions
|
5
5
|
class Action
|
6
|
-
attr_reader :name,
|
6
|
+
attr_reader :name,
|
7
|
+
:web,
|
8
|
+
:block
|
7
9
|
|
8
|
-
def initialize(name, block:)
|
10
|
+
def initialize(name, web:, block:)
|
9
11
|
@name = name
|
12
|
+
@web = web
|
10
13
|
@block = block
|
11
14
|
end
|
15
|
+
|
16
|
+
def web_enabled?
|
17
|
+
@web == :enabled?
|
18
|
+
end
|
19
|
+
|
20
|
+
def web_enable?
|
21
|
+
@web == :enable
|
22
|
+
end
|
23
|
+
|
24
|
+
def web_disable?
|
25
|
+
@web == :disable
|
26
|
+
end
|
27
|
+
|
28
|
+
def web_regular?
|
29
|
+
@web == :regular
|
30
|
+
end
|
12
31
|
end
|
13
32
|
end
|
14
33
|
end
|
@@ -4,16 +4,39 @@ module Featury
|
|
4
4
|
module Actions
|
5
5
|
class Collection
|
6
6
|
extend Forwardable
|
7
|
-
def_delegators :@collection, :<<, :each, :map, :merge, :find
|
7
|
+
def_delegators :@collection, :<<, :filter, :each, :map, :merge, :find
|
8
8
|
|
9
9
|
def initialize(collection = Set.new)
|
10
10
|
@collection = collection
|
11
11
|
end
|
12
12
|
|
13
|
+
def for_web
|
14
|
+
Collection.new(
|
15
|
+
filter do |action|
|
16
|
+
action.web_enabled? ||
|
17
|
+
action.web_enable? ||
|
18
|
+
action.web_disable? ||
|
19
|
+
action.web_regular?
|
20
|
+
end
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
13
24
|
def names
|
14
25
|
map(&:name)
|
15
26
|
end
|
16
27
|
|
28
|
+
def web_enabled
|
29
|
+
find(&:web_enabled?)
|
30
|
+
end
|
31
|
+
|
32
|
+
def web_enable
|
33
|
+
find(&:web_enable?)
|
34
|
+
end
|
35
|
+
|
36
|
+
def web_disable
|
37
|
+
find(&:web_disable?)
|
38
|
+
end
|
39
|
+
|
17
40
|
def find_by(name:)
|
18
41
|
find { |action| action.name == name }
|
19
42
|
end
|
data/lib/featury/actions/dsl.rb
CHANGED
data/lib/featury/info/dsl.rb
CHANGED
@@ -10,6 +10,7 @@ module Featury
|
|
10
10
|
module ClassMethods
|
11
11
|
def info
|
12
12
|
Featury::Info::Result.new(
|
13
|
+
actions: Featury::Info::Result::Actions.new(collection_of_actions),
|
13
14
|
features: collection_of_features.full_names,
|
14
15
|
groups: collection_of_groups.map(&:group),
|
15
16
|
tree: collection_of_features.full_names.concat(
|
data/lib/featury/info/result.rb
CHANGED
@@ -3,9 +3,37 @@
|
|
3
3
|
module Featury
|
4
4
|
module Info
|
5
5
|
class Result
|
6
|
-
|
6
|
+
class Actions
|
7
|
+
class Web
|
8
|
+
attr_reader :all,
|
9
|
+
:enabled,
|
10
|
+
:enable,
|
11
|
+
:disable
|
7
12
|
|
8
|
-
|
13
|
+
def initialize(collection_of_actions)
|
14
|
+
@all = collection_of_actions.names
|
15
|
+
@enabled = collection_of_actions.web_enabled.name
|
16
|
+
@enable = collection_of_actions.web_enable.name
|
17
|
+
@disable = collection_of_actions.web_disable.name
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader :all,
|
22
|
+
:web
|
23
|
+
|
24
|
+
def initialize(collection_of_actions)
|
25
|
+
@all = collection_of_actions.names
|
26
|
+
@web = Web.new(collection_of_actions.for_web)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
attr_reader :actions,
|
31
|
+
:features,
|
32
|
+
:groups,
|
33
|
+
:tree
|
34
|
+
|
35
|
+
def initialize(actions:, features:, groups:, tree:)
|
36
|
+
@actions = actions
|
9
37
|
@features = features
|
10
38
|
@groups = groups
|
11
39
|
@tree = tree
|
data/lib/featury/version.rb
CHANGED