featury 1.0.0.rc11 → 1.0.0.rc13
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/lib/featury/base.rb +1 -0
- data/lib/featury/callbacks/callback.rb +22 -0
- data/lib/featury/callbacks/collection.rb +22 -0
- data/lib/featury/callbacks/dsl.rb +40 -0
- data/lib/featury/callbacks/service.rb +23 -0
- data/lib/featury/callbacks/workspace.rb +27 -0
- data/lib/featury/context/callable.rb +1 -0
- data/lib/featury/context/workspace.rb +5 -0
- data/lib/featury/features/collection.rb +1 -1
- data/lib/featury/features/dsl.rb +19 -2
- data/lib/featury/version.rb +1 -1
- metadata +23 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97cc910762d980a170b075f98d2b5fe4cff87af8680477a06805fd31f0f9576b
|
4
|
+
data.tar.gz: 14ebb9a2d462b8414d5291a64b1a8d7c4b3957a3ad3669ebd88fc39c821c5ec4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ddf5182c50a1476a46d5ab336a0cb11baf3e0c9c72d27c71e51b5b5b1134376972aede1c3b0d334f3dc5b621096695ca45cc9e058b14a31816c3e11b946bf57
|
7
|
+
data.tar.gz: 8584f3fec8b9bdf944923754fe27ffcb54ac3b13b9ed5e4393449ce6c2505b6760418f3c84651e55ce80a9c276e95a8c8df9d8f702b2fb039051973d48036148
|
data/lib/featury/base.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Featury
|
4
|
+
module Callbacks
|
5
|
+
class Callback
|
6
|
+
attr_reader :block
|
7
|
+
|
8
|
+
def initialize(stage, block:)
|
9
|
+
@stage = stage.to_sym
|
10
|
+
@block = block
|
11
|
+
end
|
12
|
+
|
13
|
+
def before?
|
14
|
+
@stage == :before
|
15
|
+
end
|
16
|
+
|
17
|
+
def after?
|
18
|
+
@stage == :after
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Featury
|
4
|
+
module Callbacks
|
5
|
+
class Collection
|
6
|
+
extend Forwardable
|
7
|
+
def_delegators :@collection, :<<, :filter, :each, :map, :merge, :find
|
8
|
+
|
9
|
+
def initialize(collection = Set.new)
|
10
|
+
@collection = collection
|
11
|
+
end
|
12
|
+
|
13
|
+
def before
|
14
|
+
@before ||= Collection.new(filter(&:before?))
|
15
|
+
end
|
16
|
+
|
17
|
+
def after
|
18
|
+
@after ||= Collection.new(filter(&:after?))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Featury
|
4
|
+
module Callbacks
|
5
|
+
module DSL
|
6
|
+
def self.included(base)
|
7
|
+
base.extend(ClassMethods)
|
8
|
+
base.include(Workspace)
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
def inherited(child)
|
13
|
+
super
|
14
|
+
|
15
|
+
child.send(:collection_of_callbacks).merge(collection_of_callbacks)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def before
|
21
|
+
collection_of_callbacks << Callback.new(
|
22
|
+
:before,
|
23
|
+
block: ->(action:, features:) { yield(action:, features:) }
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def after
|
28
|
+
collection_of_callbacks << Callback.new(
|
29
|
+
:after,
|
30
|
+
block: ->(action:, features:) { yield(action:, features:) }
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def collection_of_callbacks
|
35
|
+
@collection_of_callbacks ||= Collection.new
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Featury
|
4
|
+
module Callbacks
|
5
|
+
class Service
|
6
|
+
def self.call!(...)
|
7
|
+
new(...).call!
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(action:, callbacks:, features:)
|
11
|
+
@callbacks = callbacks
|
12
|
+
@action = action
|
13
|
+
@features = features
|
14
|
+
end
|
15
|
+
|
16
|
+
def call!
|
17
|
+
@callbacks.each do |callback|
|
18
|
+
callback.block.call(action: @action, features: @features)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Featury
|
4
|
+
module Callbacks
|
5
|
+
module Workspace
|
6
|
+
private
|
7
|
+
|
8
|
+
def call!(action:, collection_of_callbacks:, collection_of_features:, **) # rubocop:disable Metrics/MethodLength
|
9
|
+
Featury::Callbacks::Service.call!(
|
10
|
+
action: action.name,
|
11
|
+
callbacks: collection_of_callbacks.before,
|
12
|
+
features: collection_of_features.list
|
13
|
+
)
|
14
|
+
|
15
|
+
result = super
|
16
|
+
|
17
|
+
Featury::Callbacks::Service.call!(
|
18
|
+
action: action.name,
|
19
|
+
callbacks: collection_of_callbacks.after,
|
20
|
+
features: collection_of_features.list
|
21
|
+
)
|
22
|
+
|
23
|
+
result
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -7,6 +7,7 @@ module Featury
|
|
7
7
|
|
8
8
|
attr_reader :action,
|
9
9
|
:incoming_arguments,
|
10
|
+
:collection_of_callbacks,
|
10
11
|
:collection_of_conditions,
|
11
12
|
:collection_of_features,
|
12
13
|
:collection_of_groups
|
@@ -14,6 +15,7 @@ module Featury
|
|
14
15
|
def _call!(
|
15
16
|
action:,
|
16
17
|
incoming_arguments:,
|
18
|
+
collection_of_callbacks:,
|
17
19
|
collection_of_resources:,
|
18
20
|
collection_of_conditions:,
|
19
21
|
collection_of_features:,
|
@@ -22,6 +24,7 @@ module Featury
|
|
22
24
|
call!(
|
23
25
|
action:,
|
24
26
|
incoming_arguments:,
|
27
|
+
collection_of_callbacks:,
|
25
28
|
collection_of_resources:,
|
26
29
|
collection_of_conditions:,
|
27
30
|
collection_of_features:,
|
@@ -32,6 +35,7 @@ module Featury
|
|
32
35
|
def call!(
|
33
36
|
action:,
|
34
37
|
incoming_arguments:,
|
38
|
+
collection_of_callbacks:,
|
35
39
|
collection_of_resources:,
|
36
40
|
collection_of_conditions:,
|
37
41
|
collection_of_features:,
|
@@ -39,6 +43,7 @@ module Featury
|
|
39
43
|
)
|
40
44
|
@action = action
|
41
45
|
@incoming_arguments = incoming_arguments
|
46
|
+
@collection_of_callbacks = collection_of_callbacks
|
42
47
|
@collection_of_resources = collection_of_resources
|
43
48
|
@collection_of_conditions = collection_of_conditions
|
44
49
|
@collection_of_features = collection_of_features
|
data/lib/featury/features/dsl.rb
CHANGED
@@ -17,15 +17,32 @@ module Featury
|
|
17
17
|
private
|
18
18
|
|
19
19
|
def prefix(prefix)
|
20
|
-
|
20
|
+
self.feature_prefix = prefix
|
21
21
|
end
|
22
22
|
|
23
23
|
def features(*names)
|
24
24
|
names.each do |name|
|
25
|
-
collection_of_features << Feature.new(
|
25
|
+
collection_of_features << Feature.new(feature_prefix, name)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
def feature_prefix=(value)
|
30
|
+
@feature_prefix = value
|
31
|
+
end
|
32
|
+
|
33
|
+
def feature_prefix
|
34
|
+
@feature_prefix || default_feature_prefix
|
35
|
+
end
|
36
|
+
|
37
|
+
def default_feature_prefix
|
38
|
+
@default_feature_prefix ||=
|
39
|
+
name.underscore
|
40
|
+
.gsub(/([a-z])(\d+)/, '\1_\2')
|
41
|
+
.gsub(/(\d+)([a-z])/, '\1_\2')
|
42
|
+
.tr("/", "_")
|
43
|
+
.to_sym
|
44
|
+
end
|
45
|
+
|
29
46
|
def collection_of_features
|
30
47
|
@collection_of_features ||= Collection.new
|
31
48
|
end
|
data/lib/featury/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
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.rc13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activesupport
|
@@ -33,14 +33,14 @@ dependencies:
|
|
33
33
|
name: i18n
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
|
-
- - "
|
36
|
+
- - ">="
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '1.14'
|
39
39
|
type: :runtime
|
40
40
|
prerelease: false
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
42
42
|
requirements:
|
43
|
-
- - "
|
43
|
+
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '1.14'
|
46
46
|
- !ruby/object:Gem::Dependency
|
@@ -49,54 +49,54 @@ dependencies:
|
|
49
49
|
requirements:
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '2.
|
52
|
+
version: '2.14'
|
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.
|
59
|
+
version: '2.14'
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: zeitwerk
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
|
-
- - "
|
64
|
+
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: '2.6'
|
67
67
|
type: :runtime
|
68
68
|
prerelease: false
|
69
69
|
version_requirements: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
|
-
- - "
|
71
|
+
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: '2.6'
|
74
74
|
- !ruby/object:Gem::Dependency
|
75
75
|
name: appraisal
|
76
76
|
requirement: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- - "
|
78
|
+
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '2.5'
|
81
81
|
type: :development
|
82
82
|
prerelease: false
|
83
83
|
version_requirements: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
-
- - "
|
85
|
+
- - ">="
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: '2.5'
|
88
88
|
- !ruby/object:Gem::Dependency
|
89
89
|
name: rake
|
90
90
|
requirement: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
|
-
- - "
|
92
|
+
- - ">="
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '13.0'
|
95
95
|
type: :development
|
96
96
|
prerelease: false
|
97
97
|
version_requirements: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- - "
|
99
|
+
- - ">="
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '13.0'
|
102
102
|
- !ruby/object:Gem::Dependency
|
@@ -117,14 +117,14 @@ dependencies:
|
|
117
117
|
name: rspec
|
118
118
|
requirement: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
|
-
- - "
|
120
|
+
- - ">="
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '3.12'
|
123
123
|
type: :development
|
124
124
|
prerelease: false
|
125
125
|
version_requirements: !ruby/object:Gem::Requirement
|
126
126
|
requirements:
|
127
|
-
- - "
|
127
|
+
- - ">="
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: '3.12'
|
130
130
|
- !ruby/object:Gem::Dependency
|
@@ -133,14 +133,14 @@ dependencies:
|
|
133
133
|
requirements:
|
134
134
|
- - ">="
|
135
135
|
- !ruby/object:Gem::Version
|
136
|
-
version: '0.
|
136
|
+
version: '0.9'
|
137
137
|
type: :development
|
138
138
|
prerelease: false
|
139
139
|
version_requirements: !ruby/object:Gem::Requirement
|
140
140
|
requirements:
|
141
141
|
- - ">="
|
142
142
|
- !ruby/object:Gem::Version
|
143
|
-
version: '0.
|
143
|
+
version: '0.9'
|
144
144
|
description: A set of tools for building reliable services of any complexity
|
145
145
|
email:
|
146
146
|
- profox.rus@gmail.com
|
@@ -160,6 +160,11 @@ files:
|
|
160
160
|
- lib/featury/actions/service/factory.rb
|
161
161
|
- lib/featury/actions/workspace.rb
|
162
162
|
- lib/featury/base.rb
|
163
|
+
- lib/featury/callbacks/callback.rb
|
164
|
+
- lib/featury/callbacks/collection.rb
|
165
|
+
- lib/featury/callbacks/dsl.rb
|
166
|
+
- lib/featury/callbacks/service.rb
|
167
|
+
- lib/featury/callbacks/workspace.rb
|
163
168
|
- lib/featury/conditions/collection.rb
|
164
169
|
- lib/featury/conditions/condition.rb
|
165
170
|
- lib/featury/conditions/dsl.rb
|
@@ -198,14 +203,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
198
203
|
requirements:
|
199
204
|
- - ">="
|
200
205
|
- !ruby/object:Gem::Version
|
201
|
-
version: 3.
|
206
|
+
version: '3.2'
|
202
207
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
208
|
requirements:
|
204
209
|
- - ">="
|
205
210
|
- !ruby/object:Gem::Version
|
206
211
|
version: '0'
|
207
212
|
requirements: []
|
208
|
-
rubygems_version: 3.6.
|
213
|
+
rubygems_version: 3.6.7
|
209
214
|
specification_version: 4
|
210
215
|
summary: A set of tools for building reliable services of any complexity
|
211
216
|
test_files: []
|