dry-transaction 0.13.0 → 0.13.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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +308 -0
  3. data/LICENSE +20 -0
  4. data/README.md +15 -41
  5. data/dry-transaction.gemspec +35 -0
  6. data/lib/dry-transaction.rb +2 -0
  7. data/lib/dry/transaction.rb +2 -0
  8. data/lib/dry/transaction/builder.rb +6 -4
  9. data/lib/dry/transaction/callable.rb +5 -0
  10. data/lib/dry/transaction/dsl.rb +2 -0
  11. data/lib/dry/transaction/errors.rb +2 -0
  12. data/lib/dry/transaction/instance_methods.rb +6 -4
  13. data/lib/dry/transaction/operation.rb +5 -3
  14. data/lib/dry/transaction/operation_resolver.rb +2 -0
  15. data/lib/dry/transaction/result_matcher.rb +3 -1
  16. data/lib/dry/transaction/stack.rb +2 -0
  17. data/lib/dry/transaction/step.rb +6 -4
  18. data/lib/dry/transaction/step_adapter.rb +6 -4
  19. data/lib/dry/transaction/step_adapters.rb +9 -7
  20. data/lib/dry/transaction/step_adapters/around.rb +4 -2
  21. data/lib/dry/transaction/step_adapters/check.rb +2 -0
  22. data/lib/dry/transaction/step_adapters/map.rb +2 -0
  23. data/lib/dry/transaction/step_adapters/raw.rb +5 -3
  24. data/lib/dry/transaction/step_adapters/tee.rb +2 -0
  25. data/lib/dry/transaction/step_adapters/try.rb +3 -1
  26. data/lib/dry/transaction/step_failure.rb +2 -0
  27. data/lib/dry/transaction/version.rb +3 -1
  28. metadata +14 -110
  29. data/Gemfile +0 -15
  30. data/Gemfile.lock +0 -97
  31. data/LICENSE.md +0 -9
  32. data/Rakefile +0 -6
  33. data/spec/examples.txt +0 -88
  34. data/spec/integration/around_spec.rb +0 -120
  35. data/spec/integration/auto_injection_spec.rb +0 -32
  36. data/spec/integration/custom_step_adapters_spec.rb +0 -41
  37. data/spec/integration/operation_spec.rb +0 -30
  38. data/spec/integration/passing_step_arguments_spec.rb +0 -51
  39. data/spec/integration/publishing_step_events_spec.rb +0 -119
  40. data/spec/integration/transaction_spec.rb +0 -573
  41. data/spec/integration/transaction_without_steps_spec.rb +0 -101
  42. data/spec/spec_helper.rb +0 -116
  43. data/spec/support/container.rb +0 -10
  44. data/spec/support/database.rb +0 -12
  45. data/spec/support/db_transactions.rb +0 -45
  46. data/spec/support/result_mixin.rb +0 -3
  47. data/spec/support/test_module_constants.rb +0 -11
  48. data/spec/unit/step_adapters/around_spec.rb +0 -46
  49. data/spec/unit/step_adapters/check_spec.rb +0 -43
  50. data/spec/unit/step_adapters/map_spec.rb +0 -16
  51. data/spec/unit/step_adapters/raw_spec.rb +0 -36
  52. data/spec/unit/step_adapters/tee_spec.rb +0 -17
  53. data/spec/unit/step_adapters/try_spec.rb +0 -89
  54. data/spec/unit/step_spec.rb +0 -139
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "dry/monads/result"
2
4
  require "dry/transaction/version"
3
5
  require "dry/transaction/step_adapters"
@@ -1,7 +1,9 @@
1
- require "dry/transaction/step"
2
- require "dry/transaction/dsl"
3
- require "dry/transaction/instance_methods"
4
- require "dry/transaction/operation_resolver"
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry/transaction/step'
4
+ require 'dry/transaction/dsl'
5
+ require 'dry/transaction/instance_methods'
6
+ require 'dry/transaction/operation_resolver'
5
7
 
6
8
  module Dry
7
9
  module Transaction
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dry
2
4
  module Transaction
3
5
  # @api private
@@ -29,6 +31,9 @@ module Dry
29
31
  def call(*args, &block)
30
32
  if arity.zero?
31
33
  operation.(&block)
34
+ elsif args.last.is_a?(Hash) && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0")
35
+ *prefix, last = args
36
+ operation.(*prefix, **last, &block)
32
37
  else
33
38
  operation.(*args, &block)
34
39
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dry
2
4
  module Transaction
3
5
  class DSL < Module
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dry
2
4
  module Transaction
3
5
  class InvalidStepError < ArgumentError
@@ -1,6 +1,8 @@
1
- require "dry/monads/result"
2
- require "dry/transaction/result_matcher"
3
- require "dry/transaction/stack"
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry/monads/result'
4
+ require 'dry/transaction/result_matcher'
5
+ require 'dry/transaction/stack'
4
6
 
5
7
  module Dry
6
8
  module Transaction
@@ -14,7 +16,7 @@ module Dry
14
16
 
15
17
  def initialize(steps: (self.class.steps), listeners: nil, **operations)
16
18
  @steps = steps.map { |step|
17
- operation = resolve_operation(step, operations)
19
+ operation = resolve_operation(step, **operations)
18
20
  step.with(operation: operation)
19
21
  }
20
22
  @operations = operations
@@ -1,6 +1,8 @@
1
- require "dry/monads/result"
2
- require "dry/matcher"
3
- require "dry/matcher/result_matcher"
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry/monads/result'
4
+ require 'dry/matcher'
5
+ require 'dry/matcher/result_matcher'
4
6
 
5
7
  module Dry
6
8
  module Transaction
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dry
2
4
  module Transaction
3
5
  class OperationResolver < Module
@@ -1,4 +1,6 @@
1
- require "dry/matcher"
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry/matcher'
2
4
 
3
5
  module Dry
4
6
  module Transaction
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dry
2
4
  module Transaction
3
5
  # @api private
@@ -1,7 +1,9 @@
1
- require "dry/monads/result"
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry/monads/result'
2
4
  require 'dry/events/publisher'
3
- require "dry/transaction/step_failure"
4
- require "dry/transaction/step_adapter"
5
+ require 'dry/transaction/step_failure'
6
+ require 'dry/transaction/step_adapter'
5
7
 
6
8
  module Dry
7
9
  module Transaction
@@ -23,7 +25,7 @@ module Dry
23
25
  attr_reader :call_args
24
26
 
25
27
  def initialize(adapter:, name:, operation_name:, operation: nil, options:, call_args: [])
26
- @adapter = StepAdapter[adapter, operation, **options, step_name: name, operation_name: operation_name]
28
+ @adapter = StepAdapter[adapter, operation, { **options, step_name: name, operation_name: operation_name }]
27
29
  @name = name
28
30
  @operation_name = operation_name
29
31
  @call_args = call_args
@@ -1,4 +1,6 @@
1
- require "dry/transaction/callable"
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry/transaction/callable'
2
4
 
3
5
  module Dry
4
6
  module Transaction
@@ -28,9 +30,9 @@ module Dry
28
30
 
29
31
  @options = options
30
32
 
31
- @yields = @adapter.
32
- parameters.
33
- any? { |type, _| type == :block }
33
+ @yields = @adapter
34
+ .parameters
35
+ .any? { |type, _| type == :block }
34
36
  end
35
37
 
36
38
  def yields?
@@ -1,4 +1,6 @@
1
- require "dry-container"
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry-container'
2
4
 
3
5
  module Dry
4
6
  module Transaction
@@ -8,9 +10,9 @@ module Dry
8
10
  end
9
11
  end
10
12
 
11
- require "dry/transaction/step_adapters/check"
12
- require "dry/transaction/step_adapters/map"
13
- require "dry/transaction/step_adapters/raw"
14
- require "dry/transaction/step_adapters/tee"
15
- require "dry/transaction/step_adapters/try"
16
- require "dry/transaction/step_adapters/around"
13
+ require 'dry/transaction/step_adapters/check'
14
+ require 'dry/transaction/step_adapters/map'
15
+ require 'dry/transaction/step_adapters/raw'
16
+ require 'dry/transaction/step_adapters/tee'
17
+ require 'dry/transaction/step_adapters/try'
18
+ require 'dry/transaction/step_adapters/around'
@@ -1,5 +1,7 @@
1
- require "dry/monads/result"
2
- require "dry/transaction/errors"
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry/monads/result'
4
+ require 'dry/transaction/errors'
3
5
 
4
6
  module Dry
5
7
  module Transaction
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dry
2
4
  module Transaction
3
5
  class StepAdapters
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dry
2
4
  module Transaction
3
5
  class StepAdapters
@@ -1,6 +1,8 @@
1
- require "dry/monads/result"
2
- require "dry/transaction/errors"
3
- require "dry/transaction/step_adapters/around"
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry/monads/result'
4
+ require 'dry/transaction/errors'
5
+ require 'dry/transaction/step_adapters/around'
4
6
 
5
7
  module Dry
6
8
  module Transaction
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dry
2
4
  module Transaction
3
5
  class StepAdapters
@@ -1,4 +1,6 @@
1
- require "dry/transaction/errors"
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry/transaction/errors'
2
4
 
3
5
  module Dry
4
6
  module Transaction
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dry
2
4
  module Transaction
3
5
  # A wrapper for storing together the step that failed
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dry
2
4
  # Business transaction DSL.
3
5
  module Transaction
4
- VERSION = "0.13.0".freeze
6
+ VERSION = '0.13.1'.freeze
5
7
  end
6
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-transaction
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Riley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-13 00:00:00.000000000 Z
11
+ date: 2021-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-container
@@ -66,94 +66,17 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.4.0
69
- - !ruby/object:Gem::Dependency
70
- name: bundler
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.15'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.15'
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '11.2'
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: 11.2.2
93
- type: :development
94
- prerelease: false
95
- version_requirements: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - "~>"
98
- - !ruby/object:Gem::Version
99
- version: '11.2'
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: 11.2.2
103
- - !ruby/object:Gem::Dependency
104
- name: rspec
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '3.3'
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - "~>"
115
- - !ruby/object:Gem::Version
116
- version: '3.3'
117
- - !ruby/object:Gem::Dependency
118
- name: simplecov
119
- requirement: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- version: '0'
124
- type: :development
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- version: '0'
131
- - !ruby/object:Gem::Dependency
132
- name: yard
133
- requirement: !ruby/object:Gem::Requirement
134
- requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- version: '0'
138
- type: :development
139
- prerelease: false
140
- version_requirements: !ruby/object:Gem::Requirement
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: '0'
145
- description:
69
+ description: Business Transaction Flow DSL
146
70
  email:
147
71
  - tim@icelab.com.au
148
72
  executables: []
149
73
  extensions: []
150
74
  extra_rdoc_files: []
151
75
  files:
152
- - Gemfile
153
- - Gemfile.lock
154
- - LICENSE.md
76
+ - CHANGELOG.md
77
+ - LICENSE
155
78
  - README.md
156
- - Rakefile
79
+ - dry-transaction.gemspec
157
80
  - lib/dry-transaction.rb
158
81
  - lib/dry/transaction.rb
159
82
  - lib/dry/transaction/builder.rb
@@ -176,32 +99,14 @@ files:
176
99
  - lib/dry/transaction/step_adapters/try.rb
177
100
  - lib/dry/transaction/step_failure.rb
178
101
  - lib/dry/transaction/version.rb
179
- - spec/examples.txt
180
- - spec/integration/around_spec.rb
181
- - spec/integration/auto_injection_spec.rb
182
- - spec/integration/custom_step_adapters_spec.rb
183
- - spec/integration/operation_spec.rb
184
- - spec/integration/passing_step_arguments_spec.rb
185
- - spec/integration/publishing_step_events_spec.rb
186
- - spec/integration/transaction_spec.rb
187
- - spec/integration/transaction_without_steps_spec.rb
188
- - spec/spec_helper.rb
189
- - spec/support/container.rb
190
- - spec/support/database.rb
191
- - spec/support/db_transactions.rb
192
- - spec/support/result_mixin.rb
193
- - spec/support/test_module_constants.rb
194
- - spec/unit/step_adapters/around_spec.rb
195
- - spec/unit/step_adapters/check_spec.rb
196
- - spec/unit/step_adapters/map_spec.rb
197
- - spec/unit/step_adapters/raw_spec.rb
198
- - spec/unit/step_adapters/tee_spec.rb
199
- - spec/unit/step_adapters/try_spec.rb
200
- - spec/unit/step_spec.rb
201
- homepage: https://github.com/dry-rb/dry-transaction
102
+ homepage: https://dry-rb.org/gems/dry-transaction
202
103
  licenses:
203
104
  - MIT
204
- metadata: {}
105
+ metadata:
106
+ allowed_push_host: https://rubygems.org
107
+ changelog_uri: https://github.com/dry-rb/dry-transaction/blob/master/CHANGELOG.md
108
+ source_code_uri: https://github.com/dry-rb/dry-transaction
109
+ bug_tracker_uri: https://github.com/dry-rb/dry-transaction/issues
205
110
  post_install_message:
206
111
  rdoc_options: []
207
112
  require_paths:
@@ -210,15 +115,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
210
115
  requirements:
211
116
  - - ">="
212
117
  - !ruby/object:Gem::Version
213
- version: 2.2.0
118
+ version: 2.5.0
214
119
  required_rubygems_version: !ruby/object:Gem::Requirement
215
120
  requirements:
216
121
  - - ">="
217
122
  - !ruby/object:Gem::Version
218
123
  version: '0'
219
124
  requirements: []
220
- rubyforge_project:
221
- rubygems_version: 2.7.5
125
+ rubygems_version: 3.1.4
222
126
  signing_key:
223
127
  specification_version: 4
224
128
  summary: Business Transaction Flow DSL
data/Gemfile DELETED
@@ -1,15 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- group :test do
6
- gem "simplecov"
7
- gem "codeclimate-test-reporter"
8
- gem "pry-byebug", platform: :mri
9
- gem "dry-container"
10
- end
11
-
12
- group :tools do
13
- gem "pry"
14
- gem "rubocop"
15
- end
@@ -1,97 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- dry-transaction (0.13.0)
5
- dry-container (>= 0.2.8)
6
- dry-events (>= 0.1.0)
7
- dry-matcher (>= 0.7.0)
8
- dry-monads (>= 0.4.0)
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- ast (2.3.0)
14
- byebug (9.1.0)
15
- codeclimate-test-reporter (0.5.0)
16
- simplecov (>= 0.7.1, < 1.0.0)
17
- coderay (1.1.1)
18
- concurrent-ruby (1.0.5)
19
- diff-lcs (1.2.5)
20
- docile (1.1.5)
21
- dry-configurable (0.7.0)
22
- concurrent-ruby (~> 1.0)
23
- dry-container (0.6.0)
24
- concurrent-ruby (~> 1.0)
25
- dry-configurable (~> 0.1, >= 0.1.3)
26
- dry-core (0.4.6)
27
- concurrent-ruby (~> 1.0)
28
- dry-equalizer (0.2.1)
29
- dry-events (0.1.0)
30
- concurrent-ruby (~> 1.0)
31
- dry-core (~> 0.4)
32
- dry-equalizer (~> 0.2)
33
- dry-matcher (0.7.0)
34
- dry-monads (0.4.0)
35
- dry-core (~> 0.3, >= 0.3.3)
36
- dry-equalizer
37
- json (1.8.6)
38
- method_source (0.8.2)
39
- parser (2.3.1.4)
40
- ast (~> 2.2)
41
- powerpack (0.1.1)
42
- pry (0.10.3)
43
- coderay (~> 1.1.0)
44
- method_source (~> 0.8.1)
45
- slop (~> 3.4)
46
- pry-byebug (3.5.0)
47
- byebug (~> 9.1)
48
- pry (~> 0.10)
49
- rainbow (2.1.0)
50
- rake (11.2.2)
51
- rspec (3.3.0)
52
- rspec-core (~> 3.3.0)
53
- rspec-expectations (~> 3.3.0)
54
- rspec-mocks (~> 3.3.0)
55
- rspec-core (3.3.2)
56
- rspec-support (~> 3.3.0)
57
- rspec-expectations (3.3.1)
58
- diff-lcs (>= 1.2.0, < 2.0)
59
- rspec-support (~> 3.3.0)
60
- rspec-mocks (3.3.2)
61
- diff-lcs (>= 1.2.0, < 2.0)
62
- rspec-support (~> 3.3.0)
63
- rspec-support (3.3.0)
64
- rubocop (0.43.0)
65
- parser (>= 2.3.1.1, < 3.0)
66
- powerpack (~> 0.1)
67
- rainbow (>= 1.99.1, < 3.0)
68
- ruby-progressbar (~> 1.7)
69
- unicode-display_width (~> 1.0, >= 1.0.1)
70
- ruby-progressbar (1.8.1)
71
- simplecov (0.10.0)
72
- docile (~> 1.1.0)
73
- json (~> 1.8)
74
- simplecov-html (~> 0.10.0)
75
- simplecov-html (0.10.0)
76
- slop (3.6.0)
77
- unicode-display_width (1.1.1)
78
- yard (0.8.7.6)
79
-
80
- PLATFORMS
81
- ruby
82
-
83
- DEPENDENCIES
84
- bundler (~> 1.15)
85
- codeclimate-test-reporter
86
- dry-container
87
- dry-transaction!
88
- pry
89
- pry-byebug
90
- rake (~> 11.2, >= 11.2.2)
91
- rspec (~> 3.3)
92
- rubocop
93
- simplecov
94
- yard
95
-
96
- BUNDLED WITH
97
- 1.16.1