featury 1.0.0.rc12 → 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 +6 -1
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,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.rc13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
@@ -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
|