dry-transaction 0.14.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 010cc004830363a29fd3701799a706d8734e37196acdf9e515a87519c7f1aef8
4
- data.tar.gz: fd9b26e42dd9690c8fc56d372555378f8013a86d8f0b56426b00bccd9220aa10
3
+ metadata.gz: d4cd9e9404fa18118f81eda69c2c826bf78d115db2011ffc7aaa61142cbbab26
4
+ data.tar.gz: e3d1503de5353ab0204f727f71b2189895ff78989ff43478b0f9ab13c3819831
5
5
  SHA512:
6
- metadata.gz: 0ccdb31bf78be6abb87c19eca848acbe54120a4308a84c7c498724c7428e2aa91e6f54480ca89fe6674cc08fddc56eaff15015b32afe09b9ffeb9f499d46850d
7
- data.tar.gz: fe27e8c8fe12217585d333e8263b7c8c3be2d1f74191c68a2ec6c9e9583ca3fb0324b34a91a78e661540b3276c1403c1f9826a2254d4f6ebcc927e008c1f7c2f
6
+ metadata.gz: b11d66011be4757691bd017cb12906c840343b93daa94912bc99fd0d9e0efc8392b501e1333f2bbda0635a1f34e308b74aedbeed95ee62026b5f52d9589e6054
7
+ data.tar.gz: 18149f9703d95a138f3536cb8b5a1f59ed5007a0ac99d5ade9b56f8e1c01e547afb4bbb7864e0d54d1271e83e67e91c073aff719a80c1f8512fe900c8febc134
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
+ ## 0.16.0 2024-01-17
4
+
5
+
6
+ ### Changed
7
+
8
+ - Dependency on dry-matcher bumped to 1.0 (@santiagodoldan in #149)
9
+
10
+ [Compare v0.15.0...v0.16.0](https://github.com/dry-rb/dry-transaction/compare/v0.15.0...v0.16.0)
11
+
12
+ ## 0.15.0 2022-11-16
13
+
14
+
15
+ ### Changed
16
+
17
+ - Dependencies were bumped to exclude dry-container (@flash-gordon)
18
+
19
+ [Compare v0.14.0...v0.15.0](https://github.com/dry-rb/dry-transaction/compare/v0.14.0...v0.15.0)
20
+
3
21
  ## 0.14.0 2022-10-21
4
22
 
5
23
 
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2021 dry-rb team
3
+ Copyright (c) 2015-2023 dry-rb team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -1,29 +1,22 @@
1
1
  <!--- this file is synced from dry-rb/template-gem project -->
2
+
2
3
  [gem]: https://rubygems.org/gems/dry-transaction
3
4
  [actions]: https://github.com/dry-rb/dry-transaction/actions
4
- [codacy]: https://www.codacy.com/gh/dry-rb/dry-transaction
5
- [chat]: https://dry-rb.zulipchat.com
6
- [inchpages]: http://inch-ci.org/github/dry-rb/dry-transaction
7
-
8
- # dry-transaction [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
9
5
 
10
- [![Gem Version](https://badge.fury.io/rb/dry-transaction.svg)][gem]
11
- [![CI Status](https://github.com/dry-rb/dry-transaction/workflows/ci/badge.svg)][actions]
12
- [![Codacy Badge](https://api.codacy.com/project/badge/Grade/f2c8f3f2e96a477faee00109cfb2090d)][codacy]
13
- [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/f2c8f3f2e96a477faee00109cfb2090d)][codacy]
14
- [![Inline docs](http://inch-ci.org/github/dry-rb/dry-transaction.svg?branch=main)][inchpages]
6
+ # dry-transaction [![Gem Version](https://badge.fury.io/rb/dry-transaction.svg)][gem] [![CI Status](https://github.com/dry-rb/dry-transaction/workflows/CI/badge.svg)][actions]
15
7
 
16
8
  ## Links
17
9
 
18
10
  * [User documentation](https://dry-rb.org/gems/dry-transaction)
19
11
  * [API documentation](http://rubydoc.info/gems/dry-transaction)
12
+ * [Forum](https://discourse.dry-rb.org)
20
13
 
21
14
  ## Supported Ruby versions
22
15
 
23
16
  This library officially supports the following Ruby versions:
24
17
 
25
- * MRI `>= 2.7.0`
26
- * jruby `>= 9.3` (postponed until 2.7 is supported)
18
+ * MRI `>= 3.0`
19
+ * jruby `>= 9.4` (not tested on CI)
27
20
 
28
21
  ## License
29
22
 
@@ -22,16 +22,16 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ["lib"]
23
23
 
24
24
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
25
- spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-transaction/blob/master/CHANGELOG.md"
25
+ spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-transaction/blob/main/CHANGELOG.md"
26
26
  spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-transaction"
27
27
  spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-transaction/issues"
28
28
 
29
- spec.required_ruby_version = ">= 2.7.0"
29
+ spec.required_ruby_version = ">= 3.0"
30
30
 
31
31
  # to update dependencies edit project.yml
32
- spec.add_runtime_dependency "dry-container", ">= 0.2.8"
33
- spec.add_runtime_dependency "dry-events", ">= 0.4.0"
34
- spec.add_runtime_dependency "dry-matcher", ">= 0.7.0"
35
- spec.add_runtime_dependency "dry-monads", ">= 0.5.0"
32
+ spec.add_runtime_dependency "dry-core", "~> 1.0"
33
+ spec.add_runtime_dependency "dry-events", "~> 1.0"
34
+ spec.add_runtime_dependency "dry-matcher", "~> 1.0"
35
+ spec.add_runtime_dependency "dry-monads", "~> 1.6"
36
36
 
37
37
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/transaction/step'
4
- require 'dry/transaction/dsl'
5
- require 'dry/transaction/instance_methods'
6
- require 'dry/transaction/operation_resolver'
3
+ require "dry/transaction/step"
4
+ require "dry/transaction/dsl"
5
+ require "dry/transaction/instance_methods"
6
+ require "dry/transaction/operation_resolver"
7
7
 
8
8
  module Dry
9
9
  module Transaction
@@ -11,7 +11,8 @@ module Dry
11
11
  attr_reader :dsl_mod
12
12
  attr_reader :resolver_mod
13
13
 
14
- def initialize(container: nil, step_adapters:)
14
+ def initialize(step_adapters:, container: nil)
15
+ super()
15
16
  @dsl_mod = DSL.new(step_adapters: step_adapters)
16
17
  @resolver_mod = OperationResolver.new(container)
17
18
  end
@@ -4,6 +4,7 @@ module Dry
4
4
  module Transaction
5
5
  class DSL < Module
6
6
  def initialize(step_adapters:)
7
+ super()
7
8
  @step_adapters = step_adapters
8
9
 
9
10
  define_steps
@@ -11,7 +12,7 @@ module Dry
11
12
  end
12
13
 
13
14
  def inspect
14
- "Dry::Transaction::DSL(#{@step_adapters.keys.sort.join(', ')})"
15
+ "Dry::Transaction::DSL(#{@step_adapters.keys.sort.join(", ")})"
15
16
  end
16
17
 
17
18
  private
@@ -35,7 +36,7 @@ module Dry
35
36
  name: step_name,
36
37
  operation_name: operation_name,
37
38
  operation: nil, # operations are resolved only when transactions are instantiated
38
- options: options,
39
+ options: options
39
40
  )
40
41
  end
41
42
  end
@@ -1,20 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/monads/result'
4
- require 'dry/transaction/result_matcher'
5
- require 'dry/transaction/stack'
3
+ require "dry/transaction/result_matcher"
4
+ require "dry/transaction/stack"
6
5
 
7
6
  module Dry
8
7
  module Transaction
9
8
  module InstanceMethods
10
- include Dry::Monads::Result::Mixin
9
+ include Dry::Monads[:result]
11
10
 
12
11
  attr_reader :steps
13
12
  attr_reader :operations
14
13
  attr_reader :listeners
15
14
  attr_reader :stack
16
15
 
17
- def initialize(steps: (self.class.steps), listeners: nil, **operations)
16
+ def initialize(steps: self.class.steps, listeners: nil, **operations)
18
17
  @steps = steps.map { |step|
19
18
  operation = resolve_operation(step, **operations)
20
19
  step.with(operation: operation)
@@ -78,7 +77,10 @@ module Dry
78
77
  super unless step
79
78
 
80
79
  operation = operations[step.name]
81
- raise NotImplementedError, "no operation +#{step.operation_name}+ defined for step +#{step.name}+" unless operation
80
+ unless operation
81
+ raise NotImplementedError,
82
+ "no operation +#{step.operation_name}+ defined for step +#{step.name}+"
83
+ end
82
84
 
83
85
  operation.(*args, &block)
84
86
  end
@@ -91,9 +93,9 @@ module Dry
91
93
  elsif operations[step.name].respond_to?(:call)
92
94
  operations[step.name]
93
95
  elsif operations[step.name]
94
- raise InvalidStepError.new(step.name)
96
+ raise InvalidStepError, step.name
95
97
  else
96
- raise MissingStepError.new(step.name)
98
+ raise MissingStepError, step.name
97
99
  end
98
100
  end
99
101
 
@@ -1,15 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/monads/result'
4
- require 'dry/matcher'
5
- require 'dry/matcher/result_matcher'
3
+ require "dry/matcher/result_matcher"
6
4
 
7
5
  module Dry
8
6
  module Transaction
9
7
  module Operation
10
8
  def self.included(klass)
11
9
  klass.class_eval do
12
- include Dry::Monads::Result::Mixin
10
+ include Dry::Monads[:result]
13
11
  include Dry::Matcher.for(:call, with: Dry::Matcher::ResultMatcher)
14
12
  end
15
13
  end
@@ -6,9 +6,9 @@ module Dry
6
6
  def initialize(container)
7
7
  module_exec(container) do |ops_container|
8
8
  define_method :initialize do |**kwargs|
9
- operation_kwargs = self.class.steps.select(&:operation_name).map { |step|
9
+ operation_kwargs = self.class.steps.select(&:operation_name).to_h { |step|
10
10
  operation = kwargs.fetch(step.name) {
11
- if ops_container && ops_container.key?(step.operation_name)
11
+ if ops_container&.key?(step.operation_name)
12
12
  ops_container[step.operation_name]
13
13
  else
14
14
  nil
@@ -16,7 +16,7 @@ module Dry
16
16
  }
17
17
 
18
18
  [step.name, operation]
19
- }.to_h
19
+ }
20
20
 
21
21
  super(**kwargs, **operation_kwargs)
22
22
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/matcher'
3
+ require "dry/matcher"
4
4
 
5
5
  module Dry
6
6
  module Transaction
@@ -1,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/monads'
4
- require 'dry/events'
5
- require 'dry/transaction/step_failure'
6
- require 'dry/transaction/step_adapter'
3
+ require "dry/transaction/step_failure"
4
+ require "dry/transaction/step_adapter"
7
5
 
8
6
  module Dry
9
7
  module Transaction
@@ -13,7 +11,7 @@ module Dry
13
11
  RETURN = -> x { x }
14
12
 
15
13
  include Dry::Events::Publisher[name || object_id]
16
- include Dry::Monads::Result::Mixin
14
+ include Dry::Monads[:result]
17
15
 
18
16
  register_event(:step)
19
17
  register_event(:step_succeeded)
@@ -24,12 +22,15 @@ module Dry
24
22
  attr_reader :operation_name
25
23
  attr_reader :call_args
26
24
 
27
- def initialize(adapter:, name:, operation_name:, operation: nil, options:, call_args: [])
28
- @adapter = StepAdapter[adapter, operation, { **options, step_name: name, operation_name: operation_name }]
25
+ # rubocop:disable Metrics/ParameterLists
26
+ def initialize(adapter:, name:, operation_name:, options:, operation: nil, call_args: [])
27
+ @adapter = StepAdapter[adapter, operation,
28
+ {**options, step_name: name, operation_name: operation_name}]
29
29
  @name = name
30
30
  @operation_name = operation_name
31
31
  @call_args = call_args
32
32
  end
33
+ # rubocop:enable Metrics/ParameterLists
33
34
 
34
35
  def with(operation: UNDEFINED, call_args: UNDEFINED)
35
36
  return self if operation == UNDEFINED && call_args == UNDEFINED
@@ -43,7 +44,7 @@ module Dry
43
44
  operation_name: operation_name,
44
45
  operation: new_operation,
45
46
  options: adapter.options,
46
- call_args: new_call_args,
47
+ call_args: new_call_args
47
48
  )
48
49
  end
49
50
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/transaction/callable'
3
+ require "dry/transaction/callable"
4
4
 
5
5
  module Dry
6
6
  module Transaction
@@ -1,20 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/monads/result'
4
- require 'dry/transaction/errors'
5
-
6
3
  module Dry
7
4
  module Transaction
8
5
  class StepAdapters
9
6
  # @api private
10
7
  class Around
11
- include Dry::Monads::Result::Mixin
8
+ include Dry::Monads[:result]
12
9
 
13
10
  def call(operation, options, args, &block)
14
11
  result = operation.(*args, &block)
15
12
 
16
13
  unless result.is_a?(Dry::Monads::Result)
17
- raise InvalidResultError.new(options[:step_name])
14
+ raise InvalidResultError, options[:step_name]
18
15
  end
19
16
 
20
17
  result
@@ -5,7 +5,7 @@ module Dry
5
5
  class StepAdapters
6
6
  # @api private
7
7
  class Check
8
- include Dry::Monads::Result::Mixin
8
+ include Dry::Monads[:result]
9
9
 
10
10
  def call(operation, _options, args)
11
11
  input = args[0]
@@ -5,7 +5,7 @@ module Dry
5
5
  class StepAdapters
6
6
  # @api private
7
7
  class Map
8
- include Dry::Monads::Result::Mixin
8
+ include Dry::Monads[:result]
9
9
 
10
10
  def call(operation, _options, args)
11
11
  Success(operation.(*args))
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/monads/result'
4
- require 'dry/transaction/errors'
5
- require 'dry/transaction/step_adapters/around'
3
+ require "dry/monads/result"
4
+ require "dry/transaction/errors"
5
+ require "dry/transaction/step_adapters/around"
6
6
 
7
7
  module Dry
8
8
  module Transaction
@@ -5,7 +5,7 @@ module Dry
5
5
  class StepAdapters
6
6
  # @api private
7
7
  class Tee
8
- include Dry::Monads::Result::Mixin
8
+ include Dry::Monads[:result]
9
9
 
10
10
  def call(operation, _options, args)
11
11
  operation.(*args)
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry/transaction/errors'
3
+ require "dry/transaction/errors"
4
4
 
5
5
  module Dry
6
6
  module Transaction
7
7
  class StepAdapters
8
8
  # @api private
9
9
  class Try
10
- include Dry::Monads::Result::Mixin
10
+ include Dry::Monads[:result]
11
11
 
12
12
  def call(operation, options, args)
13
13
  unless options[:catch]
14
- raise MissingCatchListError.new(options[:step_name])
14
+ raise MissingCatchListError, options[:step_name]
15
15
  end
16
16
 
17
17
  result = operation.(*args)
@@ -1,18 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'dry-container'
4
-
5
3
  module Dry
6
4
  module Transaction
7
5
  class StepAdapters
8
- extend Dry::Container::Mixin
6
+ extend Dry::Core::Container::Mixin
9
7
  end
10
8
  end
11
9
  end
12
10
 
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'
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"
@@ -10,12 +10,14 @@ module Dry
10
10
 
11
11
  # @api private
12
12
  def self.call(step, value)
13
+ # rubocop:disable Style/CaseEquality
13
14
  if self === value
14
15
  value
15
16
  else
16
17
  yield
17
18
  new(step, value)
18
19
  end
20
+ # rubocop:enable Style/CaseEquality
19
21
  end
20
22
 
21
23
  def initialize(step, value)
@@ -3,6 +3,6 @@
3
3
  module Dry
4
4
  # Business transaction DSL.
5
5
  module Transaction
6
- VERSION = '0.14.0'.freeze
6
+ VERSION = "0.16.0"
7
7
  end
8
8
  end
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "dry/core"
4
+ require "dry/events"
3
5
  require "dry/monads"
6
+ require "dry/matcher"
4
7
  require "dry/transaction/version"
5
8
  require "dry/transaction/step_adapters"
6
9
  require "dry/transaction/builder"
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-transaction
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Riley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-21 00:00:00.000000000 Z
11
+ date: 2024-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: dry-container
14
+ name: dry-core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.8
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.2.8
26
+ version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dry-events
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.4.0
33
+ version: '1.0'
34
34
  type: :runtime
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.4.0
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: dry-matcher
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.7.0
47
+ version: '1.0'
48
48
  type: :runtime
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.7.0
54
+ version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: dry-monads
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.5.0
61
+ version: '1.6'
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: 0.5.0
68
+ version: '1.6'
69
69
  description: Business Transaction Flow DSL
70
70
  email:
71
71
  - tim@icelab.com.au
@@ -104,7 +104,7 @@ licenses:
104
104
  - MIT
105
105
  metadata:
106
106
  allowed_push_host: https://rubygems.org
107
- changelog_uri: https://github.com/dry-rb/dry-transaction/blob/master/CHANGELOG.md
107
+ changelog_uri: https://github.com/dry-rb/dry-transaction/blob/main/CHANGELOG.md
108
108
  source_code_uri: https://github.com/dry-rb/dry-transaction
109
109
  bug_tracker_uri: https://github.com/dry-rb/dry-transaction/issues
110
110
  post_install_message:
@@ -115,14 +115,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - ">="
117
117
  - !ruby/object:Gem::Version
118
- version: 2.7.0
118
+ version: '3.0'
119
119
  required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - ">="
122
122
  - !ruby/object:Gem::Version
123
123
  version: '0'
124
124
  requirements: []
125
- rubygems_version: 3.1.6
125
+ rubygems_version: 3.3.26
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: Business Transaction Flow DSL