servactory 1.9.6 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/config/locales/en.yml +19 -4
  3. data/config/locales/ru.yml +21 -6
  4. data/lib/servactory/{methods/method.rb → actions/action.rb} +2 -2
  5. data/lib/servactory/{methods/aliases_for_make → actions/aliases}/collection.rb +2 -2
  6. data/lib/servactory/{methods/method_collection.rb → actions/collection.rb} +3 -3
  7. data/lib/servactory/{methods → actions}/dsl.rb +9 -9
  8. data/lib/servactory/{methods/shortcuts_for_make → actions/shortcuts}/collection.rb +2 -2
  9. data/lib/servactory/actions/stages/collection.rb +20 -0
  10. data/lib/servactory/actions/stages/stage.rb +30 -0
  11. data/lib/servactory/{methods → actions}/tools/runner.rb +1 -1
  12. data/lib/servactory/{methods → actions}/workspace.rb +4 -2
  13. data/lib/servactory/base.rb +1 -1
  14. data/lib/servactory/configuration/dsl.rb +4 -2
  15. data/lib/servactory/configuration/factory.rb +12 -4
  16. data/lib/servactory/configuration/setup.rb +24 -8
  17. data/lib/servactory/context/workspace/inputs.rb +43 -7
  18. data/lib/servactory/context/workspace/outputs.rb +1 -1
  19. data/lib/servactory/context/workspace.rb +0 -4
  20. data/lib/servactory/dsl.rb +18 -1
  21. data/lib/servactory/inputs/collection.rb +1 -1
  22. data/lib/servactory/inputs/dsl.rb +2 -0
  23. data/lib/servactory/inputs/input.rb +106 -88
  24. data/lib/servactory/inputs/tools/distributor.rb +24 -0
  25. data/lib/servactory/inputs/tools/rules.rb +3 -3
  26. data/lib/servactory/inputs/tools/{find_unnecessary.rb → unnecessary.rb} +4 -4
  27. data/lib/servactory/inputs/tools/validation.rb +5 -7
  28. data/lib/servactory/inputs/validations/base.rb +1 -1
  29. data/lib/servactory/inputs/validations/inclusion.rb +15 -10
  30. data/lib/servactory/inputs/validations/must.rb +26 -17
  31. data/lib/servactory/inputs/validations/required.rb +16 -11
  32. data/lib/servactory/inputs/validations/type.rb +19 -69
  33. data/lib/servactory/inputs/workspace.rb +6 -3
  34. data/lib/servactory/internals/dsl.rb +6 -1
  35. data/lib/servactory/internals/internal.rb +81 -14
  36. data/lib/servactory/internals/validations/base.rb +1 -1
  37. data/lib/servactory/internals/validations/type.rb +6 -43
  38. data/lib/servactory/maintenance/attributes/define_conflict.rb +15 -0
  39. data/lib/servactory/maintenance/attributes/define_method.rb +17 -0
  40. data/lib/servactory/maintenance/attributes/option.rb +121 -0
  41. data/lib/servactory/maintenance/attributes/option_helper.rb +17 -0
  42. data/lib/servactory/maintenance/attributes/option_helpers_collection.rb +20 -0
  43. data/lib/servactory/maintenance/attributes/options_collection.rb +48 -0
  44. data/lib/servactory/maintenance/collection_mode/class_names_collection.rb +16 -0
  45. data/lib/servactory/maintenance/hash_mode/class_names_collection.rb +16 -0
  46. data/lib/servactory/maintenance/validations/collection.rb +66 -0
  47. data/lib/servactory/maintenance/validations/object_schema.rb +116 -0
  48. data/lib/servactory/maintenance/validations/types.rb +181 -0
  49. data/lib/servactory/outputs/dsl.rb +6 -1
  50. data/lib/servactory/outputs/output.rb +79 -19
  51. data/lib/servactory/outputs/validations/base.rb +1 -1
  52. data/lib/servactory/outputs/validations/type.rb +6 -45
  53. data/lib/servactory/version.rb +5 -4
  54. data/lib/servactory.rb +1 -1
  55. metadata +56 -30
  56. data/lib/servactory/inputs/define_input_conflict.rb +0 -13
  57. data/lib/servactory/inputs/define_input_method.rb +0 -15
  58. data/lib/servactory/inputs/option.rb +0 -98
  59. data/lib/servactory/inputs/option_helper.rb +0 -15
  60. data/lib/servactory/inputs/option_helpers_collection.rb +0 -18
  61. data/lib/servactory/inputs/options_collection.rb +0 -46
  62. data/lib/servactory/methods/stage.rb +0 -28
  63. data/lib/servactory/methods/stage_collection.rb +0 -18
metadata CHANGED
@@ -1,43 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.6
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-10 00:00:00.000000000 Z
11
+ date: 2023-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '6.0'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: 7.0.8
22
+ version: '7.2'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '6.0'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: 7.0.8
32
+ version: '7.2'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: i18n
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: '1.13'
39
+ version: '1.14'
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
44
  - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: '1.13'
46
+ version: '1.14'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: zeitwerk
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +58,20 @@ dependencies:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
60
  version: '2.6'
61
+ - !ruby/object:Gem::Dependency
62
+ name: appraisal
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '2.5'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '2.5'
55
75
  - !ruby/object:Gem::Dependency
56
76
  name: pry
57
77
  requirement: !ruby/object:Gem::Requirement
@@ -114,28 +134,28 @@ dependencies:
114
134
  requirements:
115
135
  - - "~>"
116
136
  - !ruby/object:Gem::Version
117
- version: '1.50'
137
+ version: '1.57'
118
138
  type: :development
119
139
  prerelease: false
120
140
  version_requirements: !ruby/object:Gem::Requirement
121
141
  requirements:
122
142
  - - "~>"
123
143
  - !ruby/object:Gem::Version
124
- version: '1.50'
144
+ version: '1.57'
125
145
  - !ruby/object:Gem::Dependency
126
146
  name: rubocop-performance
127
147
  requirement: !ruby/object:Gem::Requirement
128
148
  requirements:
129
149
  - - "~>"
130
150
  - !ruby/object:Gem::Version
131
- version: '1.17'
151
+ version: '1.19'
132
152
  type: :development
133
153
  prerelease: false
134
154
  version_requirements: !ruby/object:Gem::Requirement
135
155
  requirements:
136
156
  - - "~>"
137
157
  - !ruby/object:Gem::Version
138
- version: '1.17'
158
+ version: '1.19'
139
159
  - !ruby/object:Gem::Dependency
140
160
  name: rubocop-rake
141
161
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +176,14 @@ dependencies:
156
176
  requirements:
157
177
  - - "~>"
158
178
  - !ruby/object:Gem::Version
159
- version: '2.19'
179
+ version: '2.24'
160
180
  type: :development
161
181
  prerelease: false
162
182
  version_requirements: !ruby/object:Gem::Requirement
163
183
  requirements:
164
184
  - - "~>"
165
185
  - !ruby/object:Gem::Version
166
- version: '2.19'
186
+ version: '2.24'
167
187
  - !ruby/object:Gem::Dependency
168
188
  name: steep
169
189
  requirement: !ruby/object:Gem::Requirement
@@ -204,6 +224,15 @@ files:
204
224
  - config/locales/en.yml
205
225
  - config/locales/ru.yml
206
226
  - lib/servactory.rb
227
+ - lib/servactory/actions/action.rb
228
+ - lib/servactory/actions/aliases/collection.rb
229
+ - lib/servactory/actions/collection.rb
230
+ - lib/servactory/actions/dsl.rb
231
+ - lib/servactory/actions/shortcuts/collection.rb
232
+ - lib/servactory/actions/stages/collection.rb
233
+ - lib/servactory/actions/stages/stage.rb
234
+ - lib/servactory/actions/tools/runner.rb
235
+ - lib/servactory/actions/workspace.rb
207
236
  - lib/servactory/base.rb
208
237
  - lib/servactory/configuration/dsl.rb
209
238
  - lib/servactory/configuration/factory.rb
@@ -224,17 +253,12 @@ files:
224
253
  - lib/servactory/info/dsl.rb
225
254
  - lib/servactory/info/result.rb
226
255
  - lib/servactory/inputs/collection.rb
227
- - lib/servactory/inputs/define_input_conflict.rb
228
- - lib/servactory/inputs/define_input_method.rb
229
256
  - lib/servactory/inputs/dsl.rb
230
257
  - lib/servactory/inputs/input.rb
231
- - lib/servactory/inputs/option.rb
232
- - lib/servactory/inputs/option_helper.rb
233
- - lib/servactory/inputs/option_helpers_collection.rb
234
- - lib/servactory/inputs/options_collection.rb
235
258
  - lib/servactory/inputs/tools/check_errors.rb
236
- - lib/servactory/inputs/tools/find_unnecessary.rb
259
+ - lib/servactory/inputs/tools/distributor.rb
237
260
  - lib/servactory/inputs/tools/rules.rb
261
+ - lib/servactory/inputs/tools/unnecessary.rb
238
262
  - lib/servactory/inputs/tools/validation.rb
239
263
  - lib/servactory/inputs/validations/base.rb
240
264
  - lib/servactory/inputs/validations/errors.rb
@@ -248,15 +272,17 @@ files:
248
272
  - lib/servactory/internals/internal.rb
249
273
  - lib/servactory/internals/validations/base.rb
250
274
  - lib/servactory/internals/validations/type.rb
251
- - lib/servactory/methods/aliases_for_make/collection.rb
252
- - lib/servactory/methods/dsl.rb
253
- - lib/servactory/methods/method.rb
254
- - lib/servactory/methods/method_collection.rb
255
- - lib/servactory/methods/shortcuts_for_make/collection.rb
256
- - lib/servactory/methods/stage.rb
257
- - lib/servactory/methods/stage_collection.rb
258
- - lib/servactory/methods/tools/runner.rb
259
- - lib/servactory/methods/workspace.rb
275
+ - lib/servactory/maintenance/attributes/define_conflict.rb
276
+ - lib/servactory/maintenance/attributes/define_method.rb
277
+ - lib/servactory/maintenance/attributes/option.rb
278
+ - lib/servactory/maintenance/attributes/option_helper.rb
279
+ - lib/servactory/maintenance/attributes/option_helpers_collection.rb
280
+ - lib/servactory/maintenance/attributes/options_collection.rb
281
+ - lib/servactory/maintenance/collection_mode/class_names_collection.rb
282
+ - lib/servactory/maintenance/hash_mode/class_names_collection.rb
283
+ - lib/servactory/maintenance/validations/collection.rb
284
+ - lib/servactory/maintenance/validations/object_schema.rb
285
+ - lib/servactory/maintenance/validations/types.rb
260
286
  - lib/servactory/outputs/collection.rb
261
287
  - lib/servactory/outputs/dsl.rb
262
288
  - lib/servactory/outputs/output.rb
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Inputs
5
- class DefineInputConflict
6
- attr_reader :content
7
-
8
- def initialize(content:)
9
- @content = content
10
- end
11
- end
12
- end
13
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Inputs
5
- class DefineInputMethod
6
- attr_reader :name,
7
- :content
8
-
9
- def initialize(name:, content:)
10
- @name = name.to_sym
11
- @content = content
12
- end
13
- end
14
- end
15
- end
@@ -1,98 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Inputs
5
- class Option
6
- DEFAULT_VALUE = ->(key:, value:, message: nil) { { key => value, message: message } }
7
-
8
- private_constant :DEFAULT_VALUE
9
-
10
- attr_reader :name,
11
- :validation_class,
12
- :define_input_methods,
13
- :define_input_conflicts,
14
- :need_for_checks,
15
- :value_key,
16
- :value
17
-
18
- # rubocop:disable Metrics/MethodLength
19
- def initialize(
20
- name:,
21
- input:,
22
- validation_class:,
23
- need_for_checks:,
24
- value_fallback:,
25
- original_value: nil,
26
- value_key: nil,
27
- define_input_methods: nil,
28
- define_input_conflicts: nil,
29
- with_advanced_mode: true,
30
- **options
31
- ) # do
32
- @name = name.to_sym
33
- @validation_class = validation_class
34
- @define_input_methods = define_input_methods
35
- @define_input_conflicts = define_input_conflicts
36
- @need_for_checks = need_for_checks
37
- @value_key = value_key
38
-
39
- @value = prepare_value_for(
40
- original_value: original_value,
41
- options: options,
42
- value_fallback: value_fallback,
43
- with_advanced_mode: with_advanced_mode
44
- )
45
-
46
- prepare_input_methods_for(input)
47
- end
48
- # rubocop:enable Metrics/MethodLength
49
-
50
- def need_for_checks?
51
- need_for_checks
52
- end
53
-
54
- private
55
-
56
- def prepare_value_for(original_value:, options:, value_fallback:, with_advanced_mode:)
57
- return original_value if original_value.present?
58
-
59
- return options.fetch(@name, value_fallback) unless with_advanced_mode
60
-
61
- prepare_advanced_for(
62
- value: options.fetch(@name, DEFAULT_VALUE.call(key: value_key, value: value_fallback)),
63
- value_fallback: value_fallback
64
- )
65
- end
66
-
67
- def prepare_advanced_for(value:, value_fallback:)
68
- if value.is_a?(Hash)
69
- message = value.fetch(:message, nil)
70
-
71
- DEFAULT_VALUE.call(
72
- key: value_key,
73
- value: value.fetch(value_key, message.present? ? true : value_fallback),
74
- message: message
75
- )
76
- else
77
- DEFAULT_VALUE.call(key: value_key, value: value)
78
- end
79
- end
80
-
81
- def prepare_input_methods_for(input)
82
- input.instance_eval(define_input_methods_template) if define_input_methods_template.present?
83
- end
84
-
85
- def define_input_methods_template
86
- return if @define_input_methods.blank?
87
-
88
- @define_input_methods_template ||= @define_input_methods.map do |define_input_method|
89
- <<-RUBY
90
- def #{define_input_method.name}
91
- #{define_input_method.content.call(value: @value)}
92
- end
93
- RUBY
94
- end.join("\n")
95
- end
96
- end
97
- end
98
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Inputs
5
- class OptionHelper
6
- attr_reader :name,
7
- :equivalent
8
-
9
- def initialize(name:, equivalent:)
10
- @name = name
11
- @equivalent = equivalent
12
- end
13
- end
14
- end
15
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Inputs
5
- class OptionHelpersCollection
6
- extend Forwardable
7
- def_delegators :@collection, :<<, :find, :merge
8
-
9
- def initialize(collection)
10
- @collection = collection
11
- end
12
-
13
- def find_by(name:)
14
- find { |helper| helper.name == name }
15
- end
16
- end
17
- end
18
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Inputs
5
- class OptionsCollection
6
- extend Forwardable
7
- def_delegators :@collection, :<<, :filter, :each, :map, :flat_map, :find
8
-
9
- def initialize(*)
10
- @collection = Set.new
11
- end
12
-
13
- def names
14
- map(&:name)
15
- end
16
-
17
- def validation_classes
18
- filter { |option| option.validation_class.present? }.map(&:validation_class).uniq
19
- end
20
-
21
- def options_for_checks
22
- filter(&:need_for_checks?).to_h do |option|
23
- value = if option.value.is_a?(Hash)
24
- option.value.key?(:is) ? option.value.fetch(:is) : option.value
25
- else
26
- option.value
27
- end
28
-
29
- [option.name, value]
30
- end
31
- end
32
-
33
- def defined_conflict_code
34
- flat_map do |option|
35
- option.define_input_conflicts&.map do |define_input_conflict|
36
- define_input_conflict.content.call
37
- end
38
- end.reject(&:blank?).first
39
- end
40
-
41
- def find_by(name:)
42
- find { |option| option.name == name }
43
- end
44
- end
45
- end
46
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Methods
5
- class Stage
6
- attr_accessor :position,
7
- :wrapper,
8
- :rollback,
9
- :condition,
10
- :is_condition_opposite
11
-
12
- def initialize(position:, wrapper: nil, rollback: nil, condition: nil)
13
- @position = position
14
- @wrapper = wrapper
15
- @rollback = rollback
16
- @condition = condition
17
- end
18
-
19
- def next_method_position
20
- methods.size + 1
21
- end
22
-
23
- def methods
24
- @methods ||= MethodCollection.new
25
- end
26
- end
27
- end
28
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Methods
5
- class StageCollection
6
- extend Forwardable
7
- def_delegators :@collection, :<<, :each, :merge, :sort_by, :size, :empty?
8
-
9
- def initialize(collection = Set.new)
10
- @collection = collection
11
- end
12
-
13
- def sorted_by_position
14
- StageCollection.new(sort_by(&:position))
15
- end
16
- end
17
- end
18
- end