servactory 2.6.0.rc5 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 644c141dd6e3bdee996ffc4aad56a6e9b472ad964406923cc14fd1185541e2ae
4
- data.tar.gz: 4036bed062dd8717f6288c72c498cca4a2a91401154a23266148a42cac2aa10a
3
+ metadata.gz: 64f8eb059214e69b961c2e6a5c91565eff6372eaa64677a5d7da42f8f301d38b
4
+ data.tar.gz: c49125a5572e80d044668bcd70b6f45bd9d4c0c0109fe6ce35238fc1b630d405
5
5
  SHA512:
6
- metadata.gz: '09e7437eedd68dc0c14a98ec4c6c5c922483fc9e3924425a0478bb8d1404c36ef0531fb2adb9d2094ff7fa20633f92fb44fa8bd5588c6d7b28372371fe709af8'
7
- data.tar.gz: ac82354cffdb531261d50a12f0a54fb79bca2474fcf00b9851769ebcbe2a08c9c46fbb8edfb07bb8964142adac85e901d6773082001ffc0248746e8c448b77a1
6
+ metadata.gz: 9c17c8c39353bca7c6efc198472c7c8e088a934ea1e9181522d653580ec3dad9f9046169b38396d1b2508860fe21b3fc1fef1eb0d6d84b7e913b50e78664a8ff
7
+ data.tar.gz: a3555354a011e24848d9cbace96d5dad5db690d9a07b8cb41318b7e5820e24f04194f55b7faee4e38c8f7a521e13a2022f756802ce49c4168211135263980ba6
@@ -61,7 +61,7 @@ en:
61
61
  format:
62
62
  default: "[%{service_class_name}] Internal attribute `%{internal_name}` does not match `%{format_name}` format"
63
63
  wrong_pattern: "[%{service_class_name}] Internal attribute `%{internal_name}` does not match `%{format_name}` format"
64
- unknown: "[%{service_class_name}] Unknown `%{format_name}` format specified for output attribute `%{internal_name}`"
64
+ unknown: "[%{service_class_name}] Unknown `%{format_name}` format specified for internal attribute `%{internal_name}`"
65
65
  min:
66
66
  default: "[%{service_class_name}] Internal attribute `%{internal_name}` received value `%{value}`, which is less than `%{option_value}`"
67
67
  max:
@@ -95,6 +95,7 @@ ru:
95
95
  max:
96
96
  default: "[%{service_class_name}] Выходящий атрибут `%{output_name}` получил значение `%{value}`, которое больше `%{option_value}`"
97
97
  type:
98
- default: "[%{service_class_name}] Неправильный тип выходящего атрибута `%{output_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
99
- for_hash:
100
- wrong_element_type: "[%{service_class_name}] Неправильный тип в хеше выходящего атрибута `%{output_name}`, для `%{key_name}` ожидалось `%{expected_type}`, получено `%{given_type}`"
98
+ default_error:
99
+ default: "[%{service_class_name}] Неправильный тип выходящего атрибута `%{output_name}`, ожидалось `%{expected_type}`, получено `%{given_type}`"
100
+ for_hash:
101
+ wrong_element_type: "[%{service_class_name}] Неправильный тип в хеше выходящего атрибута `%{output_name}`, для `%{key_name}` ожидалось `%{expected_type}`, получено `%{given_type}`"
@@ -48,6 +48,8 @@ module ApplicationService
48
48
  # ]
49
49
  # )
50
50
 
51
+ # collection_mode_class_names [ActiveRecord::Relation]
52
+
51
53
  # hash_mode_class_names [CustomHash]
52
54
 
53
55
  # action_shortcuts %i[assign build create save]
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Servactory
4
+ module Configuration
5
+ module Actions
6
+ module Aliases
7
+ class Collection
8
+ extend Forwardable
9
+ def_delegators :@collection, :<<, :merge, :include?
10
+
11
+ def initialize(*)
12
+ @collection = Set.new
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Servactory
4
+ module Configuration
5
+ module Actions
6
+ module RescueHandlers
7
+ class Collection
8
+ extend Forwardable
9
+ def_delegators :@collection, :+, :detect, :reverse_each
10
+
11
+ def initialize(*)
12
+ @collection = Set.new
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Servactory
4
+ module Configuration
5
+ module Actions
6
+ module Shortcuts
7
+ class Collection
8
+ extend Forwardable
9
+ def_delegators :@collection, :<<, :each, :merge, :include?
10
+
11
+ def initialize(*)
12
+ @collection = Set.new
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Servactory
4
+ module Configuration
5
+ module CollectionMode
6
+ class ClassNamesCollection
7
+ extend Forwardable
8
+ def_delegators :@collection, :merge, :intersection
9
+
10
+ def initialize(collection)
11
+ @collection = collection
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module Maintenance
4
+ module Configuration
5
5
  module HashMode
6
6
  class ClassNamesCollection
7
7
  extend Forwardable
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Servactory
4
- module Maintenance
5
- module Attributes
4
+ module Configuration
5
+ module OptionHelpers
6
6
  class OptionHelpersCollection
7
7
  extend Forwardable
8
8
  def_delegators :@collection, :<<, :find, :merge
@@ -31,23 +31,23 @@ module Servactory
31
31
  @result_class = Servactory::Result
32
32
 
33
33
  @collection_mode_class_names =
34
- Servactory::Configuration::ClassNamesCollection.new(default_collection_mode_class_names)
34
+ Servactory::Configuration::CollectionMode::ClassNamesCollection.new(default_collection_mode_class_names)
35
35
 
36
36
  @hash_mode_class_names =
37
- Servactory::Maintenance::HashMode::ClassNamesCollection.new(default_hash_mode_class_names)
37
+ Servactory::Configuration::HashMode::ClassNamesCollection.new(default_hash_mode_class_names)
38
38
 
39
39
  @input_option_helpers =
40
- Servactory::Maintenance::Attributes::OptionHelpersCollection.new(default_input_option_helpers)
40
+ Servactory::Configuration::OptionHelpers::OptionHelpersCollection.new(default_input_option_helpers)
41
41
 
42
42
  @internal_option_helpers =
43
- Servactory::Maintenance::Attributes::OptionHelpersCollection.new(default_internal_option_helpers)
43
+ Servactory::Configuration::OptionHelpers::OptionHelpersCollection.new(default_internal_option_helpers)
44
44
 
45
45
  @output_option_helpers =
46
- Servactory::Maintenance::Attributes::OptionHelpersCollection.new(default_output_option_helpers)
46
+ Servactory::Configuration::OptionHelpers::OptionHelpersCollection.new(default_output_option_helpers)
47
47
 
48
- @action_aliases = Servactory::Actions::Aliases::Collection.new
49
- @action_shortcuts = Servactory::Actions::Shortcuts::Collection.new
50
- @action_rescue_handlers = Servactory::Actions::RescueHandlers::Collection.new
48
+ @action_aliases = Servactory::Configuration::Actions::Aliases::Collection.new
49
+ @action_shortcuts = Servactory::Configuration::Actions::Shortcuts::Collection.new
50
+ @action_rescue_handlers = Servactory::Configuration::Actions::RescueHandlers::Collection.new
51
51
 
52
52
  @i18n_root_key = "servactory"
53
53
 
@@ -11,14 +11,14 @@ module Servactory
11
11
  def info # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
12
12
  Servactory::Info::Result.new(
13
13
  inputs: collection_of_inputs.to_h do |input|
14
- work = input.class::Actor.new(input)
14
+ actor = input.class::Actor.new(input)
15
15
  inclusion = input.collection_of_options.find_by(name: :inclusion)
16
16
  must = input.collection_of_options.find_by(name: :must)
17
17
 
18
18
  [
19
19
  input.name,
20
20
  {
21
- work: work,
21
+ actor: actor,
22
22
  types: input.types,
23
23
  required: input.required,
24
24
  default: input.default,
@@ -29,14 +29,14 @@ module Servactory
29
29
  end,
30
30
 
31
31
  internals: collection_of_internals.to_h do |internal|
32
- work = internal.class::Actor.new(internal)
32
+ actor = internal.class::Actor.new(internal)
33
33
  inclusion = internal.collection_of_options.find_by(name: :inclusion)
34
34
  must = internal.collection_of_options.find_by(name: :must)
35
35
 
36
36
  [
37
37
  internal.name,
38
38
  {
39
- work: work,
39
+ actor: actor,
40
40
  types: internal.types,
41
41
  inclusion: inclusion.body,
42
42
  must: must.body
@@ -45,14 +45,14 @@ module Servactory
45
45
  end,
46
46
 
47
47
  outputs: collection_of_outputs.to_h do |output|
48
- work = output.class::Actor.new(output)
48
+ actor = output.class::Actor.new(output)
49
49
  inclusion = output.collection_of_options.find_by(name: :inclusion)
50
50
  must = output.collection_of_options.find_by(name: :must)
51
51
 
52
52
  [
53
53
  output.name,
54
54
  {
55
- work: work,
55
+ actor: actor,
56
56
  types: output.types,
57
57
  inclusion: inclusion.body,
58
58
  must: must.body
@@ -142,11 +142,14 @@ module Servactory
142
142
  value: wrong_value
143
143
  )
144
144
  elsif input_required_message.is_a?(Proc)
145
- input_work = attribute_data.fetch(:work)
145
+ service_class = Struct.new(:class_name, keyword_init: true)
146
+ service = service_class.new(class_name: described_class.name)
147
+
148
+ input_actor = attribute_data.fetch(:actor)
146
149
 
147
150
  input_required_message = input_required_message.call(
148
- service_class_name: described_class.name,
149
- input: input_work,
151
+ service: service,
152
+ input: input_actor,
150
153
  value: wrong_value
151
154
  )
152
155
  end
@@ -35,19 +35,10 @@ module Servactory
35
35
  validate_for!(attribute: attribute, values: values, option: option)
36
36
  end
37
37
 
38
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
39
38
  def validate_for!(attribute:, values:, option:)
40
39
  consists_of_types = Array(option.value)
41
40
 
42
- if !consists_of_types.include?(NilClass) && !values&.all?(&:present?) &&
43
- (
44
- (
45
- attribute.input? && (
46
- (values.blank? && attribute.required?) ||
47
- (values.present? && attribute.required?)
48
- )
49
- ) || attribute.internal? || attribute.output?
50
- )
41
+ if fails_presence_validation?(attribute: attribute, values: values, consists_of_types: consists_of_types)
51
42
  return [false, :required]
52
43
  end
53
44
 
@@ -59,7 +50,18 @@ module Servactory
59
50
 
60
51
  [false, :wrong_element_type]
61
52
  end
62
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
53
+
54
+ def fails_presence_validation?(attribute:, values:, consists_of_types:)
55
+ return false if consists_of_types.include?(NilClass)
56
+
57
+ check_present = proc { _1 && !values.all?(&:present?) }
58
+
59
+ [
60
+ check_present[attribute.input? && (attribute.required? || (attribute.optional? && values.present?))],
61
+ check_present[attribute.internal?],
62
+ check_present[attribute.output?]
63
+ ].any?
64
+ end
63
65
 
64
66
  ########################################################################
65
67
 
@@ -4,8 +4,8 @@ module Servactory
4
4
  module VERSION
5
5
  MAJOR = 2
6
6
  MINOR = 6
7
- PATCH = 0
8
- PRE = "rc5"
7
+ PATCH = 1
8
+ PRE = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0.rc5
4
+ version: 2.6.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: 2024-05-11 00:00:00.000000000 Z
11
+ date: 2024-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -245,20 +245,22 @@ files:
245
245
  - lib/generators/servactory/templates/services/application_service/result.rb
246
246
  - lib/servactory.rb
247
247
  - lib/servactory/actions/action.rb
248
- - lib/servactory/actions/aliases/collection.rb
249
248
  - lib/servactory/actions/collection.rb
250
249
  - lib/servactory/actions/dsl.rb
251
- - lib/servactory/actions/rescue_handlers/collection.rb
252
- - lib/servactory/actions/shortcuts/collection.rb
253
250
  - lib/servactory/actions/stages/collection.rb
254
251
  - lib/servactory/actions/stages/stage.rb
255
252
  - lib/servactory/actions/tools/rules.rb
256
253
  - lib/servactory/actions/tools/runner.rb
257
254
  - lib/servactory/actions/workspace.rb
258
255
  - lib/servactory/base.rb
259
- - lib/servactory/configuration/class_names_collection.rb
256
+ - lib/servactory/configuration/actions/aliases/collection.rb
257
+ - lib/servactory/configuration/actions/rescue_handlers/collection.rb
258
+ - lib/servactory/configuration/actions/shortcuts/collection.rb
259
+ - lib/servactory/configuration/collection_mode/class_names_collection.rb
260
260
  - lib/servactory/configuration/dsl.rb
261
261
  - lib/servactory/configuration/factory.rb
262
+ - lib/servactory/configuration/hash_mode/class_names_collection.rb
263
+ - lib/servactory/configuration/option_helpers/option_helpers_collection.rb
262
264
  - lib/servactory/configuration/setup.rb
263
265
  - lib/servactory/context/callable.rb
264
266
  - lib/servactory/context/dsl.rb
@@ -299,7 +301,6 @@ files:
299
301
  - lib/servactory/maintenance/attributes/define_method.rb
300
302
  - lib/servactory/maintenance/attributes/option.rb
301
303
  - lib/servactory/maintenance/attributes/option_helper.rb
302
- - lib/servactory/maintenance/attributes/option_helpers_collection.rb
303
304
  - lib/servactory/maintenance/attributes/options/registrar.rb
304
305
  - lib/servactory/maintenance/attributes/options_collection.rb
305
306
  - lib/servactory/maintenance/attributes/tools/check_errors.rb
@@ -312,7 +313,6 @@ files:
312
313
  - lib/servactory/maintenance/attributes/validations/inclusion.rb
313
314
  - lib/servactory/maintenance/attributes/validations/must.rb
314
315
  - lib/servactory/maintenance/attributes/validations/type.rb
315
- - lib/servactory/maintenance/hash_mode/class_names_collection.rb
316
316
  - lib/servactory/maintenance/validations/object_schema.rb
317
317
  - lib/servactory/maintenance/validations/types.rb
318
318
  - lib/servactory/outputs/collection.rb
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Actions
5
- module Aliases
6
- class Collection
7
- extend Forwardable
8
- def_delegators :@collection, :<<, :merge, :include?
9
-
10
- def initialize(*)
11
- @collection = Set.new
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Actions
5
- module RescueHandlers
6
- class Collection
7
- extend Forwardable
8
- def_delegators :@collection, :+, :detect, :reverse_each
9
-
10
- def initialize(*)
11
- @collection = Set.new
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Actions
5
- module Shortcuts
6
- class Collection
7
- extend Forwardable
8
- def_delegators :@collection, :<<, :each, :merge, :include?
9
-
10
- def initialize(*)
11
- @collection = Set.new
12
- end
13
- end
14
- end
15
- end
16
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Configuration
5
- class ClassNamesCollection
6
- extend Forwardable
7
- def_delegators :@collection, :merge, :intersection
8
-
9
- def initialize(collection)
10
- @collection = collection
11
- end
12
- end
13
- end
14
- end