servactory 2.16.0.rc1 → 2.16.0.rc2

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: bc13e8261f2784169fde009e5f3fd2527e963e55cbda931d728c46319b395187
4
- data.tar.gz: 9b4f88c9ba2695f0fa8c8084866bb27a1bcf99702890985e080d08a750d6e1c1
3
+ metadata.gz: 3ff6af883d52092f1fd6589a77d962a3bd8b346ca5b8f40ffe4489b993e023e3
4
+ data.tar.gz: 8eb05b74076fa1c75e6688ffa1503daaca3f5f0a43d32d621eeda3912456d4cc
5
5
  SHA512:
6
- metadata.gz: ab74975be82b4e3231a1ed12d92d12853755afe051e7e0f7144ae34efbc909c124e70091a333fba41c657c2f5344abd7cc649c5f9def2d37e7363b41ab39d794
7
- data.tar.gz: b46024d472db88be0c99e9eb15c912089b4ebace519e39e5e840ba84272f7d61572fcf851c47b106e4acd44037798d9a7fd40547093521a87a180f6c3bac677a
6
+ metadata.gz: 9bf62d2f5546ccf038ba21009e9cca29d27dfe10431d1117bd020e5c537d45afc10f1323b2ce34ae87b7e43d750b4cae767277390d51de81c3692fe984fb7aaf
7
+ data.tar.gz: 0c1c762bccd20fc0d9738a6c5788dd27d874567306adeb6edabe5d2ba0522fdabd0c507ac97d63ca9b35dba7fa4475ff9c54c6ffdb76ebd819e58d092e9acf98
@@ -4,7 +4,7 @@ module Servactory
4
4
  module Actions
5
5
  class Collection
6
6
  extend Forwardable
7
- def_delegators :@collection, :<<, :each, :sort_by
7
+ def_delegators :@collection, :<<, :each, :map, :sort_by
8
8
 
9
9
  def initialize(collection = Set.new)
10
10
  @collection = collection
@@ -77,7 +77,7 @@ module Servactory
77
77
 
78
78
  current_stage = @current_stage.presence || Stages::Stage.new(position:)
79
79
 
80
- current_stage.methods << Action.new(
80
+ current_stage.actions << Action.new(
81
81
  name,
82
82
  position:,
83
83
  **options
@@ -5,7 +5,7 @@ module Servactory
5
5
  module Stages
6
6
  class Collection
7
7
  extend Forwardable
8
- def_delegators :@collection, :<<, :each, :merge, :sort_by, :size, :empty?
8
+ def_delegators :@collection, :<<, :each, :merge, :to_h, :sort_by, :size, :empty?
9
9
 
10
10
  def initialize(collection = Set.new)
11
11
  @collection = collection
@@ -17,12 +17,8 @@ module Servactory
17
17
  @condition = condition
18
18
  end
19
19
 
20
- def next_method_position
21
- methods.size + 1
22
- end
23
-
24
- def methods
25
- @methods ||= Collection.new
20
+ def actions
21
+ @actions ||= Servactory::Actions::Collection.new
26
22
  end
27
23
  end
28
24
  end
@@ -32,17 +32,17 @@ module Servactory
32
32
 
33
33
  wrapper = stage.wrapper
34
34
  rollback = stage.rollback
35
- methods = stage.methods.sorted_by_position
35
+ actions = stage.actions.sorted_by_position
36
36
 
37
37
  if wrapper.is_a?(Proc)
38
- call_wrapper_with_methods(wrapper, rollback, methods)
38
+ call_wrapper_with_actions(wrapper, rollback, actions)
39
39
  else
40
- call_methods(methods)
40
+ call_actions(actions)
41
41
  end
42
42
  end
43
43
 
44
- def call_wrapper_with_methods(wrapper, rollback, methods) # rubocop:disable Metrics/MethodLength
45
- wrapper.call(methods: -> { call_methods(methods) }, context: @context)
44
+ def call_wrapper_with_actions(wrapper, rollback, actions) # rubocop:disable Metrics/MethodLength
45
+ wrapper.call(methods: -> { call_actions(actions) }, context: @context)
46
46
  rescue StandardError => e
47
47
  if rollback.present?
48
48
  @context.send(rollback, e)
@@ -56,16 +56,16 @@ module Servactory
56
56
  end
57
57
  end
58
58
 
59
- def call_methods(methods)
60
- methods.each do |method|
61
- next if unnecessary_for_make?(method)
59
+ def call_actions(actions)
60
+ actions.each do |action|
61
+ next if unnecessary_for_make?(action)
62
62
 
63
- call_method(method)
63
+ call_action(action)
64
64
  end
65
65
  end
66
66
 
67
- def call_method(method)
68
- @context.send(method.name)
67
+ def call_action(action)
68
+ @context.send(action.name)
69
69
  rescue StandardError => e
70
70
  rescue_with_handler(e) || raise
71
71
  end
@@ -79,9 +79,9 @@ module Servactory
79
79
  is_condition_opposite ? !result : result
80
80
  end
81
81
 
82
- def unnecessary_for_make?(make_method)
83
- condition = make_method.condition
84
- is_condition_opposite = make_method.is_condition_opposite
82
+ def unnecessary_for_make?(make_action)
83
+ condition = make_action.condition
84
+ is_condition_opposite = make_action.is_condition_opposite
85
85
 
86
86
  result = prepare_condition_for(condition)
87
87
 
@@ -5,17 +5,19 @@ module Servactory
5
5
  class Builder # rubocop:disable Metrics/ClassLength
6
6
  attr_reader :inputs,
7
7
  :internals,
8
- :outputs
8
+ :outputs,
9
+ :stages
9
10
 
10
11
  def self.build(...)
11
12
  new.build(...)
12
13
  end
13
14
 
14
- def build(collection_of_inputs:, collection_of_internals:, collection_of_outputs:, config:)
15
+ def build(collection_of_inputs:, collection_of_internals:, collection_of_outputs:, collection_of_stages:, config:)
15
16
  build_all_attributes(
16
17
  inputs: collection_of_inputs,
17
18
  internals: collection_of_internals,
18
19
  outputs: collection_of_outputs,
20
+ stages: collection_of_stages,
19
21
  config:
20
22
  )
21
23
 
@@ -25,7 +27,7 @@ module Servactory
25
27
  private
26
28
 
27
29
  # rubocop:disable Metrics/MethodLength
28
- def build_all_attributes(inputs:, internals:, outputs:, config:)
30
+ def build_all_attributes(inputs:, internals:, outputs:, stages:, config:)
29
31
  build_input_attributes_with(
30
32
  collection: inputs,
31
33
  dynamic_options: config.input_option_helpers.dynamic_options
@@ -40,6 +42,8 @@ module Servactory
40
42
  collection: outputs,
41
43
  dynamic_options: config.output_option_helpers.dynamic_options
42
44
  )
45
+
46
+ build_action_stages_with(collection: stages)
43
47
  end
44
48
  # rubocop:enable Metrics/MethodLength
45
49
 
@@ -65,6 +69,22 @@ module Servactory
65
69
  )
66
70
  end
67
71
 
72
+ def build_action_stages_with(collection:) # rubocop:disable Metrics/MethodLength
73
+ @stages = collection.to_h do |stage|
74
+ [
75
+ :"stage_#{stage.position}",
76
+ stage.actions.map do |action|
77
+ {
78
+ action.name => {
79
+ position: action.position,
80
+ condition: action.condition
81
+ }
82
+ }
83
+ end
84
+ ]
85
+ end
86
+ end
87
+
68
88
  def build_attributes_with(collection:, dynamic_options:, include_specific_options: false) # rubocop:disable Metrics/MethodLength
69
89
  collection.to_h do |attribute|
70
90
  options = process_options_for(
@@ -13,12 +13,14 @@ module Servactory
13
13
  collection_of_inputs:,
14
14
  collection_of_internals:,
15
15
  collection_of_outputs:,
16
+ collection_of_stages:,
16
17
  config:
17
18
  )
18
19
 
19
20
  Result.new(builder)
20
21
  end
21
22
 
23
+ # API: Servactory Web
22
24
  def servactory?
23
25
  true
24
26
  end
@@ -5,12 +5,14 @@ module Servactory
5
5
  class Result
6
6
  attr_reader :inputs,
7
7
  :internals,
8
- :outputs
8
+ :outputs,
9
+ :stages
9
10
 
10
11
  def initialize(builder)
11
12
  @inputs = builder.inputs
12
13
  @internals = builder.internals
13
14
  @outputs = builder.outputs
15
+ @stages = builder.stages
14
16
  end
15
17
  end
16
18
  end
@@ -5,7 +5,7 @@ module Servactory
5
5
  MAJOR = 2
6
6
  MINOR = 16
7
7
  PATCH = 0
8
- PRE = "rc1"
8
+ PRE = "rc2"
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: servactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.16.0.rc1
4
+ version: 2.16.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov