servactory 2.11.0 → 2.12.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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/config/locales/en.yml +6 -6
  3. data/config/locales/ru.yml +6 -6
  4. data/lib/servactory/configuration/option_helpers/option_helpers_collection.rb +5 -1
  5. data/lib/servactory/configuration/setup.rb +6 -3
  6. data/lib/servactory/context/warehouse/base.rb +25 -0
  7. data/lib/servactory/context/warehouse/inputs.rb +56 -0
  8. data/lib/servactory/context/warehouse/internals.rb +10 -0
  9. data/lib/servactory/context/warehouse/outputs.rb +12 -0
  10. data/lib/servactory/context/warehouse/setup.rb +73 -0
  11. data/lib/servactory/context/workspace/inputs.rb +3 -3
  12. data/lib/servactory/context/workspace/internals.rb +2 -2
  13. data/lib/servactory/context/workspace/outputs.rb +2 -2
  14. data/lib/servactory/context/workspace.rb +2 -2
  15. data/lib/servactory/info/builder.rb +103 -0
  16. data/lib/servactory/info/dsl.rb +8 -51
  17. data/lib/servactory/info/result.rb +4 -4
  18. data/lib/servactory/inputs/input.rb +8 -5
  19. data/lib/servactory/inputs/tools/unnecessary.rb +1 -1
  20. data/lib/servactory/inputs/tools/validation.rb +1 -1
  21. data/lib/servactory/inputs/tools/{store.rb → warehouse.rb} +2 -2
  22. data/lib/servactory/inputs/workspace.rb +1 -1
  23. data/lib/servactory/internals/internal.rb +5 -4
  24. data/lib/servactory/maintenance/attributes/option_helper.rb +8 -2
  25. data/lib/servactory/maintenance/attributes/options/registrar.rb +1 -34
  26. data/lib/servactory/outputs/output.rb +5 -4
  27. data/lib/servactory/result.rb +1 -1
  28. data/lib/servactory/test_kit/result.rb +3 -3
  29. data/lib/servactory/test_kit/rspec/matchers/have_service_attribute_matchers/consists_of_matcher.rb +20 -8
  30. data/lib/servactory/test_kit/rspec/matchers/have_service_attribute_matchers/inclusion_matcher.rb +23 -4
  31. data/lib/servactory/test_kit/rspec/matchers/have_service_input_matcher.rb +4 -1
  32. data/lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/valid_with_matcher.rb +5 -4
  33. data/lib/servactory/test_kit/rspec/matchers/have_service_internal_matcher.rb +4 -1
  34. data/lib/servactory/tool_kit/dynamic_options/inclusion.rb +63 -0
  35. data/lib/servactory/tool_kit/dynamic_options/must.rb +5 -1
  36. data/lib/servactory/version.rb +2 -2
  37. metadata +12 -8
  38. data/lib/servactory/context/store.rb +0 -71
  39. data/lib/servactory/maintenance/attributes/translator/inclusion.rb +0 -26
  40. data/lib/servactory/maintenance/attributes/validations/inclusion.rb +0 -63
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Servactory
4
- module Maintenance
5
- module Attributes
6
- module Validations
7
- class Inclusion < Base
8
- def self.check(context:, attribute:, value:, check_key:, **)
9
- return unless should_be_checked_for?(attribute, value, check_key)
10
-
11
- new(context:, attribute:, value:).check
12
- end
13
-
14
- # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
15
- def self.should_be_checked_for?(attribute, value, check_key)
16
- check_key == :inclusion && (
17
- (
18
- attribute.input? && (
19
- attribute.required? || (
20
- attribute.optional? && !attribute.default.nil?
21
- ) || (
22
- attribute.optional? && !value.nil?
23
- )
24
- )
25
- ) || attribute.internal? || attribute.output?
26
- )
27
- end
28
- # rubocop:enable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
29
-
30
- ##########################################################################
31
-
32
- def initialize(context:, attribute:, value:)
33
- super()
34
-
35
- @context = context
36
- @attribute = attribute
37
- @value = value
38
- end
39
-
40
- def check
41
- inclusion_in, message = @attribute.inclusion.values_at(:in, :message)
42
-
43
- return if inclusion_in.nil?
44
- return if inclusion_in.include?(@value)
45
-
46
- add_error_with(message)
47
- end
48
-
49
- private
50
-
51
- def add_error_with(message)
52
- add_error(
53
- message: message.presence || Servactory::Maintenance::Attributes::Translator::Inclusion.default_message,
54
- service: @context.send(:servactory_service_info),
55
- **Servactory::Utils.fetch_hash_with_desired_attribute(@attribute),
56
- value: @value
57
- )
58
- end
59
- end
60
- end
61
- end
62
- end
63
- end