dry-transaction 0.14.0 → 0.15.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: d9c1425876b4a098f950d9522921485ff19fcc5a4e72821e9d0c201a2fe50c32
4
+ data.tar.gz: 03abc2d074b6ee1b413a2576b3f9165017112cc22763b1868345c282ff7c8a5c
5
5
  SHA512:
6
- metadata.gz: 0ccdb31bf78be6abb87c19eca848acbe54120a4308a84c7c498724c7428e2aa91e6f54480ca89fe6674cc08fddc56eaff15015b32afe09b9ffeb9f499d46850d
7
- data.tar.gz: fe27e8c8fe12217585d333e8263b7c8c3be2d1f74191c68a2ec6c9e9583ca3fb0324b34a91a78e661540b3276c1403c1f9826a2254d4f6ebcc927e008c1f7c2f
6
+ metadata.gz: 0e33116591724aa2bc18722aedabe06cf55bec9c5291aba661209a96c2d83c483513defdba07906bb95ab3482e1bab2ce1956a56751a6e5d8a06971cd57a557b
7
+ data.tar.gz: 1fd41ea16ce2d78b519a2cf0d20cdb0156b8040e6eb17578ed18d1d9b1e2f01be7a86a9b70e551cceb4482c1f7596c1ccbafaad1b8600e332e6b004241e2ac27
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
+ ## 0.15.0 2022-11-16
4
+
5
+
6
+ ### Changed
7
+
8
+ - Dependencies were bumped to exclude dry-container (@flash-gordon)
9
+
10
+ [Compare v0.14.0...v0.15.0](https://github.com/dry-rb/dry-transaction/compare/v0.14.0...v0.15.0)
11
+
3
12
  ## 0.14.0 2022-10-21
4
13
 
5
14
 
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-2022 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
@@ -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
29
  spec.required_ruby_version = ">= 2.7.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", "~> 0.10"
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,12 +77,16 @@ 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
85
87
 
86
88
  def resolve_operation(step, **operations)
89
+ # rubocop:disable Lint/DuplicateBranch
87
90
  if step.internal? && operations[step.name]
88
91
  operations[step.name]
89
92
  elsif methods.include?(step.name) || private_methods.include?(step.name)
@@ -91,10 +94,11 @@ module Dry
91
94
  elsif operations[step.name].respond_to?(:call)
92
95
  operations[step.name]
93
96
  elsif operations[step.name]
94
- raise InvalidStepError.new(step.name)
97
+ raise InvalidStepError, step.name
95
98
  else
96
- raise MissingStepError.new(step.name)
99
+ raise MissingStepError, step.name
97
100
  end
101
+ # rubocop:enable Lint/DuplicateBranch
98
102
  end
99
103
 
100
104
  def assert_valid_step_args(step_args)
@@ -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.15.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.15.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: 2022-11-16 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: '0.10'
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: '0.10'
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: