servactory 2.0.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/servactory/actions/dsl.rb +2 -2
- data/lib/servactory/context/workspace/inputs.rb +3 -1
- data/lib/servactory/maintenance/validations/collection.rb +30 -10
- data/lib/servactory/maintenance/validations/types.rb +15 -15
- data/lib/servactory/version.rb +1 -1
- data/lib/servactory.rb +1 -1
- metadata +26 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c804a894a51f06d11d05d6b60e539d2d1540959312330726010327dab9a40ed
|
4
|
+
data.tar.gz: ab85a273c813f528a596d79efe571d3916f694b1daff5d556d652f28dcab2c98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a47f20f6976c843de99822ae9b7cd0ba17a9fc59e0d940776f8a2fe66f9145668507ba4bddb21c8a994994eab765d49f0ee656156aa4394e69c768ec831eff60
|
7
|
+
data.tar.gz: 8141c47cd8912dccc02c354cb8c8fa9026238b4c4867de25e1f32c2998aaaf2eb6e4c0ff35e765fced2d585b99f0e458993ac9dfa473674cc07007d2b2ea4033
|
@@ -68,14 +68,14 @@ module Servactory
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def method_missing(name, *args, &block)
|
71
|
-
return
|
71
|
+
return method_missing_for_action_aliases(name, *args, &block) if config.action_aliases.include?(name)
|
72
72
|
|
73
73
|
return method_missing_for_shortcuts_for_make(name, *args, &block) if config.action_shortcuts.include?(name)
|
74
74
|
|
75
75
|
super
|
76
76
|
end
|
77
77
|
|
78
|
-
def
|
78
|
+
def method_missing_for_action_aliases(_alias_name, *args, &block) # rubocop:disable Lint/UnusedMethodArgument
|
79
79
|
method_name = args.first
|
80
80
|
method_options = args.last.is_a?(Hash) ? args.pop : {}
|
81
81
|
|
@@ -40,7 +40,8 @@ module Servactory
|
|
40
40
|
|
41
41
|
private
|
42
42
|
|
43
|
-
|
43
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Lint/UnusedMethodArgument
|
44
|
+
def getter_with(name:, &block)
|
44
45
|
input_name = name.to_s.chomp("?").to_sym
|
45
46
|
input = @collection_of_inputs.find_by(name: input_name)
|
46
47
|
|
@@ -61,6 +62,7 @@ module Servactory
|
|
61
62
|
input.value
|
62
63
|
end
|
63
64
|
end
|
65
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Lint/UnusedMethodArgument
|
64
66
|
|
65
67
|
def prepare_hash_values_inside(object:, schema:) # rubocop:disable Metrics/MethodLength
|
66
68
|
return object unless object.respond_to?(:fetch)
|
@@ -10,10 +10,10 @@ module Servactory
|
|
10
10
|
new(...).validate
|
11
11
|
end
|
12
12
|
|
13
|
-
def initialize(
|
14
|
-
@
|
13
|
+
def initialize(attribute:, types:, value:)
|
14
|
+
@attribute = attribute
|
15
15
|
@types = types
|
16
|
-
@
|
16
|
+
@value = value
|
17
17
|
|
18
18
|
@errors = []
|
19
19
|
end
|
@@ -39,21 +39,41 @@ module Servactory
|
|
39
39
|
|
40
40
|
private
|
41
41
|
|
42
|
+
def validate_value!
|
43
|
+
return if unnecessary_types.empty?
|
44
|
+
|
45
|
+
add_error(
|
46
|
+
expected_type: attribute_consists_of_types.join(", "),
|
47
|
+
given_type: unnecessary_types.join(", ")
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
########################################################################
|
52
|
+
|
42
53
|
def prepared_type
|
43
54
|
@prepared_type ||= @types.fetch(0, Array)
|
44
55
|
end
|
45
56
|
|
46
|
-
def
|
47
|
-
@
|
48
|
-
|
57
|
+
def attribute_consists_of_types
|
58
|
+
@attribute_consists_of_types ||= prepared_types_from(Array(@attribute.consists_of.fetch(:type, [])))
|
59
|
+
end
|
49
60
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
61
|
+
def unnecessary_types
|
62
|
+
@unnecessary_types ||= @value&.map(&:class)&.difference(attribute_consists_of_types).presence || []
|
63
|
+
end
|
64
|
+
|
65
|
+
def prepared_types_from(types)
|
66
|
+
types.map do |type|
|
67
|
+
if type.is_a?(String)
|
68
|
+
Object.const_get(type)
|
69
|
+
else
|
70
|
+
type
|
71
|
+
end
|
54
72
|
end
|
55
73
|
end
|
56
74
|
|
75
|
+
########################################################################
|
76
|
+
|
57
77
|
def add_error(expected_type:, given_type:)
|
58
78
|
@errors << {
|
59
79
|
expected_type: expected_type,
|
@@ -92,23 +92,23 @@ module Servactory
|
|
92
92
|
collection_validator = nil
|
93
93
|
object_schema_validator = nil
|
94
94
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
)
|
95
|
+
if @attribute.collection_mode?
|
96
|
+
collection_validator = Servactory::Maintenance::Validations::Collection.validate(
|
97
|
+
attribute: @attribute,
|
98
|
+
types: @types,
|
99
|
+
value: @value
|
100
|
+
)
|
102
101
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
102
|
+
return if collection_validator.valid?
|
103
|
+
elsif @attribute.hash_mode?
|
104
|
+
object_schema_validator = Servactory::Maintenance::Validations::ObjectSchema.validate(
|
105
|
+
object: @value,
|
106
|
+
schema: @attribute.schema
|
107
|
+
)
|
109
108
|
|
110
|
-
|
111
|
-
|
109
|
+
return if object_schema_validator.valid?
|
110
|
+
else
|
111
|
+
return if prepared_types.any? do |type| # rubocop:disable Style/IfInsideElse
|
112
112
|
@value.is_a?(type)
|
113
113
|
end
|
114
114
|
end
|
data/lib/servactory/version.rb
CHANGED
data/lib/servactory.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: servactory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
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-
|
11
|
+
date: 2023-11-13 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.
|
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.
|
32
|
+
version: '7.2'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: i18n
|
29
35
|
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
|