featury 1.0.0.rc16 → 1.0.0.rc20

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cd98a4235a1f9d9340fa5636436c54a70a7fc5fa54948d13ceaf311d9facd13
4
- data.tar.gz: c392d9f3cde18aa65a60078335040b52b1fa43d6e152e133929e4de2bb3fa26c
3
+ metadata.gz: 89e31c544583912d5448fd9fffbed08f5460691a921fdd3a6722dff1c6549ad1
4
+ data.tar.gz: bcc393cbf53897b0b1168f1d125b22c8d725450a2952817c1e29a3e83c12d787
5
5
  SHA512:
6
- metadata.gz: e807ae55d5679f89ab50cdf2a68384eb82d100f0902f0b262e051eccfb0e13fe2b10178204a2e0cf6fd6a4702f9f74a5b8f0d2e2287f46f7ac667415e2c89dc2
7
- data.tar.gz: '0198b0a0a4c9efe3dc5ad9d44b7f619b98950c86607cb13ef133f759a84faca48df9f07782ff51b1874d93403a8d6f5eb71b592f63407b62866d03fa90987e0d'
6
+ metadata.gz: 554318ae7d5d7b0727e0e9ef262fb020178cf5e1602a87d7800e2ad798691d9581f02f2b1975ccaf9f5d168915dca91a6b10eb2c2d201d51e730aa48d2aadb0a
7
+ data.tar.gz: 6c1cf235e2cd4d217f0a9c05140c70dd60f4c8d8615e8cce36e7e9be87298d6f970911c79a472085ca65271f48be00815c7cdf02c3ee6ffca8b8075f90a0c54e
data/README.md CHANGED
@@ -1,3 +1,13 @@
1
+ <p align="center">
2
+ <a href="https://servactory.com" target="_blank">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/servactory/featury/main/.github/logo-dark.svg">
5
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/servactory/featury/main/.github/logo-light.svg">
6
+ <img alt="Featury" src="https://raw.githubusercontent.com/servactory/featury/main/.github/logo-light.svg" width="350" height="70" style="max-width: 100%;">
7
+ </picture>
8
+ </a>
9
+ </p>
10
+
1
11
  <p align="center">
2
12
  <a href="https://rubygems.org/gems/featury"><img src="https://img.shields.io/gem/v/featury?logo=rubygems&logoColor=fff" alt="Gem version"></a>
3
13
  <a href="https://github.com/servactory/featury/releases"><img src="https://img.shields.io/github/release-date/servactory/featury" alt="Release Date"></a>
@@ -30,22 +40,26 @@ In such a scenario, the base class could potentially be structured as follows:
30
40
 
31
41
  ```ruby
32
42
  class ApplicationFeature < Featury::Base
33
- action :enabled? do |features:, **options|
43
+ action :enabled?, web: :enabled? do |features:, **options|
34
44
  features.all? { |feature| Flipper.enabled?(feature, *options.values) }
35
45
  end
36
46
 
37
- action :disabled? do |features:, **options|
47
+ action :disabled?, web: :regular do |features:, **options|
38
48
  features.any? { |feature| !Flipper.enabled?(feature, *options.values) }
39
49
  end
40
50
 
41
- action :enable do |features:, **options|
51
+ action :enable, web: :enable do |features:, **options|
42
52
  features.all? { |feature| Flipper.enable(feature, *options.values) }
43
53
  end
44
54
 
45
- action :disable do |features:, **options|
55
+ action :disable, web: :disable do |features:, **options|
46
56
  features.all? { |feature| Flipper.disable(feature, *options.values) }
47
57
  end
48
58
 
59
+ action :add do |features:, **options|
60
+ features.all? { |feature| Flipper.add(feature, *options.values) }
61
+ end
62
+
49
63
  before do |action:, features:|
50
64
  Slack::API::Notify.call!(action:, features:)
51
65
  end
@@ -56,6 +70,16 @@ class ApplicationFeature < Featury::Base
56
70
  end
57
71
  ```
58
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
+
59
83
  #### Features of your project
60
84
 
61
85
  ```ruby
@@ -144,9 +168,10 @@ info = User::OnboardingFeature.info
144
168
  ```
145
169
 
146
170
  ```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.
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.
150
175
  ```
151
176
 
152
177
  ## Contributing
@@ -3,12 +3,31 @@
3
3
  module Featury
4
4
  module Actions
5
5
  class Action
6
- attr_reader :name, :block
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
@@ -17,9 +17,10 @@ module Featury
17
17
 
18
18
  private
19
19
 
20
- def action(name)
20
+ def action(name, web: nil)
21
21
  collection_of_actions << Action.new(
22
22
  name,
23
+ web:,
23
24
  block: ->(features:, **options) { yield(features:, **options) }
24
25
  )
25
26
  end
@@ -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(
@@ -19,6 +20,11 @@ module Featury
19
20
  )
20
21
  )
21
22
  end
23
+
24
+ # API: Featury Web
25
+ def featury?
26
+ true
27
+ end
22
28
  end
23
29
  end
24
30
  end
@@ -3,9 +3,37 @@
3
3
  module Featury
4
4
  module Info
5
5
  class Result
6
- attr_reader :features, :groups, :tree
6
+ class Actions
7
+ class Web
8
+ attr_reader :all,
9
+ :enabled,
10
+ :enable,
11
+ :disable
7
12
 
8
- def initialize(features:, groups:, tree:)
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
@@ -5,7 +5,7 @@ module Featury
5
5
  MAJOR = 1
6
6
  MINOR = 0
7
7
  PATCH = 0
8
- PRE = "rc16"
8
+ PRE = "rc20"
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
11
11
  end
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.rc16
4
+ version: 1.0.0.rc20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
@@ -49,14 +49,14 @@ dependencies:
49
49
  requirements:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: '2.14'
52
+ version: '2.15'
53
53
  type: :runtime
54
54
  prerelease: false
55
55
  version_requirements: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: '2.14'
59
+ version: '2.15'
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: zeitwerk
62
62
  requirement: !ruby/object:Gem::Requirement
@@ -212,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
212
  - !ruby/object:Gem::Version
213
213
  version: '0'
214
214
  requirements: []
215
- rubygems_version: 3.6.7
215
+ rubygems_version: 3.6.9
216
216
  specification_version: 4
217
217
  summary: A set of tools for building reliable services of any complexity
218
218
  test_files: []