servactory 2.13.2 → 2.14.0
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/lib/generators/servactory/templates/services/application_service/base.rb +9 -1
- data/lib/servactory/actions/dsl.rb +29 -6
- data/lib/servactory/configuration/actions/shortcuts/collection.rb +12 -2
- data/lib/servactory/configuration/collection_mode/class_names_collection.rb +1 -1
- data/lib/servactory/configuration/factory.rb +15 -3
- data/lib/servactory/configuration/hash_mode/class_names_collection.rb +1 -1
- data/lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/valid_with_matcher.rb +1 -1
- data/lib/servactory/tool_kit/dynamic_options/consists_of.rb +1 -1
- data/lib/servactory/tool_kit/dynamic_options/inclusion.rb +5 -5
- data/lib/servactory/tool_kit/dynamic_options/schema.rb +2 -2
- data/lib/servactory/utils.rb +8 -0
- data/lib/servactory/version.rb +2 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f6718e3b5e71152099847ec1713940116c44a7641dbc3c63d7a4ef60478ef3c
|
4
|
+
data.tar.gz: 9ecd3809f2792504bb5f2694b4ceb9969e5bd4ad386dccfbdb5af6e0a8e55a9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1810233557cfb71509fcf04e618295cde0ab190511b8bb50569cd098cf359c606730de1299d89eaaeec8e6c55d65b901fc7bbea895e46532a1a3f825d5bfcc6f
|
7
|
+
data.tar.gz: 4011679f170547c0ee3b4e1c527dfadccb961185446d4386c3a9ff6da81da9a6da683d7d5102ca339a5609c644d61ded644321115cc1697368451301c53a8078
|
@@ -52,7 +52,15 @@ module ApplicationService
|
|
52
52
|
|
53
53
|
# hash_mode_class_names [CustomHash]
|
54
54
|
|
55
|
-
# action_shortcuts
|
55
|
+
# action_shortcuts(
|
56
|
+
# %i[assign build create save],
|
57
|
+
# {
|
58
|
+
# restrict: {
|
59
|
+
# prefix: :create,
|
60
|
+
# suffix: :restriction
|
61
|
+
# }
|
62
|
+
# }
|
63
|
+
# )
|
56
64
|
|
57
65
|
# action_aliases %i[do_it!]
|
58
66
|
|
@@ -87,14 +87,16 @@ module Servactory
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def method_missing(name, ...)
|
90
|
-
return method_missing_for_action_aliases(
|
90
|
+
return method_missing_for_action_aliases(...) if config.action_aliases.include?(name)
|
91
91
|
|
92
|
-
|
92
|
+
if (action_shortcut = config.action_shortcuts.find_by(name:)).present?
|
93
|
+
return method_missing_for_shortcuts_for_make(action_shortcut, ...)
|
94
|
+
end
|
93
95
|
|
94
96
|
super
|
95
97
|
end
|
96
98
|
|
97
|
-
def method_missing_for_action_aliases(
|
99
|
+
def method_missing_for_action_aliases(*args)
|
98
100
|
method_name = args.first
|
99
101
|
method_options = args.last.is_a?(Hash) ? args.pop : {}
|
100
102
|
|
@@ -103,16 +105,37 @@ module Servactory
|
|
103
105
|
make(method_name, **method_options)
|
104
106
|
end
|
105
107
|
|
106
|
-
def method_missing_for_shortcuts_for_make(
|
108
|
+
def method_missing_for_shortcuts_for_make(action_shortcut, *args)
|
107
109
|
method_options = args.last.is_a?(Hash) ? args.pop : {}
|
108
110
|
|
109
111
|
args.each do |method_name|
|
110
|
-
|
112
|
+
full_method_name = build_method_name_for_shortcuts_for_make_with(
|
113
|
+
method_name.to_s,
|
114
|
+
action_shortcut
|
115
|
+
)
|
116
|
+
|
117
|
+
make(full_method_name, **method_options)
|
111
118
|
end
|
112
119
|
end
|
113
120
|
|
121
|
+
def build_method_name_for_shortcuts_for_make_with(method_name, action_shortcut)
|
122
|
+
prefix = action_shortcut.fetch(:prefix)
|
123
|
+
suffix = action_shortcut.fetch(:suffix)
|
124
|
+
|
125
|
+
method_body, special_char =
|
126
|
+
Servactory::Utils.extract_special_character_from(method_name.to_s)
|
127
|
+
|
128
|
+
parts = []
|
129
|
+
parts << "#{prefix}_" if prefix.present?
|
130
|
+
parts << method_body
|
131
|
+
parts << "_#{suffix}" if suffix.present?
|
132
|
+
parts << special_char if special_char
|
133
|
+
|
134
|
+
parts.join.to_sym
|
135
|
+
end
|
136
|
+
|
114
137
|
def respond_to_missing?(name, *)
|
115
|
-
config.action_aliases.include?(name) || config.action_shortcuts.include?(name) || super
|
138
|
+
config.action_aliases.include?(name) || config.action_shortcuts.shortcuts.include?(name) || super
|
116
139
|
end
|
117
140
|
|
118
141
|
def next_position
|
@@ -6,10 +6,20 @@ module Servactory
|
|
6
6
|
module Shortcuts
|
7
7
|
class Collection
|
8
8
|
extend Forwardable
|
9
|
-
def_delegators :@collection,
|
9
|
+
def_delegators :@collection, :merge!, :fetch, :keys
|
10
10
|
|
11
11
|
def initialize(*)
|
12
|
-
@collection =
|
12
|
+
@collection = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
alias merge merge!
|
16
|
+
|
17
|
+
def shortcuts
|
18
|
+
keys
|
19
|
+
end
|
20
|
+
|
21
|
+
def find_by(name:)
|
22
|
+
fetch(name, nil)
|
13
23
|
end
|
14
24
|
end
|
15
25
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Servactory
|
4
4
|
module Configuration
|
5
|
-
class Factory
|
5
|
+
class Factory # rubocop:disable Metrics/ClassLength
|
6
6
|
def initialize(config)
|
7
7
|
@config = config
|
8
8
|
end
|
@@ -63,8 +63,20 @@ module Servactory
|
|
63
63
|
@config.action_aliases.merge(action_aliases)
|
64
64
|
end
|
65
65
|
|
66
|
-
def action_shortcuts(
|
67
|
-
|
66
|
+
def action_shortcuts(array, hash = {}) # rubocop:disable Metrics/MethodLength
|
67
|
+
prepared = array.to_h do |action_shortcut|
|
68
|
+
[
|
69
|
+
action_shortcut,
|
70
|
+
{
|
71
|
+
prefix: action_shortcut,
|
72
|
+
suffix: nil
|
73
|
+
}
|
74
|
+
]
|
75
|
+
end
|
76
|
+
|
77
|
+
prepared = prepared.merge(hash)
|
78
|
+
|
79
|
+
@config.action_shortcuts.merge(prepared)
|
68
80
|
end
|
69
81
|
|
70
82
|
def i18n_root_key(value)
|
data/lib/servactory/test_kit/rspec/matchers/have_service_input_matchers/valid_with_matcher.rb
CHANGED
@@ -129,7 +129,7 @@ module Servactory
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def failure_inclusion_passes? # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
132
|
-
input_inclusion_in = attribute_data.
|
132
|
+
input_inclusion_in = attribute_data.dig(:inclusion, :in)
|
133
133
|
|
134
134
|
return true if input_inclusion_in.blank?
|
135
135
|
|
@@ -28,7 +28,7 @@ module Servactory
|
|
28
28
|
|
29
29
|
def common_condition_with(attribute:, value:, option:)
|
30
30
|
return true if option.value == false
|
31
|
-
return [false, :wrong_type]
|
31
|
+
return [false, :wrong_type] unless @collection_mode_class_names.intersect?(attribute.types)
|
32
32
|
|
33
33
|
values = value.respond_to?(:flatten) ? value&.flatten : value
|
34
34
|
|
@@ -10,14 +10,14 @@ module Servactory
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def condition_for_input_with(input:, value:, option:)
|
13
|
-
if input.required? || (
|
14
|
-
input.optional? && !input.default.nil?
|
15
|
-
) || (
|
16
|
-
input.optional? && !value.nil?
|
17
|
-
) # do
|
13
|
+
if input.required? || (input.optional? && !value.nil?) # rubocop:disable Style/IfUnlessModifier
|
18
14
|
return option.value.include?(value)
|
19
15
|
end
|
20
16
|
|
17
|
+
if input.optional? && value.nil? && !input.default.nil? # rubocop:disable Style/IfUnlessModifier
|
18
|
+
return option.value.include?(input.default)
|
19
|
+
end
|
20
|
+
|
21
21
|
true
|
22
22
|
end
|
23
23
|
|
@@ -29,9 +29,9 @@ module Servactory
|
|
29
29
|
common_condition_with(attribute: output, value:, option:)
|
30
30
|
end
|
31
31
|
|
32
|
-
def common_condition_with(attribute:, value:, option:) # rubocop:disable Metrics/
|
32
|
+
def common_condition_with(attribute:, value:, option:) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
33
33
|
return true if option.value == false
|
34
|
-
return [false, :wrong_type]
|
34
|
+
return [false, :wrong_type] unless @default_hash_mode_class_names.intersect?(attribute.types)
|
35
35
|
|
36
36
|
if value.blank? && ((attribute.input? && attribute.optional?) || attribute.internal? || attribute.output?)
|
37
37
|
return true
|
data/lib/servactory/utils.rb
CHANGED
data/lib/servactory/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: servactory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Sokolov
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-04-21 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activesupport
|
@@ -103,14 +103,14 @@ dependencies:
|
|
103
103
|
name: appraisal
|
104
104
|
requirement: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- - "
|
106
|
+
- - ">="
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '2.5'
|
109
109
|
type: :development
|
110
110
|
prerelease: false
|
111
111
|
version_requirements: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
|
-
- - "
|
113
|
+
- - ">="
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '2.5'
|
116
116
|
- !ruby/object:Gem::Dependency
|
@@ -189,14 +189,14 @@ dependencies:
|
|
189
189
|
requirements:
|
190
190
|
- - ">="
|
191
191
|
- !ruby/object:Gem::Version
|
192
|
-
version: '0.
|
192
|
+
version: '0.9'
|
193
193
|
type: :development
|
194
194
|
prerelease: false
|
195
195
|
version_requirements: !ruby/object:Gem::Requirement
|
196
196
|
requirements:
|
197
197
|
- - ">="
|
198
198
|
- !ruby/object:Gem::Version
|
199
|
-
version: '0.
|
199
|
+
version: '0.9'
|
200
200
|
- !ruby/object:Gem::Dependency
|
201
201
|
name: steep
|
202
202
|
requirement: !ruby/object:Gem::Requirement
|
@@ -347,7 +347,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
347
347
|
requirements:
|
348
348
|
- - ">="
|
349
349
|
- !ruby/object:Gem::Version
|
350
|
-
version: 3.
|
350
|
+
version: '3.2'
|
351
351
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
352
352
|
requirements:
|
353
353
|
- - ">="
|