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.
- checksums.yaml +4 -4
- data/config/locales/en.yml +6 -6
- data/config/locales/ru.yml +6 -6
- data/lib/servactory/configuration/option_helpers/option_helpers_collection.rb +5 -1
- data/lib/servactory/configuration/setup.rb +6 -3
- data/lib/servactory/context/warehouse/base.rb +25 -0
- data/lib/servactory/context/warehouse/inputs.rb +56 -0
- data/lib/servactory/context/warehouse/internals.rb +10 -0
- data/lib/servactory/context/warehouse/outputs.rb +12 -0
- data/lib/servactory/context/warehouse/setup.rb +73 -0
- data/lib/servactory/context/workspace/inputs.rb +3 -3
- data/lib/servactory/context/workspace/internals.rb +2 -2
- data/lib/servactory/context/workspace/outputs.rb +2 -2
- data/lib/servactory/context/workspace.rb +2 -2
- data/lib/servactory/info/builder.rb +103 -0
- data/lib/servactory/info/dsl.rb +8 -51
- data/lib/servactory/info/result.rb +4 -4
- data/lib/servactory/inputs/input.rb +8 -5
- data/lib/servactory/inputs/tools/unnecessary.rb +1 -1
- data/lib/servactory/inputs/tools/validation.rb +1 -1
- data/lib/servactory/inputs/tools/{store.rb → warehouse.rb} +2 -2
- data/lib/servactory/inputs/workspace.rb +1 -1
- data/lib/servactory/internals/internal.rb +5 -4
- data/lib/servactory/maintenance/attributes/option_helper.rb +8 -2
- data/lib/servactory/maintenance/attributes/options/registrar.rb +1 -34
- data/lib/servactory/outputs/output.rb +5 -4
- data/lib/servactory/result.rb +1 -1
- data/lib/servactory/test_kit/result.rb +3 -3
- data/lib/servactory/test_kit/rspec/matchers/have_service_attribute_matchers/consists_of_matcher.rb +20 -8
- data/lib/servactory/test_kit/rspec/matchers/have_service_attribute_matchers/inclusion_matcher.rb +23 -4
- data/lib/servactory/test_kit/rspec/matchers/have_service_input_matcher.rb +4 -1
- data/lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/valid_with_matcher.rb +5 -4
- data/lib/servactory/test_kit/rspec/matchers/have_service_internal_matcher.rb +4 -1
- data/lib/servactory/tool_kit/dynamic_options/inclusion.rb +63 -0
- data/lib/servactory/tool_kit/dynamic_options/must.rb +5 -1
- data/lib/servactory/version.rb +2 -2
- metadata +12 -8
- data/lib/servactory/context/store.rb +0 -71
- data/lib/servactory/maintenance/attributes/translator/inclusion.rb +0 -26
- 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
|