business_flow 0.17.4 → 0.18.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57b8b055c5e74f6c55285b6b2c1514a062fb8f7ed5370538a482bae1f6319a21
4
- data.tar.gz: 40b01f4b0e319225ae99890ebe3f9a93a2360f9a31ffe4379fe4b0b87afd91f0
3
+ metadata.gz: 6b1ad94958c6313af360e1343b5fd5ac9603e8e4aa7834581c40e53631de8a51
4
+ data.tar.gz: 5562160edcf999491ae6f7d32afdb8f2b7e3479e9141b202021a9fe2ce46144e
5
5
  SHA512:
6
- metadata.gz: 6c3fc8bf70de03131787d8973e77117a80f824810a92f08abec20ec20ae2d10e5dd04eb7b3afdb9c759c01bdf97f87b440358f6ae5bbf3ad3c81a6375b350492
7
- data.tar.gz: 332391d394a721cbcb5c3b212cae333daea82e7f2c34bc51dc1142c5d0f4c7b5438c06df7e9e22dd72f94a573fc39254763e33cff85bdb044eaaa85e1ca0c69a
6
+ metadata.gz: 55311f2cf46499c01f1fb6c9886a6eace211696a17968eb9f4864696f650e573fa0343be4e9386d3fcce14daec28326d75f61fddd4e206d1a5a2a7275f4fa90e
7
+ data.tar.gz: 32ddef13a80d803eb0d95e0d8511ed4bd93b68866fa326d6b22fe770d618553cbfee48c1e5aa167501f3ed83d69d707482b28c1dc4d20896f5e5c0f44cef3c51
data/Gemfile.lock CHANGED
@@ -1,91 +1,86 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- business_flow (0.17.3)
5
- activemodel (~> 4.2)
6
- activesupport (~> 4.2)
4
+ business_flow (0.18.0)
5
+ activemodel (>= 4.2, < 8)
6
+ activesupport (>= 4.2, < 8)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (4.2.11.3)
12
- activesupport (= 4.2.11.3)
13
- builder (~> 3.1)
14
- activesupport (4.2.11.3)
15
- i18n (~> 0.7)
16
- minitest (~> 5.1)
17
- thread_safe (~> 0.3, >= 0.3.4)
18
- tzinfo (~> 1.1)
11
+ activemodel (7.0.2)
12
+ activesupport (= 7.0.2)
13
+ activesupport (7.0.2)
14
+ concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ i18n (>= 1.6, < 2)
16
+ minitest (>= 5.1)
17
+ tzinfo (~> 2.0)
19
18
  ast (2.4.2)
20
- builder (3.2.4)
19
+ codeclimate-engine-rb (0.4.2)
21
20
  concurrent-ruby (1.1.9)
22
- diff-lcs (1.4.4)
23
- docile (1.3.5)
24
- i18n (0.9.5)
21
+ diff-lcs (1.5.0)
22
+ docile (1.1.5)
23
+ i18n (1.9.1)
25
24
  concurrent-ruby (~> 1.0)
26
- kwalify (0.7.2)
27
- minitest (5.14.4)
28
- parallel (1.20.1)
29
- parser (3.0.2.0)
30
- ast (~> 2.4.1)
31
- rainbow (3.0.0)
32
- reek (6.0.6)
33
- kwalify (~> 0.7.0)
34
- parser (~> 3.0.0)
25
+ jaro_winkler (1.5.4)
26
+ json (2.6.1)
27
+ minitest (5.15.0)
28
+ parallel (1.21.0)
29
+ parser (2.5.3.0)
30
+ ast (~> 2.4.0)
31
+ rainbow (3.1.1)
32
+ rake (10.5.0)
33
+ reek (4.8.2)
34
+ codeclimate-engine-rb (~> 0.4.0)
35
+ parser (>= 2.5.0.0, < 2.6)
35
36
  rainbow (>= 2.0, < 4.0)
36
- regexp_parser (2.1.1)
37
37
  retryable (3.0.5)
38
- rexml (3.2.5)
39
38
  rspec (3.10.0)
40
39
  rspec-core (~> 3.10.0)
41
40
  rspec-expectations (~> 3.10.0)
42
41
  rspec-mocks (~> 3.10.0)
43
- rspec-core (3.10.1)
42
+ rspec-core (3.10.2)
44
43
  rspec-support (~> 3.10.0)
45
- rspec-expectations (3.10.1)
44
+ rspec-expectations (3.10.2)
46
45
  diff-lcs (>= 1.2.0, < 2.0)
47
46
  rspec-support (~> 3.10.0)
48
- rspec-mocks (3.10.2)
47
+ rspec-mocks (3.10.3)
49
48
  diff-lcs (>= 1.2.0, < 2.0)
50
49
  rspec-support (~> 3.10.0)
51
- rspec-support (3.10.2)
52
- rubocop (0.93.1)
50
+ rspec-support (3.10.3)
51
+ rubocop (0.68.1)
52
+ jaro_winkler (~> 1.5.1)
53
53
  parallel (~> 1.10)
54
- parser (>= 2.7.1.5)
54
+ parser (>= 2.5, != 2.5.1.1)
55
55
  rainbow (>= 2.2.2, < 4.0)
56
- regexp_parser (>= 1.8)
57
- rexml
58
- rubocop-ast (>= 0.6.0)
59
56
  ruby-progressbar (~> 1.7)
60
- unicode-display_width (>= 1.4.0, < 2.0)
61
- rubocop-ast (1.4.1)
62
- parser (>= 2.7.1.5)
63
- rubocop-rspec (1.44.1)
64
- rubocop (~> 0.87)
65
- rubocop-ast (>= 0.7.1)
57
+ unicode-display_width (>= 1.4.0, < 1.6)
58
+ rubocop-rspec (1.24.0)
59
+ rubocop (>= 0.53.0)
66
60
  ruby-progressbar (1.11.0)
67
- simplecov (0.18.5)
68
- docile (~> 1.1)
69
- simplecov-html (~> 0.11)
70
- simplecov-html (0.12.3)
71
- thread_safe (0.3.6)
61
+ simplecov (0.15.1)
62
+ docile (~> 1.1.0)
63
+ json (>= 1.8, < 3)
64
+ simplecov-html (~> 0.10.0)
65
+ simplecov-html (0.10.2)
72
66
  timecop (0.9.4)
73
- tzinfo (1.2.9)
74
- thread_safe (~> 0.1)
75
- unicode-display_width (1.7.0)
67
+ tzinfo (2.0.4)
68
+ concurrent-ruby (~> 1.0)
69
+ unicode-display_width (1.5.0)
76
70
 
77
71
  PLATFORMS
78
72
  ruby
79
73
 
80
74
  DEPENDENCIES
81
75
  business_flow!
82
- reek (~> 6)
76
+ rake (~> 10.0)
77
+ reek (~> 4.8)
83
78
  retryable (~> 3.0.4)
84
79
  rspec (~> 3.0)
85
80
  rubocop (~> 0.53)
86
- rubocop-rspec (~> 1.24)
87
- simplecov (~> 0.15)
88
- timecop (~> 0.9)
81
+ rubocop-rspec (~> 1.24.0)
82
+ simplecov (~> 0.15.1)
83
+ timecop (~> 0.9.1)
89
84
 
90
85
  BUNDLED WITH
91
- 1.16.6
86
+ 2.3.6
@@ -20,14 +20,15 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.add_dependency 'activemodel', '~> 4.2'
24
- spec.add_dependency 'activesupport', '~> 4.2'
23
+ spec.add_dependency 'activemodel', '>= 4.2', '< 8'
24
+ spec.add_dependency 'activesupport', '>= 4.2', '< 8'
25
25
 
26
- spec.add_development_dependency 'reek', '~> 6'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'reek', '~> 4.8'
27
28
  spec.add_development_dependency 'retryable', '~> 3.0.4'
28
29
  spec.add_development_dependency 'rspec', '~> 3.0'
29
30
  spec.add_development_dependency 'rubocop', '~> 0.53'
30
- spec.add_development_dependency 'rubocop-rspec', '~> 1.24'
31
- spec.add_development_dependency 'simplecov', '~> 0.15'
32
- spec.add_development_dependency 'timecop', '~> 0.9'
31
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.24.0'
32
+ spec.add_development_dependency 'simplecov', '~> 0.15.1'
33
+ spec.add_development_dependency 'timecop', '~> 0.9.1'
33
34
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module BusinessFlow
2
4
  # include BusinessFlow::Base in any object to get a flow!
3
5
  module Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module BusinessFlow
2
4
  # Extends the DSL to support caching of completed processes
3
5
  module Cacheable
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module BusinessFlow
2
4
  # Isolate the logic around invoking a 'callable' -- a symbol representing a
3
5
  # method, a symbol representing another class which implements .call, or a
@@ -95,7 +97,7 @@ module BusinessFlow
95
97
 
96
98
  def lookup_callable(first_instance)
97
99
  constant_name = @callable.to_s.camelcase
98
- first_instance.class.parents.each do |parent|
100
+ first_instance.class.module_parents.each do |parent|
99
101
  begin
100
102
  return parent.const_get(constant_name)
101
103
  rescue NameError
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BusinessFlow
4
+ # Provides compatibility for ActiveSupport/Model 4.x through 7.x
5
+ module Compat
6
+ if !Module.instance_methods.include?(:module_parents)
7
+ # ActiveSupport 5 removed #parents in favor of #module_parents.
8
+ class ::Module
9
+ def module_parents
10
+ parents
11
+ end
12
+ end
13
+ end
14
+
15
+ if !ActiveModel::Errors.instance_methods.include?(:merge!)
16
+ # ActiveModel 5 added details (which we do not use here) and #merge!
17
+ # :reek:PrimaDonnaMethod Look it's the API.
18
+ class ::ActiveModel::Errors
19
+ def merge!(other)
20
+ other.each do |attribute, message|
21
+ self[attribute] << message
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module BusinessFlow
2
4
  # Default behavior for running a step queue -- execute each step in turn
3
5
  # halting the moment something goes wrong. Use the same flow as input
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module BusinessFlow
2
4
  # Core DSL for BusinessFlow. The relevant methods are all in
3
5
  # ClassMethods.
@@ -161,7 +163,7 @@ module BusinessFlow
161
163
  def needs_code
162
164
  needs.map do |need|
163
165
  %(if #{need}.nil?
164
- errors[:#{need}] << 'must not be nil'
166
+ errors.add(:#{need}, :invalid, message: 'must not be nil')
165
167
  throw :halt_step
166
168
  end
167
169
  )
@@ -220,6 +222,14 @@ module BusinessFlow
220
222
  def human_attribute_name(key, _opts = {})
221
223
  key
222
224
  end
225
+
226
+ # Provides the miniimum necessary instance methods to support the use of
227
+ # ActiveMode::Errors, outside of what's provided by ActiveModel::Naming
228
+ module InstanceMethods
229
+ def read_attribute_for_validation(key)
230
+ send(key)
231
+ end
232
+ end
223
233
  end
224
234
 
225
235
  # :reek:ManualDispatch I have no need to actually call human_attribute_name,
@@ -228,6 +238,8 @@ module BusinessFlow
228
238
  klass.extend(ClassMethods)
229
239
  klass.class_eval RESULT_DEF, __FILE__, __LINE__
230
240
  klass.extend(ErrorSupport) unless klass.respond_to?(:human_attribute_name)
241
+ klass.extend(ActiveModel::Naming)
242
+ klass.include(ErrorSupport::InstanceMethods) unless klass.respond_to?(:read_attribute_for_validation)
231
243
  end
232
244
 
233
245
  attr_reader :parameter_object
@@ -247,7 +259,7 @@ module BusinessFlow
247
259
  @parameter_object = parameter_object
248
260
  needs.each do |need|
249
261
  if send(need).nil?
250
- errors[need] << 'must not be nil'
262
+ errors.add(need, :invalid, message: 'must not be nil')
251
263
  throw :halt_step
252
264
  end
253
265
  end
@@ -357,7 +369,7 @@ module BusinessFlow
357
369
  klass.class_eval body, __FILE__, __LINE__
358
370
  end
359
371
 
360
- def self.setter_factory(field, ivar_name)
372
+ def self.setter_factory(_field, ivar_name)
361
373
  <<-SETTER
362
374
  #{ivar_name} = new_value
363
375
  SETTER
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module BusinessFlow
2
4
  # Exception raised by DSL when flow execution fails
3
5
  class FlowFailedException < RuntimeError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module BusinessFlow
2
4
  # Include me to fire ActiveSupport notifications on the flow, every step,
3
5
  # and for any errors that happen.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module BusinessFlow
2
4
  # Fire ActiveSupport events for every step that's run and on errors
3
5
  class InstrumentedExecutor < DefaultStepExecutor
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module BusinessFlow
2
4
  # Fire ActiveSupport events for every step that's run and on errors
3
5
  class InstrumentedStepExecutor < InstrumentedExecutor
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require 'retryable'
3
5
  rescue LoadError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module BusinessFlow
2
4
  # Step is a conditional callable which can marshal its own inputs, and
3
5
  # returns a value which can marshal errors and outputs into a given object.
@@ -90,9 +92,7 @@ module BusinessFlow
90
92
  end
91
93
 
92
94
  def merge_errors_into(object)
93
- @result.errors.each do |attribute, message|
94
- (object.errors[attribute] << message).uniq!
95
- end
95
+ object.errors.merge!(@result.errors)
96
96
  throw :halt_step
97
97
  end
98
98
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module BusinessFlow
2
4
  # Responsible for adding validations to flow objects
3
5
  module Validations
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module BusinessFlow
2
- VERSION = '0.17.4'.freeze
4
+ VERSION = '0.18.0'.freeze
3
5
  end
data/lib/business_flow.rb CHANGED
@@ -1,5 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_model'
2
4
  require 'active_support/core_ext'
5
+ require 'business_flow/compat'
3
6
  require 'business_flow/version'
4
7
  require 'business_flow/flow_failed_exception'
5
8
  require 'business_flow/callable'
metadata CHANGED
@@ -1,57 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: business_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.4
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Scarborough
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-08 00:00:00.000000000 Z
11
+ date: 2022-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '8'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '4.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '8'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: activesupport
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - "~>"
37
+ - - ">="
32
38
  - !ruby/object:Gem::Version
33
39
  version: '4.2'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '8'
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
- - - "~>"
47
+ - - ">="
39
48
  - !ruby/object:Gem::Version
40
49
  version: '4.2'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '8'
53
+ - !ruby/object:Gem::Dependency
54
+ name: rake
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '10.0'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '10.0'
41
67
  - !ruby/object:Gem::Dependency
42
68
  name: reek
43
69
  requirement: !ruby/object:Gem::Requirement
44
70
  requirements:
45
71
  - - "~>"
46
72
  - !ruby/object:Gem::Version
47
- version: '6'
73
+ version: '4.8'
48
74
  type: :development
49
75
  prerelease: false
50
76
  version_requirements: !ruby/object:Gem::Requirement
51
77
  requirements:
52
78
  - - "~>"
53
79
  - !ruby/object:Gem::Version
54
- version: '6'
80
+ version: '4.8'
55
81
  - !ruby/object:Gem::Dependency
56
82
  name: retryable
57
83
  requirement: !ruby/object:Gem::Requirement
@@ -100,42 +126,42 @@ dependencies:
100
126
  requirements:
101
127
  - - "~>"
102
128
  - !ruby/object:Gem::Version
103
- version: '1.24'
129
+ version: 1.24.0
104
130
  type: :development
105
131
  prerelease: false
106
132
  version_requirements: !ruby/object:Gem::Requirement
107
133
  requirements:
108
134
  - - "~>"
109
135
  - !ruby/object:Gem::Version
110
- version: '1.24'
136
+ version: 1.24.0
111
137
  - !ruby/object:Gem::Dependency
112
138
  name: simplecov
113
139
  requirement: !ruby/object:Gem::Requirement
114
140
  requirements:
115
141
  - - "~>"
116
142
  - !ruby/object:Gem::Version
117
- version: '0.15'
143
+ version: 0.15.1
118
144
  type: :development
119
145
  prerelease: false
120
146
  version_requirements: !ruby/object:Gem::Requirement
121
147
  requirements:
122
148
  - - "~>"
123
149
  - !ruby/object:Gem::Version
124
- version: '0.15'
150
+ version: 0.15.1
125
151
  - !ruby/object:Gem::Dependency
126
152
  name: timecop
127
153
  requirement: !ruby/object:Gem::Requirement
128
154
  requirements:
129
155
  - - "~>"
130
156
  - !ruby/object:Gem::Version
131
- version: '0.9'
157
+ version: 0.9.1
132
158
  type: :development
133
159
  prerelease: false
134
160
  version_requirements: !ruby/object:Gem::Requirement
135
161
  requirements:
136
162
  - - "~>"
137
163
  - !ruby/object:Gem::Version
138
- version: '0.9'
164
+ version: 0.9.1
139
165
  description:
140
166
  email:
141
167
  - alex@teak.io
@@ -158,6 +184,7 @@ files:
158
184
  - lib/business_flow/base.rb
159
185
  - lib/business_flow/cacheable.rb
160
186
  - lib/business_flow/callable.rb
187
+ - lib/business_flow/compat.rb
161
188
  - lib/business_flow/default_step_executor.rb
162
189
  - lib/business_flow/dsl.rb
163
190
  - lib/business_flow/flow_failed_exception.rb
@@ -187,8 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
214
  - !ruby/object:Gem::Version
188
215
  version: '0'
189
216
  requirements: []
190
- rubyforge_project:
191
- rubygems_version: 2.7.10
217
+ rubygems_version: 3.1.6
192
218
  signing_key:
193
219
  specification_version: 4
194
220
  summary: General purpose management of service object flows