business_flow 0.17.5 → 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: 18b848fddcc8032b22020398c2b1cfa80cc41c243415f49bbbe9ef47ca273d6a
4
- data.tar.gz: cdf6b62f0c354cde981a09c100f5de588956cc07599eb37d9604d2f6d743700c
3
+ metadata.gz: 6b1ad94958c6313af360e1343b5fd5ac9603e8e4aa7834581c40e53631de8a51
4
+ data.tar.gz: 5562160edcf999491ae6f7d32afdb8f2b7e3479e9141b202021a9fe2ce46144e
5
5
  SHA512:
6
- metadata.gz: 2980690e93a0c7d56ebf2020984c39a8a85d5cae78c8d8d8610c7ca74f1513c4b051816d06ff6d040b3369df709b57967dba8db66d5d4b2a2573d8e23beb3bb7
7
- data.tar.gz: 3b2be0ac6d8c86438dddb9ef7efc1ea062d7709378137d6db2307147fdfec7d84a5038d008d0ac87e3cc8a6f0dac7c64589668c7e283bbe17fb26967c8572f99
6
+ metadata.gz: 55311f2cf46499c01f1fb6c9886a6eace211696a17968eb9f4864696f650e573fa0343be4e9386d3fcce14daec28326d75f61fddd4e206d1a5a2a7275f4fa90e
7
+ data.tar.gz: 32ddef13a80d803eb0d95e0d8511ed4bd93b68866fa326d6b22fe770d618553cbfee48c1e5aa167501f3ed83d69d707482b28c1dc4d20896f5e5c0f44cef3c51
data/Gemfile.lock CHANGED
@@ -1,95 +1,77 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- business_flow (0.17.5)
5
- activemodel (>= 3.0)
6
- activesupport (>= 3.0)
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 (5.1.6)
12
- activesupport (= 5.1.6)
13
- activesupport (5.1.6)
11
+ activemodel (7.0.2)
12
+ activesupport (= 7.0.2)
13
+ activesupport (7.0.2)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
- i18n (>= 0.7, < 2)
16
- minitest (~> 5.1)
17
- tzinfo (~> 1.1)
18
- ast (2.4.0)
19
- axiom-types (0.1.1)
20
- descendants_tracker (~> 0.0.4)
21
- ice_nine (~> 0.11.0)
22
- thread_safe (~> 0.3, >= 0.3.1)
23
- codeclimate-engine-rb (0.4.1)
24
- virtus (~> 1.0)
25
- coercible (1.0.0)
26
- descendants_tracker (~> 0.0.1)
27
- concurrent-ruby (1.0.5)
28
- descendants_tracker (0.0.4)
29
- thread_safe (~> 0.3, >= 0.3.1)
30
- diff-lcs (1.3)
15
+ i18n (>= 1.6, < 2)
16
+ minitest (>= 5.1)
17
+ tzinfo (~> 2.0)
18
+ ast (2.4.2)
19
+ codeclimate-engine-rb (0.4.2)
20
+ concurrent-ruby (1.1.9)
21
+ diff-lcs (1.5.0)
31
22
  docile (1.1.5)
32
- equalizer (0.0.11)
33
- i18n (1.0.0)
23
+ i18n (1.9.1)
34
24
  concurrent-ruby (~> 1.0)
35
- ice_nine (0.11.2)
36
- json (2.1.0)
37
- minitest (5.11.3)
38
- parallel (1.12.1)
39
- parser (2.5.0.4)
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)
40
30
  ast (~> 2.4.0)
41
- powerpack (0.1.1)
42
- rainbow (3.0.0)
31
+ rainbow (3.1.1)
43
32
  rake (10.5.0)
44
- reek (4.8.0)
33
+ reek (4.8.2)
45
34
  codeclimate-engine-rb (~> 0.4.0)
46
35
  parser (>= 2.5.0.0, < 2.6)
47
- rainbow (~> 3.0)
48
- retryable (3.0.4)
49
- rspec (3.7.0)
50
- rspec-core (~> 3.7.0)
51
- rspec-expectations (~> 3.7.0)
52
- rspec-mocks (~> 3.7.0)
53
- rspec-core (3.7.1)
54
- rspec-support (~> 3.7.0)
55
- rspec-expectations (3.7.0)
36
+ rainbow (>= 2.0, < 4.0)
37
+ retryable (3.0.5)
38
+ rspec (3.10.0)
39
+ rspec-core (~> 3.10.0)
40
+ rspec-expectations (~> 3.10.0)
41
+ rspec-mocks (~> 3.10.0)
42
+ rspec-core (3.10.2)
43
+ rspec-support (~> 3.10.0)
44
+ rspec-expectations (3.10.2)
56
45
  diff-lcs (>= 1.2.0, < 2.0)
57
- rspec-support (~> 3.7.0)
58
- rspec-mocks (3.7.0)
46
+ rspec-support (~> 3.10.0)
47
+ rspec-mocks (3.10.3)
59
48
  diff-lcs (>= 1.2.0, < 2.0)
60
- rspec-support (~> 3.7.0)
61
- rspec-support (3.7.1)
62
- rubocop (0.53.0)
49
+ rspec-support (~> 3.10.0)
50
+ rspec-support (3.10.3)
51
+ rubocop (0.68.1)
52
+ jaro_winkler (~> 1.5.1)
63
53
  parallel (~> 1.10)
64
- parser (>= 2.5)
65
- powerpack (~> 0.1)
54
+ parser (>= 2.5, != 2.5.1.1)
66
55
  rainbow (>= 2.2.2, < 4.0)
67
56
  ruby-progressbar (~> 1.7)
68
- unicode-display_width (~> 1.0, >= 1.0.1)
57
+ unicode-display_width (>= 1.4.0, < 1.6)
69
58
  rubocop-rspec (1.24.0)
70
59
  rubocop (>= 0.53.0)
71
- ruby-progressbar (1.9.0)
60
+ ruby-progressbar (1.11.0)
72
61
  simplecov (0.15.1)
73
62
  docile (~> 1.1.0)
74
63
  json (>= 1.8, < 3)
75
64
  simplecov-html (~> 0.10.0)
76
65
  simplecov-html (0.10.2)
77
- thread_safe (0.3.6)
78
- timecop (0.9.1)
79
- tzinfo (1.2.5)
80
- thread_safe (~> 0.1)
81
- unicode-display_width (1.3.0)
82
- virtus (1.0.5)
83
- axiom-types (~> 0.1)
84
- coercible (~> 1.0)
85
- descendants_tracker (~> 0.0, >= 0.0.3)
86
- equalizer (~> 0.0, >= 0.0.9)
66
+ timecop (0.9.4)
67
+ tzinfo (2.0.4)
68
+ concurrent-ruby (~> 1.0)
69
+ unicode-display_width (1.5.0)
87
70
 
88
71
  PLATFORMS
89
72
  ruby
90
73
 
91
74
  DEPENDENCIES
92
- bundler (~> 1.16)
93
75
  business_flow!
94
76
  rake (~> 10.0)
95
77
  reek (~> 4.8)
@@ -101,4 +83,4 @@ DEPENDENCIES
101
83
  timecop (~> 0.9.1)
102
84
 
103
85
  BUNDLED WITH
104
- 1.16.1
86
+ 2.3.6
@@ -20,10 +20,9 @@ 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', '>= 3.0'
24
- spec.add_dependency 'activesupport', '>= 3.0'
23
+ spec.add_dependency 'activemodel', '>= 4.2', '< 8'
24
+ spec.add_dependency 'activesupport', '>= 4.2', '< 8'
25
25
 
26
- spec.add_development_dependency 'bundler', '~> 1.16'
27
26
  spec.add_development_dependency 'rake', '~> 10.0'
28
27
  spec.add_development_dependency 'reek', '~> 4.8'
29
28
  spec.add_development_dependency 'retryable', '~> 3.0.4'
@@ -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
@@ -50,8 +52,7 @@ module BusinessFlow
50
52
  end
51
53
  end
52
54
 
53
- def cache_key(key = nil, &blk)
54
- key ||= blk
55
+ def cache_key(key = nil)
55
56
  if key
56
57
  @cache_key = Callable.new(key)
57
58
  else
@@ -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.5'.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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: business_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.5
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: 2022-11-01 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
@@ -16,42 +16,40 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
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
- version: '3.0'
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
- version: '3.0'
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
- version: '3.0'
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.16'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
49
+ version: '4.2'
50
+ - - "<"
53
51
  - !ruby/object:Gem::Version
54
- version: '1.16'
52
+ version: '8'
55
53
  - !ruby/object:Gem::Dependency
56
54
  name: rake
57
55
  requirement: !ruby/object:Gem::Requirement
@@ -186,6 +184,7 @@ files:
186
184
  - lib/business_flow/base.rb
187
185
  - lib/business_flow/cacheable.rb
188
186
  - lib/business_flow/callable.rb
187
+ - lib/business_flow/compat.rb
189
188
  - lib/business_flow/default_step_executor.rb
190
189
  - lib/business_flow/dsl.rb
191
190
  - lib/business_flow/flow_failed_exception.rb