featury 1.0.0.rc4 → 1.0.0.rc6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +38 -32
- data/lib/featury/actions/service/factory.rb +3 -3
- data/lib/featury/context/callable.rb +8 -0
- data/lib/featury/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1dc31fdf0161091a1e477a352c5e06629fed341c488d78e0d6153c02805623e
|
4
|
+
data.tar.gz: 298efaed87cd51269f3bef4573a925924db8503865f54d2e0402a7c35ba4b283
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca3ed00e6e9e6f0559c2a1ddf8a962c2dc8857d135bcf5a1c4e85f95a81d6c6244c65f050523a67a3d1aec82490a69812dc1186467b0ab2eaaba3a3523467e79
|
7
|
+
data.tar.gz: be517027a237226225c42d03a5ba88f0d050c93bdd82fcaf90681fb764f8602214d3381e59bf7f5531e18fde19328220d1f4e5a2257cd1911c43dbc26185d360
|
data/README.md
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
<a href="https://github.com/servactory/featury/releases"><img src="https://img.shields.io/github/release-date/servactory/featury" alt="Release Date"></a>
|
4
4
|
</p>
|
5
5
|
|
6
|
-
##
|
6
|
+
## Purpose
|
7
7
|
|
8
|
-
Featury is designed
|
9
|
-
|
10
|
-
|
8
|
+
Featury is designed to group and manage multiple features within a project.
|
9
|
+
It provides the flexibility to utilize any pre-existing solution or create your own.
|
10
|
+
It's easily adjustable to align with the unique needs and objectives of your project.
|
11
11
|
|
12
12
|
[//]: # (## Documentation)
|
13
13
|
|
@@ -25,8 +25,8 @@ gem "featury"
|
|
25
25
|
|
26
26
|
#### Basic class for your features
|
27
27
|
|
28
|
-
For
|
29
|
-
In
|
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:
|
30
30
|
|
31
31
|
```ruby
|
32
32
|
class ApplicationFeature < Featury::Base
|
@@ -58,14 +58,10 @@ class UserFeature::Onboarding < ApplicationFeature
|
|
58
58
|
|
59
59
|
prefix :user_onboarding
|
60
60
|
|
61
|
-
features
|
62
|
-
:passage, # => :user_onboarding_passage
|
63
|
-
)
|
61
|
+
features :passage # => :user_onboarding_passage
|
64
62
|
|
65
|
-
groups
|
66
|
-
|
67
|
-
PaymentSystemFeature
|
68
|
-
)
|
63
|
+
groups BillingFeature,
|
64
|
+
PaymentSystemFeature
|
69
65
|
end
|
70
66
|
```
|
71
67
|
|
@@ -73,9 +69,8 @@ end
|
|
73
69
|
class BillingFeature < ApplicationFeature
|
74
70
|
prefix :billing
|
75
71
|
|
76
|
-
features
|
77
|
-
|
78
|
-
)
|
72
|
+
features :api, # => :billing_api
|
73
|
+
:webhooks # => :billing_webhooks
|
79
74
|
end
|
80
75
|
```
|
81
76
|
|
@@ -83,22 +78,21 @@ end
|
|
83
78
|
class PaymentSystemFeature < ApplicationFeature
|
84
79
|
prefix :payment_system
|
85
80
|
|
86
|
-
features
|
87
|
-
|
88
|
-
)
|
81
|
+
features :api, # => :payment_system_api
|
82
|
+
:webhooks # => :payment_system_webhooks
|
89
83
|
end
|
90
84
|
```
|
91
85
|
|
92
|
-
The `resource` method
|
93
|
-
|
86
|
+
The `resource` method provides an indication of how the transmitted information ought to be processed.
|
87
|
+
Besides the options provided by [Servactory](https://github.com/servactory/servactory), additional ones are available for stipulating the processing mode of the transmitted data.
|
94
88
|
|
95
|
-
If
|
89
|
+
If a resource needs to be conveyed as a feature flag option, utilize the `option` parameter:
|
96
90
|
|
97
|
-
```ruby
|
91
|
+
```ruby
|
98
92
|
resource :user, type: User, option: true
|
99
93
|
```
|
100
94
|
|
101
|
-
|
95
|
+
To transfer a resource to a nested group, utilize the `nested` option:
|
102
96
|
|
103
97
|
```ruby
|
104
98
|
resource :user, type: User, nested: true
|
@@ -106,22 +100,34 @@ resource :user, type: User, nested: true
|
|
106
100
|
|
107
101
|
#### Working with the features of your project
|
108
102
|
|
109
|
-
Each of these actions will be applied to
|
110
|
-
|
103
|
+
Each of these actions will be applied to every feature flag.
|
104
|
+
Subsequently, the outcome of these actions will be contingent upon the combined results of all feature flags.
|
111
105
|
|
112
106
|
```ruby
|
113
107
|
UserFeature::Onboarding.enabled?(user:) # => true
|
114
108
|
UserFeature::Onboarding.disabled?(user:) # => false
|
115
109
|
UserFeature::Onboarding.enable(user:) # => true
|
116
|
-
UserFeature::Onboarding.disable(user:) # =>
|
110
|
+
UserFeature::Onboarding.disable(user:) # => true
|
111
|
+
```
|
112
|
+
|
113
|
+
You can also utilize the `with` method to pass necessary arguments.
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
feature = UserFeature::Onboarding.with(user:)
|
117
|
+
|
118
|
+
feature.enabled? # => true
|
119
|
+
feature.disabled? # => false
|
120
|
+
feature.enable # => true
|
121
|
+
feature.disable # => true
|
117
122
|
```
|
118
123
|
|
119
|
-
If
|
120
|
-
|
121
|
-
|
124
|
+
If a feature flag is deactivated, possibly via automation processes,
|
125
|
+
the primary feature class subsequently responds with `false` when
|
126
|
+
queried about its enablement status.
|
122
127
|
|
123
|
-
In the example
|
124
|
-
|
128
|
+
In the preceding example, there might be a scenario where the payment system is
|
129
|
+
undergoing technical maintenance and therefore is temporarily shut down.
|
130
|
+
Consequently, the onboarding process for new users will be halted until further notice.
|
125
131
|
|
126
132
|
## Contributing
|
127
133
|
|
@@ -21,7 +21,7 @@ module Featury
|
|
21
21
|
@model_class.const_set(Builder::SERVICE_CLASS_NAME, class_sample)
|
22
22
|
end
|
23
23
|
|
24
|
-
def create_service_class # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
24
|
+
def create_service_class # rubocop:disable Metrics/MethodLength, Metrics/AbcSize,Metrics/CyclomaticComplexity
|
25
25
|
collection_of_resources = @collection_of_resources
|
26
26
|
|
27
27
|
Class.new(Featury::Service::Builder) do
|
@@ -56,7 +56,7 @@ module Featury
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
def check_features
|
59
|
+
def check_features # rubocop:disable Metrics/AbcSize
|
60
60
|
options = inputs.collection_of_resources.only_option.to_h do |resource|
|
61
61
|
[resource.name, inputs.public_send(resource.name)]
|
62
62
|
end
|
@@ -65,7 +65,7 @@ module Featury
|
|
65
65
|
inputs.action.block.call(features: inputs.collection_of_features.list, **options)
|
66
66
|
end
|
67
67
|
|
68
|
-
def check_groups
|
68
|
+
def check_groups # rubocop:disable Metrics/AbcSize
|
69
69
|
arguments = inputs.collection_of_resources.only_nested.to_h do |resource|
|
70
70
|
[resource.name, inputs.public_send(resource.name)]
|
71
71
|
end
|
@@ -10,6 +10,8 @@ module Featury
|
|
10
10
|
|
11
11
|
context = send(:new)
|
12
12
|
|
13
|
+
arguments.merge!(@with_arguments) if @with_arguments.is_a?(Hash)
|
14
|
+
|
13
15
|
_call!(context, action, **arguments)
|
14
16
|
end
|
15
17
|
|
@@ -17,6 +19,12 @@ module Featury
|
|
17
19
|
collection_of_actions.names.include?(method_name) || super
|
18
20
|
end
|
19
21
|
|
22
|
+
def with(arguments = {})
|
23
|
+
@with_arguments = arguments
|
24
|
+
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
20
28
|
private
|
21
29
|
|
22
30
|
def _call!(context, action, **arguments)
|
data/lib/featury/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.rc6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '5.1'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '5.1'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '8.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: i18n
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,14 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.
|
53
|
+
version: 2.8.0
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 2.
|
60
|
+
version: 2.8.0
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: zeitwerk
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|