servactory 1.8.4 → 1.8.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/servactory/context/workspace/inputs.rb +8 -3
- data/lib/servactory/context/workspace/internals.rb +9 -2
- data/lib/servactory/context/workspace/outputs.rb +9 -2
- data/lib/servactory/inputs/input.rb +1 -1
- data/lib/servactory/methods/dsl.rb +8 -0
- data/lib/servactory/methods/stage.rb +2 -1
- data/lib/servactory/methods/tools/runner.rb +3 -4
- data/lib/servactory/outputs/dsl.rb +0 -1
- data/lib/servactory/result.rb +1 -0
- data/lib/servactory/test_kit/fake_type.rb +1 -1
- data/lib/servactory/utils.rb +36 -1
- data/lib/servactory/version.rb +1 -1
- metadata +2 -4
- data/lib/servactory/outputs/tools/conflicts.rb +0 -38
- data/lib/servactory/outputs/workspace.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63d469613e34fcd13e27dc8fb62fa6c36fc25cf9b9e35f5b21af30013ac75993
|
4
|
+
data.tar.gz: e3edd5a0bfbd2b889e81be1aeeaa836f80c6e9925c65e5f4ed09ce2a35d44673
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 774bb94eb10a8695cde168e8cd7bc224ebc65804e2092c617dacf471612d1b3980dbc2f6d80b0418f9885a4697587c9d2d12c4172b176d79de4d6114f5198aed
|
7
|
+
data.tar.gz: 2987a6379e4404e1757e4cef6749ae3e5fd8b98712d23e630b1b0a5bde5cdac8232046089d59cc1e642b7a540a9def431dfc6708e3696a14b517ce22cd1025f7
|
@@ -24,8 +24,9 @@ module Servactory
|
|
24
24
|
|
25
25
|
private
|
26
26
|
|
27
|
-
def getter_with(name:, &block) # rubocop:disable Lint/UnusedMethodArgument
|
28
|
-
|
27
|
+
def getter_with(name:, &block) # rubocop:disable Metrics/MethodLength, Lint/UnusedMethodArgument, Metrics/AbcSize
|
28
|
+
input_name = name.to_s.chomp("?").to_sym
|
29
|
+
input = @collection_of_inputs.find_by(name: input_name)
|
29
30
|
|
30
31
|
return yield if input.nil?
|
31
32
|
|
@@ -35,7 +36,11 @@ module Servactory
|
|
35
36
|
input_prepare = input.prepare.fetch(:in, nil)
|
36
37
|
input_value = input_prepare.call(value: input_value) if input_prepare.present?
|
37
38
|
|
38
|
-
|
39
|
+
if name.to_s.end_with?("?")
|
40
|
+
Servactory::Utils.query_attribute(input_value)
|
41
|
+
else
|
42
|
+
input_value
|
43
|
+
end
|
39
44
|
end
|
40
45
|
end
|
41
46
|
end
|
@@ -42,11 +42,18 @@ module Servactory
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def getter_with(name:, &block) # rubocop:disable Lint/UnusedMethodArgument
|
45
|
-
|
45
|
+
internal_name = name.to_s.chomp("?").to_sym
|
46
|
+
internal = @collection_of_internals.find_by(name: internal_name)
|
46
47
|
|
47
48
|
return yield if internal.nil?
|
48
49
|
|
49
|
-
@context.send(:fetch_internal, internal.name)
|
50
|
+
internal_value = @context.send(:fetch_internal, internal.name)
|
51
|
+
|
52
|
+
if name.to_s.end_with?("?")
|
53
|
+
Servactory::Utils.query_attribute(internal_value)
|
54
|
+
else
|
55
|
+
internal_value
|
56
|
+
end
|
50
57
|
end
|
51
58
|
end
|
52
59
|
end
|
@@ -42,11 +42,18 @@ module Servactory
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def getter_with(name:, &block) # rubocop:disable Lint/UnusedMethodArgument
|
45
|
-
|
45
|
+
output_name = name.to_s.chomp("?").to_sym
|
46
|
+
output = @collection_of_outputs.find_by(name: output_name)
|
46
47
|
|
47
48
|
return yield if output.nil?
|
48
49
|
|
49
|
-
@context.send(:fetch_output, output.name)
|
50
|
+
output_value = @context.send(:fetch_output, output.name)
|
51
|
+
|
52
|
+
if name.to_s.end_with?("?")
|
53
|
+
Servactory::Utils.query_attribute(output_value)
|
54
|
+
else
|
55
|
+
output_value
|
56
|
+
end
|
50
57
|
end
|
51
58
|
end
|
52
59
|
end
|
@@ -42,6 +42,14 @@ module Servactory
|
|
42
42
|
def only_if(condition)
|
43
43
|
return if @current_stage.blank?
|
44
44
|
|
45
|
+
@current_stage.is_condition_opposite = false
|
46
|
+
@current_stage.condition = condition
|
47
|
+
end
|
48
|
+
|
49
|
+
def only_unless(condition)
|
50
|
+
return if @current_stage.blank?
|
51
|
+
|
52
|
+
@current_stage.is_condition_opposite = true
|
45
53
|
@current_stage.condition = condition
|
46
54
|
end
|
47
55
|
|
@@ -57,12 +57,11 @@ module Servactory
|
|
57
57
|
|
58
58
|
def unnecessary_for_stage?(stage)
|
59
59
|
condition = stage.condition
|
60
|
-
|
60
|
+
is_condition_opposite = stage.is_condition_opposite
|
61
61
|
|
62
|
-
result = prepare_condition_for(condition)
|
62
|
+
result = prepare_condition_for(condition)
|
63
63
|
|
64
|
-
|
65
|
-
result
|
64
|
+
is_condition_opposite ? !result : result
|
66
65
|
end
|
67
66
|
|
68
67
|
def unnecessary_for_make?(make_method)
|
data/lib/servactory/result.rb
CHANGED
@@ -26,6 +26,7 @@ module Servactory
|
|
26
26
|
define_singleton_method(:failure?) { false }
|
27
27
|
|
28
28
|
@context.send(:service_storage).fetch(:outputs).each_pair do |key, value|
|
29
|
+
define_singleton_method(:"#{key}?") { Servactory::Utils.query_attribute(value) }
|
29
30
|
define_singleton_method(key) { value }
|
30
31
|
end
|
31
32
|
|
data/lib/servactory/utils.rb
CHANGED
@@ -4,16 +4,51 @@ module Servactory
|
|
4
4
|
module Utils
|
5
5
|
module_function
|
6
6
|
|
7
|
+
FALSE_VALUES = [
|
8
|
+
false,
|
9
|
+
nil, "",
|
10
|
+
"0", :"0", 0,
|
11
|
+
"f", :f,
|
12
|
+
"F", :F,
|
13
|
+
"false", :false, # rubocop:disable Lint/BooleanSymbol
|
14
|
+
"FALSE", :FALSE,
|
15
|
+
"off", :off,
|
16
|
+
"OFF", :OFF
|
17
|
+
].to_set.freeze
|
18
|
+
|
19
|
+
private_constant :FALSE_VALUES
|
20
|
+
|
7
21
|
# @param value [#to_s]
|
8
22
|
# @return [Boolean]
|
9
23
|
def true?(value)
|
10
|
-
|
24
|
+
!FALSE_VALUES.include?(value)
|
11
25
|
end
|
12
26
|
|
27
|
+
# @param value [#to_s]
|
28
|
+
# @return [Boolean]
|
13
29
|
def value_present?(value)
|
14
30
|
!value.nil? && (
|
15
31
|
value.respond_to?(:empty?) ? !value.empty? : true
|
16
32
|
)
|
17
33
|
end
|
34
|
+
|
35
|
+
# NOTE: Based on `query_cast_attribute` from ActiveRecord:
|
36
|
+
# https://github.com/rails/rails/blob/main/activerecord/lib/active_record/attribute_methods/query.rb
|
37
|
+
# @param value [#to_s]
|
38
|
+
# @return [Boolean]
|
39
|
+
def query_attribute(value) # rubocop:disable Metrics/MethodLength
|
40
|
+
case value
|
41
|
+
when true then true
|
42
|
+
when false, nil then false
|
43
|
+
else
|
44
|
+
if value.is_a?(Numeric) || (value.respond_to?(:match?) && !value.match?(/[^0-9]/))
|
45
|
+
!value.to_i.zero?
|
46
|
+
else
|
47
|
+
return false if FALSE_VALUES.include?(value)
|
48
|
+
|
49
|
+
!value.blank?
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
18
53
|
end
|
19
54
|
end
|
data/lib/servactory/version.rb
CHANGED
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: 1.8.
|
4
|
+
version: 1.8.6
|
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-
|
11
|
+
date: 2023-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -244,10 +244,8 @@ files:
|
|
244
244
|
- lib/servactory/outputs/collection.rb
|
245
245
|
- lib/servactory/outputs/dsl.rb
|
246
246
|
- lib/servactory/outputs/output.rb
|
247
|
-
- lib/servactory/outputs/tools/conflicts.rb
|
248
247
|
- lib/servactory/outputs/validations/base.rb
|
249
248
|
- lib/servactory/outputs/validations/type.rb
|
250
|
-
- lib/servactory/outputs/workspace.rb
|
251
249
|
- lib/servactory/result.rb
|
252
250
|
- lib/servactory/test_kit/fake_type.rb
|
253
251
|
- lib/servactory/test_kit/result.rb
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module Outputs
|
5
|
-
module Tools
|
6
|
-
class Conflicts
|
7
|
-
def self.validate!(...)
|
8
|
-
new(...).validate!
|
9
|
-
end
|
10
|
-
|
11
|
-
def initialize(context, collection_of_outputs, collection_of_internals)
|
12
|
-
@context = context
|
13
|
-
@collection_of_outputs = collection_of_outputs
|
14
|
-
@collection_of_internals = collection_of_internals
|
15
|
-
end
|
16
|
-
|
17
|
-
def validate!
|
18
|
-
return if overlapping_attributes.empty?
|
19
|
-
|
20
|
-
message_text = I18n.t(
|
21
|
-
"servactory.outputs.tools.conflicts.error",
|
22
|
-
service_class_name: @context.class.name,
|
23
|
-
overlapping_attributes: overlapping_attributes.join(", ")
|
24
|
-
)
|
25
|
-
|
26
|
-
raise Servactory.configuration.output_error_class.new(message: message_text)
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def overlapping_attributes
|
32
|
-
@overlapping_attributes ||=
|
33
|
-
@collection_of_outputs.names.intersection(@collection_of_internals.names)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Servactory
|
4
|
-
module Outputs
|
5
|
-
module Workspace
|
6
|
-
def call!(collection_of_internals:, collection_of_outputs:, **)
|
7
|
-
super
|
8
|
-
|
9
|
-
Tools::Conflicts.validate!(self, collection_of_outputs, collection_of_internals)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|