featury 1.0.0.rc13 → 1.0.0.rc16
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 +29 -9
- data/lib/featury/actions/service/factory.rb +1 -1
- data/lib/featury/base.rb +1 -0
- data/lib/featury/callbacks/callback.rb +3 -2
- data/lib/featury/callbacks/collection.rb +11 -2
- data/lib/featury/callbacks/dsl.rb +8 -6
- data/lib/featury/callbacks/service.rb +2 -2
- data/lib/featury/callbacks/workspace.rb +2 -2
- data/lib/featury/features/collection.rb +2 -2
- data/lib/featury/features/dsl.rb +1 -0
- data/lib/featury/features/feature.rb +4 -2
- data/lib/featury/info/dsl.rb +25 -0
- data/lib/featury/info/result.rb +15 -0
- data/lib/featury/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cd98a4235a1f9d9340fa5636436c54a70a7fc5fa54948d13ceaf311d9facd13
|
4
|
+
data.tar.gz: c392d9f3cde18aa65a60078335040b52b1fa43d6e152e133929e4de2bb3fa26c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e807ae55d5679f89ab50cdf2a68384eb82d100f0902f0b262e051eccfb0e13fe2b10178204a2e0cf6fd6a4702f9f74a5b8f0d2e2287f46f7ac667415e2c89dc2
|
7
|
+
data.tar.gz: '0198b0a0a4c9efe3dc5ad9d44b7f619b98950c86607cb13ef133f759a84faca48df9f07782ff51b1874d93403a8d6f5eb71b592f63407b62866d03fa90987e0d'
|
data/README.md
CHANGED
@@ -26,7 +26,7 @@ gem "featury"
|
|
26
26
|
#### Basic class for your features
|
27
27
|
|
28
28
|
For instance, assume that you are utilizing Flipper for managing features.
|
29
|
-
In such scenario, the base class could potentially be structured as follows:
|
29
|
+
In such a scenario, the base class could potentially be structured as follows:
|
30
30
|
|
31
31
|
```ruby
|
32
32
|
class ApplicationFeature < Featury::Base
|
@@ -45,19 +45,27 @@ class ApplicationFeature < Featury::Base
|
|
45
45
|
action :disable do |features:, **options|
|
46
46
|
features.all? { |feature| Flipper.disable(feature, *options.values) }
|
47
47
|
end
|
48
|
+
|
49
|
+
before do |action:, features:|
|
50
|
+
Slack::API::Notify.call!(action:, features:)
|
51
|
+
end
|
52
|
+
|
53
|
+
after :enabled?, :disabled? do |action:, features:|
|
54
|
+
Slack::API::Notify.call!(action:, features:)
|
55
|
+
end
|
48
56
|
end
|
49
57
|
```
|
50
58
|
|
51
59
|
#### Features of your project
|
52
60
|
|
53
61
|
```ruby
|
54
|
-
class
|
62
|
+
class User::OnboardingFeature < ApplicationFeature
|
63
|
+
prefix :user_onboarding
|
64
|
+
|
55
65
|
resource :user, type: User
|
56
66
|
|
57
67
|
condition ->(resources:) { resources.user.onboarding_awaiting? }
|
58
68
|
|
59
|
-
prefix :user_onboarding
|
60
|
-
|
61
69
|
features :passage # => :user_onboarding_passage
|
62
70
|
|
63
71
|
groups BillingFeature,
|
@@ -104,16 +112,16 @@ Each of these actions will be applied to every feature flag.
|
|
104
112
|
Subsequently, the outcome of these actions will be contingent upon the combined results of all feature flags.
|
105
113
|
|
106
114
|
```ruby
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
115
|
+
User::OnboardingFeature.enabled?(user:) # => true
|
116
|
+
User::OnboardingFeature.disabled?(user:) # => false
|
117
|
+
User::OnboardingFeature.enable(user:) # => true
|
118
|
+
User::OnboardingFeature.disable(user:) # => true
|
111
119
|
```
|
112
120
|
|
113
121
|
You can also utilize the `with` method to pass necessary arguments.
|
114
122
|
|
115
123
|
```ruby
|
116
|
-
feature =
|
124
|
+
feature = User::OnboardingFeature.with(user:)
|
117
125
|
|
118
126
|
feature.enabled? # => true
|
119
127
|
feature.disabled? # => false
|
@@ -129,6 +137,18 @@ In the preceding example, there might be a scenario where the payment system is
|
|
129
137
|
undergoing technical maintenance and therefore is temporarily shut down.
|
130
138
|
Consequently, the onboarding process for new users will be halted until further notice.
|
131
139
|
|
140
|
+
#### Information about features
|
141
|
+
|
142
|
+
```ruby
|
143
|
+
info = User::OnboardingFeature.info
|
144
|
+
```
|
145
|
+
|
146
|
+
```ruby
|
147
|
+
info.features # Feature flags within one class.
|
148
|
+
info.groups # Feature groups within one class.
|
149
|
+
info.tree # Tree of feature flags starting from the current class.
|
150
|
+
```
|
151
|
+
|
132
152
|
## Contributing
|
133
153
|
|
134
154
|
This project is intended to be a safe, welcoming space for collaboration.
|
@@ -65,7 +65,7 @@ module Featury
|
|
65
65
|
[resource.name, inputs.public_send(resource.name)]
|
66
66
|
end
|
67
67
|
|
68
|
-
inputs.action.block.call(features: inputs.collection_of_features.
|
68
|
+
inputs.action.block.call(features: inputs.collection_of_features.full_names, **options)
|
69
69
|
end
|
70
70
|
|
71
71
|
def groups_are_true
|
data/lib/featury/base.rb
CHANGED
@@ -3,10 +3,11 @@
|
|
3
3
|
module Featury
|
4
4
|
module Callbacks
|
5
5
|
class Callback
|
6
|
-
attr_reader :block
|
6
|
+
attr_reader :desired_actions, :block
|
7
7
|
|
8
|
-
def initialize(stage
|
8
|
+
def initialize(stage:, desired_actions:, block:)
|
9
9
|
@stage = stage.to_sym
|
10
|
+
@desired_actions = desired_actions
|
10
11
|
@block = block
|
11
12
|
end
|
12
13
|
|
@@ -10,12 +10,21 @@ module Featury
|
|
10
10
|
@collection = collection
|
11
11
|
end
|
12
12
|
|
13
|
+
def desired_actions(include:)
|
14
|
+
Collection.new(
|
15
|
+
filter do |callback|
|
16
|
+
callback.desired_actions.blank? ||
|
17
|
+
callback.desired_actions.include?(include)
|
18
|
+
end
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
13
22
|
def before
|
14
|
-
|
23
|
+
Collection.new(filter(&:before?))
|
15
24
|
end
|
16
25
|
|
17
26
|
def after
|
18
|
-
|
27
|
+
Collection.new(filter(&:after?))
|
19
28
|
end
|
20
29
|
end
|
21
30
|
end
|
@@ -17,17 +17,19 @@ module Featury
|
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
-
def before
|
20
|
+
def before(*actions)
|
21
21
|
collection_of_callbacks << Callback.new(
|
22
|
-
:before,
|
23
|
-
|
22
|
+
stage: :before,
|
23
|
+
desired_actions: actions,
|
24
|
+
block: ->(**arguments) { yield(**arguments) }
|
24
25
|
)
|
25
26
|
end
|
26
27
|
|
27
|
-
def after
|
28
|
+
def after(*actions)
|
28
29
|
collection_of_callbacks << Callback.new(
|
29
|
-
:after,
|
30
|
-
|
30
|
+
stage: :after,
|
31
|
+
desired_actions: actions,
|
32
|
+
block: ->(**arguments) { yield(**arguments) }
|
31
33
|
)
|
32
34
|
end
|
33
35
|
|
@@ -8,13 +8,13 @@ module Featury
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def initialize(action:, callbacks:, features:)
|
11
|
-
@callbacks = callbacks
|
12
11
|
@action = action
|
12
|
+
@callbacks = callbacks
|
13
13
|
@features = features
|
14
14
|
end
|
15
15
|
|
16
16
|
def call!
|
17
|
-
@callbacks.each do |callback|
|
17
|
+
@callbacks.desired_actions(include: @action).each do |callback|
|
18
18
|
callback.block.call(action: @action, features: @features)
|
19
19
|
end
|
20
20
|
end
|
@@ -9,7 +9,7 @@ module Featury
|
|
9
9
|
Featury::Callbacks::Service.call!(
|
10
10
|
action: action.name,
|
11
11
|
callbacks: collection_of_callbacks.before,
|
12
|
-
features: collection_of_features.
|
12
|
+
features: collection_of_features.full_names
|
13
13
|
)
|
14
14
|
|
15
15
|
result = super
|
@@ -17,7 +17,7 @@ module Featury
|
|
17
17
|
Featury::Callbacks::Service.call!(
|
18
18
|
action: action.name,
|
19
19
|
callbacks: collection_of_callbacks.after,
|
20
|
-
features: collection_of_features.
|
20
|
+
features: collection_of_features.full_names
|
21
21
|
)
|
22
22
|
|
23
23
|
result
|
data/lib/featury/features/dsl.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Featury
|
4
|
+
module Info
|
5
|
+
module DSL
|
6
|
+
def self.included(base)
|
7
|
+
base.extend(ClassMethods)
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
def info
|
12
|
+
Featury::Info::Result.new(
|
13
|
+
features: collection_of_features.full_names,
|
14
|
+
groups: collection_of_groups.map(&:group),
|
15
|
+
tree: collection_of_features.full_names.concat(
|
16
|
+
collection_of_groups.map do |group|
|
17
|
+
group.group.info.tree
|
18
|
+
end
|
19
|
+
)
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/featury/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: featury
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
@@ -179,6 +179,8 @@ files:
|
|
179
179
|
- lib/featury/groups/collection.rb
|
180
180
|
- lib/featury/groups/dsl.rb
|
181
181
|
- lib/featury/groups/group.rb
|
182
|
+
- lib/featury/info/dsl.rb
|
183
|
+
- lib/featury/info/result.rb
|
182
184
|
- lib/featury/resources/collection.rb
|
183
185
|
- lib/featury/resources/dsl.rb
|
184
186
|
- lib/featury/resources/resource.rb
|