crack_pipe 0.2.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee187d314abb9bfab155824f0d2c92825ef2f0e7
4
- data.tar.gz: fc720da093abcfbf35c625488d3904012114b193
3
+ metadata.gz: 33e156e850dd1455ecf3bb6f49d52b2441531dae
4
+ data.tar.gz: 9c20ce57c7b9bdca028fe10facdbe000429d243b
5
5
  SHA512:
6
- metadata.gz: 4704be40ad6adbf04cd9ed32a03915294e36479481aa1b2711171023d12d9ec17176b0286dd109e74c296fef46fc147e67211f1a27e79d55b257811137378052
7
- data.tar.gz: fcfef7cacbaafd4ab99ccdc65ee8fe7daeb5b5c6cf0769ddbc3d841faee17a29e9b896217ed7b68feae10fde546c40920c342e57f172465d45066779eed5f8f6
6
+ metadata.gz: 1bdd788b6e58171c7ef9ca8c667f9931749bf6e08453f7a9a5c13406003df0ebc0bd0a3d11ca173d41acd5d49092050f46b3b91dda6c29720148e4573a9efff5
7
+ data.tar.gz: 10466088e351eb02413af98ac0fc6baf83846e8ee94801f66234cbbe9e8a6d3c857527d963e21a5e493a29ba68889052c0563a6cce0c02c920138f5807bfc3ed
@@ -7,23 +7,16 @@ module CrackPipe
7
7
  module Exec
8
8
  class << self
9
9
  def call(action, context, track = :default)
10
- Result.new(action(action, context, [], track))
10
+ Result.new(action(action, context, track))
11
11
  end
12
12
 
13
- def action(action, context, results = [], track = :default)
14
- action.steps.each_with_object(results) do |s, rslts|
13
+ def action(action, context, track = :default)
14
+ action.steps.each_with_object([]) do |s, results|
15
15
  next unless track == s.track
16
-
17
- if s.exec.is_a?(Action)
18
- self.action(s.exec, context, rslts)
19
- else
20
- rslts << step(action, s, context)
21
- end
22
-
23
- rslts.last.tap do |r|
16
+ results!(results, action, s, context).last.tap do |r|
24
17
  context = r[:context]
25
18
  track = r[:next]
26
- return rslts if r[:signal] == :halt
19
+ return results if r[:signal] == :halt
27
20
  end
28
21
  end
29
22
  end
@@ -68,12 +61,20 @@ module CrackPipe
68
61
  end
69
62
  end
70
63
 
71
- action.after_step(flow_control_hash(action, step, context, output))
64
+ action.after_step(output)
72
65
  end
73
66
 
74
67
  def success_with_step?(action, step, output)
75
68
  step.always_pass? || step.track != :fail && !action.failure?(output)
76
69
  end
70
+
71
+ private
72
+
73
+ def results!(results, action, step, context)
74
+ o = step(action, step, context)
75
+ return results.concat(o.history) if o.is_a?(Result)
76
+ results << flow_control_hash(action, step, context, o)
77
+ end
77
78
  end
78
79
  end
79
80
  end
@@ -52,7 +52,7 @@ module CrackPipe
52
52
  @steps = steps ? steps.dup : self.class.steps
53
53
  end
54
54
 
55
- def call(context)
55
+ def call(context, **)
56
56
  context = @__default_context__.merge(context)
57
57
  return @__wrapper__.call(Exec.(self, context)) if @__wrapper__
58
58
  Exec.(self, context)
@@ -63,8 +63,8 @@ module CrackPipe
63
63
  # for output or adding values to the context. A common example would be
64
64
  # returning some kind of default failure object in place of a literal `nil`
65
65
  # or `false`.
66
- def after_step(flow_control_hash)
67
- flow_control_hash
66
+ def after_step(output)
67
+ output
68
68
  end
69
69
 
70
70
  def fail!(output)
@@ -72,7 +72,7 @@ module CrackPipe
72
72
  end
73
73
 
74
74
  def failure?(output)
75
- !output
75
+ output.is_a?(Result) ? output.failure? : !output
76
76
  end
77
77
 
78
78
  def pass!(output)
@@ -3,7 +3,7 @@
3
3
  module CrackPipe
4
4
  MAJOR = 0
5
5
  MINOR = 2
6
- TINY = 0
6
+ TINY = 1
7
7
  VERSION = [MAJOR, MINOR, TINY].join('.').freeze
8
8
 
9
9
  def self.version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crack_pipe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-07-02 00:00:00.000000000 Z
12
+ date: 2019-07-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler