use_cases 2.0.7 → 3.0.1
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/.ruby-version +1 -0
- data/Gemfile +8 -9
- data/Gemfile.lock +59 -50
- data/lib/use_cases/module_optins/locked.rb +4 -4
- data/lib/use_cases/module_optins/transactional.rb +1 -1
- data/lib/use_cases/module_optins/validated.rb +2 -2
- data/lib/use_cases/step_adapters/abstract.rb +4 -5
- data/lib/use_cases/step_adapters/tee.rb +1 -1
- data/lib/use_cases/version.rb +1 -1
- data/use_cases.gemspec +3 -3
- metadata +12 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7024d7b5fb5fefe4415f79eb2e81b101a8d9b2ffcf25babf81448f0456f013cf
|
|
4
|
+
data.tar.gz: e9157f8e7b58dbfe6bdb5b23165f7b47a05634cc2fde3a6f88fd8d5aa2b84b3d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9fff1b2f8fbcde7e4218bb0745c80dd94f1ddadaa624eb0aa7a23ae22f2986bdaf23dadf6008d090a1a72695a7b56513ff4427e7cc30281f256bc9899f08e53f
|
|
7
|
+
data.tar.gz: e0b84b5934b3f891e550a21d6e53a4295df76e6d827fb734b8e05c1968dee9b03112d2ef2149fa28c01bbc0df6060ad415ffd0db56b60bfe56c17149112e588a
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.0.5
|
data/Gemfile
CHANGED
|
@@ -5,16 +5,15 @@ source "https://rubygems.org"
|
|
|
5
5
|
# Specify your gem's dependencies in use_cases.gemspec
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
|
-
gem "activesupport"
|
|
9
|
-
gem "dry-
|
|
10
|
-
gem "dry-
|
|
11
|
-
gem "dry-
|
|
12
|
-
gem "dry-validation"
|
|
8
|
+
gem "activesupport", "~> 6.1.7"
|
|
9
|
+
gem "dry-matcher", "~> 0.8.1"
|
|
10
|
+
gem "dry-monads", "~> 1.0.0"
|
|
11
|
+
gem "dry-validation", "~> 1.8.1"
|
|
13
12
|
|
|
14
13
|
group :development, :test do
|
|
15
|
-
gem "byebug"
|
|
14
|
+
gem "pry-byebug"
|
|
16
15
|
gem "rake", "~> 13.0"
|
|
17
|
-
gem "rspec", "~> 3.0"
|
|
18
|
-
gem "rubocop", "~> 1.
|
|
19
|
-
gem "simplecov", require: false
|
|
16
|
+
gem "rspec", "~> 3.12.0"
|
|
17
|
+
gem "rubocop", "~> 1.41.1"
|
|
18
|
+
gem "simplecov", "~> 0.22.0", require: false
|
|
20
19
|
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
use_cases (
|
|
5
|
-
activesupport (>=
|
|
4
|
+
use_cases (3.0.0)
|
|
5
|
+
activesupport (>= 6.1.7)
|
|
6
6
|
dry-matcher (>= 0.8.1)
|
|
7
7
|
dry-monads (>= 1.0.0)
|
|
8
|
-
dry-validation (>=
|
|
8
|
+
dry-validation (>= 1.8.1)
|
|
9
9
|
|
|
10
10
|
GEM
|
|
11
11
|
remote: https://rubygems.org/
|
|
12
12
|
specs:
|
|
13
|
-
activesupport (6.1.
|
|
13
|
+
activesupport (6.1.7)
|
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
15
15
|
i18n (>= 1.6, < 2)
|
|
16
16
|
minitest (>= 5.1)
|
|
@@ -18,8 +18,9 @@ GEM
|
|
|
18
18
|
zeitwerk (~> 2.3)
|
|
19
19
|
ast (2.4.2)
|
|
20
20
|
byebug (11.1.3)
|
|
21
|
+
coderay (1.1.3)
|
|
21
22
|
concurrent-ruby (1.1.9)
|
|
22
|
-
diff-lcs (1.
|
|
23
|
+
diff-lcs (1.5.0)
|
|
23
24
|
docile (1.4.0)
|
|
24
25
|
dry-configurable (0.13.0)
|
|
25
26
|
concurrent-ruby (~> 1.0)
|
|
@@ -29,19 +30,18 @@ GEM
|
|
|
29
30
|
dry-configurable (~> 0.13, >= 0.13.0)
|
|
30
31
|
dry-core (0.7.1)
|
|
31
32
|
concurrent-ruby (~> 1.0)
|
|
32
|
-
dry-
|
|
33
|
-
concurrent-ruby (~> 1.0)
|
|
34
|
-
dry-core (~> 0.5, >= 0.5)
|
|
33
|
+
dry-equalizer (0.3.0)
|
|
35
34
|
dry-inflector (0.2.1)
|
|
36
35
|
dry-initializer (3.0.4)
|
|
37
36
|
dry-logic (1.2.0)
|
|
38
37
|
concurrent-ruby (~> 1.0)
|
|
39
38
|
dry-core (~> 0.5, >= 0.5)
|
|
40
|
-
dry-matcher (0.
|
|
41
|
-
dry-core (
|
|
42
|
-
dry-monads (1.
|
|
39
|
+
dry-matcher (0.8.3)
|
|
40
|
+
dry-core (>= 0.4.8)
|
|
41
|
+
dry-monads (1.0.1)
|
|
43
42
|
concurrent-ruby (~> 1.0)
|
|
44
|
-
dry-core (~> 0.
|
|
43
|
+
dry-core (~> 0.4, >= 0.4.4)
|
|
44
|
+
dry-equalizer
|
|
45
45
|
dry-schema (1.8.0)
|
|
46
46
|
concurrent-ruby (~> 1.0)
|
|
47
47
|
dry-configurable (~> 0.13, >= 0.13.0)
|
|
@@ -55,57 +55,66 @@ GEM
|
|
|
55
55
|
dry-core (~> 0.5, >= 0.5)
|
|
56
56
|
dry-inflector (~> 0.1, >= 0.1.2)
|
|
57
57
|
dry-logic (~> 1.0, >= 1.0.2)
|
|
58
|
-
dry-validation (1.
|
|
58
|
+
dry-validation (1.8.1)
|
|
59
59
|
concurrent-ruby (~> 1.0)
|
|
60
60
|
dry-container (~> 0.7, >= 0.7.1)
|
|
61
61
|
dry-core (~> 0.5, >= 0.5)
|
|
62
62
|
dry-initializer (~> 3.0)
|
|
63
63
|
dry-schema (~> 1.8, >= 1.8.0)
|
|
64
|
-
i18n (1.
|
|
64
|
+
i18n (1.12.0)
|
|
65
65
|
concurrent-ruby (~> 1.0)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
json (2.6.3)
|
|
67
|
+
method_source (1.0.0)
|
|
68
|
+
minitest (5.17.0)
|
|
69
|
+
parallel (1.22.1)
|
|
70
|
+
parser (3.2.0.0)
|
|
69
71
|
ast (~> 2.4.1)
|
|
70
|
-
|
|
72
|
+
pry (0.14.1)
|
|
73
|
+
coderay (~> 1.1)
|
|
74
|
+
method_source (~> 1.0)
|
|
75
|
+
pry-byebug (3.10.1)
|
|
76
|
+
byebug (~> 11.0)
|
|
77
|
+
pry (>= 0.13, < 0.15)
|
|
78
|
+
rainbow (3.1.1)
|
|
71
79
|
rake (13.0.6)
|
|
72
|
-
regexp_parser (2.
|
|
80
|
+
regexp_parser (2.6.1)
|
|
73
81
|
rexml (3.2.5)
|
|
74
|
-
rspec (3.
|
|
75
|
-
rspec-core (~> 3.
|
|
76
|
-
rspec-expectations (~> 3.
|
|
77
|
-
rspec-mocks (~> 3.
|
|
78
|
-
rspec-core (3.
|
|
79
|
-
rspec-support (~> 3.
|
|
80
|
-
rspec-expectations (3.
|
|
82
|
+
rspec (3.12.0)
|
|
83
|
+
rspec-core (~> 3.12.0)
|
|
84
|
+
rspec-expectations (~> 3.12.0)
|
|
85
|
+
rspec-mocks (~> 3.12.0)
|
|
86
|
+
rspec-core (3.12.0)
|
|
87
|
+
rspec-support (~> 3.12.0)
|
|
88
|
+
rspec-expectations (3.12.1)
|
|
81
89
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
82
|
-
rspec-support (~> 3.
|
|
83
|
-
rspec-mocks (3.
|
|
90
|
+
rspec-support (~> 3.12.0)
|
|
91
|
+
rspec-mocks (3.12.1)
|
|
84
92
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
85
|
-
rspec-support (~> 3.
|
|
86
|
-
rspec-support (3.
|
|
87
|
-
rubocop (1.
|
|
93
|
+
rspec-support (~> 3.12.0)
|
|
94
|
+
rspec-support (3.12.0)
|
|
95
|
+
rubocop (1.41.1)
|
|
96
|
+
json (~> 2.3)
|
|
88
97
|
parallel (~> 1.10)
|
|
89
|
-
parser (>= 3.
|
|
98
|
+
parser (>= 3.1.2.1)
|
|
90
99
|
rainbow (>= 2.2.2, < 4.0)
|
|
91
100
|
regexp_parser (>= 1.8, < 3.0)
|
|
92
|
-
rexml
|
|
93
|
-
rubocop-ast (>= 1.
|
|
101
|
+
rexml (>= 3.2.5, < 4.0)
|
|
102
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
|
94
103
|
ruby-progressbar (~> 1.7)
|
|
95
104
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
96
|
-
rubocop-ast (1.
|
|
97
|
-
parser (>= 3.
|
|
105
|
+
rubocop-ast (1.24.1)
|
|
106
|
+
parser (>= 3.1.1.0)
|
|
98
107
|
ruby-progressbar (1.11.0)
|
|
99
|
-
simplecov (0.
|
|
108
|
+
simplecov (0.22.0)
|
|
100
109
|
docile (~> 1.1)
|
|
101
110
|
simplecov-html (~> 0.11)
|
|
102
111
|
simplecov_json_formatter (~> 0.1)
|
|
103
112
|
simplecov-html (0.12.3)
|
|
104
|
-
simplecov_json_formatter (0.1.
|
|
105
|
-
tzinfo (2.0.
|
|
113
|
+
simplecov_json_formatter (0.1.4)
|
|
114
|
+
tzinfo (2.0.5)
|
|
106
115
|
concurrent-ruby (~> 1.0)
|
|
107
|
-
unicode-display_width (2.
|
|
108
|
-
zeitwerk (2.
|
|
116
|
+
unicode-display_width (2.4.2)
|
|
117
|
+
zeitwerk (2.6.6)
|
|
109
118
|
|
|
110
119
|
PLATFORMS
|
|
111
120
|
x86_64-darwin-20
|
|
@@ -113,17 +122,17 @@ PLATFORMS
|
|
|
113
122
|
x86_64-linux
|
|
114
123
|
|
|
115
124
|
DEPENDENCIES
|
|
116
|
-
activesupport
|
|
125
|
+
activesupport (~> 6.1.7)
|
|
117
126
|
byebug
|
|
118
|
-
dry-
|
|
119
|
-
dry-
|
|
120
|
-
dry-
|
|
121
|
-
|
|
127
|
+
dry-matcher (~> 0.8.1)
|
|
128
|
+
dry-monads (~> 1.0.0)
|
|
129
|
+
dry-validation (~> 1.8.1)
|
|
130
|
+
pry-byebug
|
|
122
131
|
rake (~> 13.0)
|
|
123
|
-
rspec (~> 3.0)
|
|
124
|
-
rubocop (~> 1.
|
|
125
|
-
simplecov
|
|
132
|
+
rspec (~> 3.12.0)
|
|
133
|
+
rubocop (~> 1.41.1)
|
|
134
|
+
simplecov (~> 0.22.0)
|
|
126
135
|
use_cases!
|
|
127
136
|
|
|
128
137
|
BUNDLED WITH
|
|
129
|
-
2.2
|
|
138
|
+
2.4.2
|
|
@@ -26,13 +26,13 @@ module UseCases
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
module CallPatch
|
|
29
|
-
def call(
|
|
29
|
+
def call(...)
|
|
30
30
|
unless self.class._lock_with
|
|
31
31
|
raise MissingLockConfiguration, "Locked use cases require setting `lock_with` to define the cache key and wait configuration.\n" \
|
|
32
32
|
" Example: `lock_with { |params, curent_user| \"my-key-\#{params[:id]}-\#{curent_user.id}\" }`"
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
key = lock_with(
|
|
35
|
+
key = lock_with(...)
|
|
36
36
|
|
|
37
37
|
raise MissingLockerError, "Locked use cases require setting `locker` dependency to define the cache store.\n" unless respond_to?(:locker)
|
|
38
38
|
|
|
@@ -45,8 +45,8 @@ module UseCases
|
|
|
45
45
|
self.class._lock_options
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
def lock_with(
|
|
49
|
-
self.class._lock_with.is_a?(Proc) ? self.class._lock_with.call(
|
|
48
|
+
def lock_with(...)
|
|
49
|
+
self.class._lock_with.is_a?(Proc) ? self.class._lock_with.call(...) : self.class._lock_with
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
end
|
|
@@ -13,7 +13,7 @@ module UseCases
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
module DoCallPatch
|
|
16
|
-
def do_call(*
|
|
16
|
+
def do_call(*)
|
|
17
17
|
unless respond_to?(:transaction_handler)
|
|
18
18
|
raise TransactionHandlerUndefined, "when using *transactional*, make sure to include a transaction handler in your dependencies."
|
|
19
19
|
end
|
|
@@ -17,7 +17,7 @@ module UseCases
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
module CallPatch
|
|
20
|
-
def call(*
|
|
20
|
+
def call(*)
|
|
21
21
|
unless stack.include_step?(:validate)
|
|
22
22
|
raise NoValidationError,
|
|
23
23
|
"Make sure to define params validations by using *params*" \
|
|
@@ -67,7 +67,7 @@ module UseCases
|
|
|
67
67
|
|
|
68
68
|
private
|
|
69
69
|
|
|
70
|
-
def validate(params, *
|
|
70
|
+
def validate(params, *)
|
|
71
71
|
return Failure([:validation_error, "*params* must be a hash."]) unless params.respond_to?(:merge)
|
|
72
72
|
|
|
73
73
|
validation = contract.call(params)
|
|
@@ -10,18 +10,17 @@ module UseCases
|
|
|
10
10
|
|
|
11
11
|
attr_reader :name, :object, :failure, :options
|
|
12
12
|
|
|
13
|
-
def initialize(name, *args
|
|
13
|
+
def initialize(name, *args)
|
|
14
14
|
@name = name
|
|
15
|
-
@object = args
|
|
16
|
-
@options = options
|
|
15
|
+
@object, @options = args
|
|
17
16
|
end
|
|
18
17
|
|
|
19
18
|
def previous_step_result
|
|
20
19
|
object.stack.prev_step_result
|
|
21
20
|
end
|
|
22
21
|
|
|
23
|
-
def call(
|
|
24
|
-
UseCases::Result.new(self, do_call(
|
|
22
|
+
def call(...)
|
|
23
|
+
UseCases::Result.new(self, do_call(...))
|
|
25
24
|
end
|
|
26
25
|
|
|
27
26
|
def do_call(*initial_args)
|
data/lib/use_cases/version.rb
CHANGED
data/use_cases.gemspec
CHANGED
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
|
12
12
|
spec.description = "A DSL to encapsulate your domain logic."
|
|
13
13
|
spec.homepage = "https://github.com/listminut/use_cases"
|
|
14
14
|
spec.license = "MIT"
|
|
15
|
-
spec.required_ruby_version = ">=
|
|
15
|
+
spec.required_ruby_version = ">= 3.0.0"
|
|
16
16
|
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
|
18
18
|
spec.metadata["source_code_uri"] = "https://github.com/listminut/use_cases"
|
|
@@ -30,10 +30,10 @@ Gem::Specification.new do |spec|
|
|
|
30
30
|
# For more information and examples about making a new gem, checkout our
|
|
31
31
|
# guide at: https://bundler.io/guides/creating_gem.html
|
|
32
32
|
|
|
33
|
-
spec.add_dependency "activesupport", ">=
|
|
33
|
+
spec.add_dependency "activesupport", ">= 6.1.7"
|
|
34
34
|
spec.add_dependency "dry-matcher", ">= 0.8.1"
|
|
35
35
|
spec.add_dependency "dry-monads", ">= 1.0.0"
|
|
36
|
-
spec.add_dependency "dry-validation", ">=
|
|
36
|
+
spec.add_dependency "dry-validation", ">= 1.8.1"
|
|
37
37
|
|
|
38
38
|
spec.add_development_dependency "byebug"
|
|
39
39
|
spec.add_development_dependency "rake"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: use_cases
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ring Twice
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-01-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 6.1.7
|
|
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:
|
|
26
|
+
version: 6.1.7
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: dry-matcher
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -58,14 +58,14 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - ">="
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
61
|
+
version: 1.8.1
|
|
62
62
|
type: :runtime
|
|
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:
|
|
68
|
+
version: 1.8.1
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: byebug
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -135,6 +135,7 @@ files:
|
|
|
135
135
|
- ".rspec"
|
|
136
136
|
- ".rubocop.yml"
|
|
137
137
|
- ".rubocop_todo.yml"
|
|
138
|
+
- ".ruby-version"
|
|
138
139
|
- CHANGELOG.md
|
|
139
140
|
- CODE_OF_CONDUCT.md
|
|
140
141
|
- Gemfile
|
|
@@ -176,7 +177,7 @@ metadata:
|
|
|
176
177
|
homepage_uri: https://github.com/listminut/use_cases
|
|
177
178
|
source_code_uri: https://github.com/listminut/use_cases
|
|
178
179
|
changelog_uri: https://github.com/listminut/use_cases/CHANGELOG.md
|
|
179
|
-
post_install_message:
|
|
180
|
+
post_install_message:
|
|
180
181
|
rdoc_options: []
|
|
181
182
|
require_paths:
|
|
182
183
|
- lib
|
|
@@ -184,15 +185,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
184
185
|
requirements:
|
|
185
186
|
- - ">="
|
|
186
187
|
- !ruby/object:Gem::Version
|
|
187
|
-
version:
|
|
188
|
+
version: 3.0.0
|
|
188
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
190
|
requirements:
|
|
190
191
|
- - ">="
|
|
191
192
|
- !ruby/object:Gem::Version
|
|
192
193
|
version: '0'
|
|
193
194
|
requirements: []
|
|
194
|
-
rubygems_version: 3.
|
|
195
|
-
signing_key:
|
|
195
|
+
rubygems_version: 3.2.33
|
|
196
|
+
signing_key:
|
|
196
197
|
specification_version: 4
|
|
197
198
|
summary: Use Cases
|
|
198
199
|
test_files: []
|