service_actor 3.6.1 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: service_actor
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.1
4
+ version: 3.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sunny Ripert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-10 00:00:00.000000000 Z
11
+ date: 2024-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -16,146 +16,182 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '3.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '0.12'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '0.12'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubocop-lts
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '12.0'
75
+ version: '18.2'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '18.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-block_is_expected
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
76
87
  - - ">="
77
88
  - !ruby/object:Gem::Version
78
- version: 12.0.1
89
+ version: '1.0'
79
90
  type: :development
80
91
  prerelease: false
81
92
  version_requirements: !ruby/object:Gem::Requirement
82
93
  requirements:
83
- - - "~>"
94
+ - - ">="
84
95
  - !ruby/object:Gem::Version
85
- version: '12.0'
96
+ version: '1.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-gradual
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
86
101
  - - ">="
87
102
  - !ruby/object:Gem::Version
88
- version: 12.0.1
103
+ version: '0.3'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0.3'
89
111
  - !ruby/object:Gem::Dependency
90
112
  name: rubocop-rspec
91
113
  requirement: !ruby/object:Gem::Requirement
92
114
  requirements:
93
115
  - - ">="
94
116
  - !ruby/object:Gem::Version
95
- version: '0'
117
+ version: '2.0'
96
118
  type: :development
97
119
  prerelease: false
98
120
  version_requirements: !ruby/object:Gem::Requirement
99
121
  requirements:
100
122
  - - ">="
101
123
  - !ruby/object:Gem::Version
102
- version: '0'
124
+ version: '2.0'
103
125
  - !ruby/object:Gem::Dependency
104
126
  name: rubocop-performance
105
127
  requirement: !ruby/object:Gem::Requirement
106
128
  requirements:
107
129
  - - ">="
108
130
  - !ruby/object:Gem::Version
109
- version: '0'
131
+ version: '1.0'
110
132
  type: :development
111
133
  prerelease: false
112
134
  version_requirements: !ruby/object:Gem::Requirement
113
135
  requirements:
114
136
  - - ">="
115
137
  - !ruby/object:Gem::Version
116
- version: '0'
138
+ version: '1.0'
117
139
  - !ruby/object:Gem::Dependency
118
140
  name: rubocop-rake
119
141
  requirement: !ruby/object:Gem::Requirement
120
142
  requirements:
121
143
  - - ">="
122
144
  - !ruby/object:Gem::Version
123
- version: '0'
145
+ version: '0.1'
124
146
  type: :development
125
147
  prerelease: false
126
148
  version_requirements: !ruby/object:Gem::Requirement
127
149
  requirements:
128
150
  - - ">="
129
151
  - !ruby/object:Gem::Version
130
- version: '0'
152
+ version: '0.1'
131
153
  - !ruby/object:Gem::Dependency
132
154
  name: code-scanning-rubocop
133
155
  requirement: !ruby/object:Gem::Requirement
134
156
  requirements:
135
157
  - - ">="
136
158
  - !ruby/object:Gem::Version
137
- version: '0'
159
+ version: '0.6'
138
160
  type: :development
139
161
  prerelease: false
140
162
  version_requirements: !ruby/object:Gem::Requirement
141
163
  requirements:
142
164
  - - ">="
143
165
  - !ruby/object:Gem::Version
144
- version: '0'
166
+ version: '0.6'
145
167
  - !ruby/object:Gem::Dependency
146
168
  name: interactor
147
169
  requirement: !ruby/object:Gem::Requirement
148
170
  requirements:
149
171
  - - ">="
150
172
  - !ruby/object:Gem::Version
151
- version: '0'
173
+ version: '3.0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '3.0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: simplecov
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0.0'
152
188
  type: :development
153
189
  prerelease: false
154
190
  version_requirements: !ruby/object:Gem::Requirement
155
191
  requirements:
156
192
  - - ">="
157
193
  - !ruby/object:Gem::Version
158
- version: '0'
194
+ version: '0.0'
159
195
  description: Service objects for your application logic
160
196
  email:
161
197
  - sunny@sunfox.org
@@ -169,11 +205,11 @@ files:
169
205
  - README.md
170
206
  - lib/service_actor.rb
171
207
  - lib/service_actor/argument_error.rb
208
+ - lib/service_actor/arguments_validator.rb
172
209
  - lib/service_actor/attributable.rb
173
210
  - lib/service_actor/base.rb
174
211
  - lib/service_actor/checkable.rb
175
212
  - lib/service_actor/checks/base.rb
176
- - lib/service_actor/checks/default_check.rb
177
213
  - lib/service_actor/checks/inclusion_check.rb
178
214
  - lib/service_actor/checks/must_check.rb
179
215
  - lib/service_actor/checks/nil_check.rb
@@ -204,7 +240,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
204
240
  requirements:
205
241
  - - ">="
206
242
  - !ruby/object:Gem::Version
207
- version: '2.4'
243
+ version: '2.7'
208
244
  required_rubygems_version: !ruby/object:Gem::Requirement
209
245
  requirements:
210
246
  - - ">="
@@ -1,90 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Adds the `default:` option to inputs. Accepts regular values and lambdas.
4
- # If no default is set and the value has not been given, raises an error.
5
- #
6
- # Example:
7
- #
8
- # class MultiplyThing < Actor
9
- # input :counter, default: 1
10
- # input :multiplier, default: -> { rand(1..10) }
11
- # end
12
- #
13
- # class MultiplyThing < Actor
14
- # input :counter,
15
- # default: {
16
- # is: 1,
17
- # message: "Counter is required"
18
- # }
19
- #
20
- # input :multiplier,
21
- # default: {
22
- # is: -> { rand(1..10) },
23
- # message: (lambda do |input_key:, actor:|
24
- # "Input \"#{input_key}\" is required"
25
- # end)
26
- # }
27
- # end
28
- class ServiceActor::Checks::DefaultCheck < ServiceActor::Checks::Base
29
- def self.check(result:, input_key:, input_options:, actor:, **)
30
- new(
31
- result: result,
32
- input_key: input_key,
33
- input_options: input_options,
34
- actor: actor,
35
- ).check
36
- end
37
-
38
- def initialize(result:, input_key:, input_options:, actor:)
39
- super()
40
-
41
- @result = result
42
- @input_key = input_key
43
- @input_options = input_options
44
- @actor = actor
45
- end
46
-
47
- def check # rubocop:disable Metrics/MethodLength
48
- return if @result.key?(@input_key)
49
-
50
- unless @input_options.key?(:default)
51
- return add_argument_error(
52
- "The \"#{@input_key}\" input on \"#{@actor}\" is missing",
53
- )
54
- end
55
-
56
- default = @input_options[:default]
57
-
58
- if default.is_a?(Hash)
59
- default_for_advanced_mode_with(default)
60
- else
61
- default_for_normal_mode_with(default)
62
- end
63
-
64
- nil
65
- end
66
-
67
- private
68
-
69
- def default_for_normal_mode_with(default)
70
- default = default.call if default.is_a?(Proc)
71
- @result[@input_key] = default
72
- end
73
-
74
- def default_for_advanced_mode_with(content)
75
- default, message = content.values_at(:is, :message)
76
-
77
- unless default
78
- return add_argument_error(
79
- message,
80
- input_key: @input_key,
81
- actor: self.class,
82
- )
83
- end
84
-
85
- default = default.call if default.is_a?(Proc)
86
- @result[@input_key] = default
87
-
88
- message.call(@input_key, self.class)
89
- end
90
- end