crack_pipe 0.2.2 → 0.2.3

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
  SHA1:
3
- metadata.gz: 2fa69e90cc9e841966e6651c94022c2c8d681524
4
- data.tar.gz: 51f93274e6266fd7719ea7ab22f65f9f8cffaace
3
+ metadata.gz: 2f69aa51b284be0cc4591174c988f58739859c43
4
+ data.tar.gz: a010016caa3ca329aa077c66482977ce15671ed5
5
5
  SHA512:
6
- metadata.gz: 43ce34d2f457616bd614a6098c12aa3be3cd4f83d7c680065751c6886532af6cf114a4b6c0c70d12b8151d74b443c531fdc007134499a379bc9fcfcca41682c8
7
- data.tar.gz: 3a7590c007d3d101ebec37576ce00b4e96e823a54e18950b22ed5d90ed44e7030b0c6e44a31f2286b81f207035464ba4e0c20f559da7941a23062ecba92fd9fb
6
+ metadata.gz: 365bdf787f4e67acfcfdec26c5496c221dc86f7900b266fb0b0985790917ff0800505850125e23a4634203c9e660399b452ef4b2e012af2ec90c8fa0da4c2c11
7
+ data.tar.gz: 8870e300e25b7b9b8aaebb21a2663cb15190c524fd7edc365ef09a7f7ac8e7bf599fde9f1b8d4c122f00bdde58b154a31d58879297be806be57439ee1aa2b953
@@ -11,7 +11,7 @@ module CrackPipe
11
11
  end
12
12
 
13
13
  def action(action, context, track = :default)
14
- action.steps.each_with_object([]) do |s, results|
14
+ action.class.steps.each_with_object([]) do |s, results|
15
15
  next unless track == s.track
16
16
  results!(results, action, s, context).last.tap do |r|
17
17
  action.after_flow_control(r)
@@ -51,14 +51,13 @@ module CrackPipe
51
51
  end
52
52
 
53
53
  def step(action, step, context)
54
+ kwargs = kwargs_with_context(action, context)
55
+
54
56
  output = catch(:signal) do
55
- case (e = step.exec)
56
- when Symbol
57
- action.public_send(e, context, **context)
58
- when Proc
59
- action.instance_exec(context, **context, &e)
57
+ if (e = step.exec).is_a?(Symbol)
58
+ action.public_send(e, context, **kwargs)
60
59
  else
61
- e.call(context, **context)
60
+ e.call(context, **kwargs)
62
61
  end
63
62
  end
64
63
 
@@ -71,6 +70,11 @@ module CrackPipe
71
70
 
72
71
  private
73
72
 
73
+ def kwargs_with_context(action, context)
74
+ return context if action.kwargs_overrides.empty?
75
+ context.merge(action.kwargs_overrides)
76
+ end
77
+
74
78
  def results!(results, action, step, context)
75
79
  o = step(action, step, context)
76
80
  return results.concat(o.history) if o.is_a?(Result)
@@ -44,16 +44,14 @@ module CrackPipe
44
44
  end
45
45
  end
46
46
 
47
- attr_reader :steps
47
+ attr_reader :kwargs_overrides
48
48
 
49
- def initialize(steps = nil, **default_context, &blk)
50
- @__default_context__ = default_context.dup
49
+ def initialize(**kwargs_overrides, &blk)
51
50
  @__wrapper__ = block_given? ? blk : nil
52
- @steps = steps ? steps.dup : self.class.steps
51
+ @kwargs_overrides = kwargs_overrides
53
52
  end
54
53
 
55
54
  def call(context, **)
56
- context = @__default_context__.merge(context)
57
55
  return @__wrapper__.call(Exec.(self, context)) if @__wrapper__
58
56
  Exec.(self, context)
59
57
  end
@@ -75,7 +73,7 @@ module CrackPipe
75
73
  output
76
74
  end
77
75
 
78
- def fail!(output)
76
+ def fail!(output = nil)
79
77
  Exec.halt(output, false)
80
78
  end
81
79
 
@@ -3,7 +3,7 @@
3
3
  module CrackPipe
4
4
  MAJOR = 0
5
5
  MINOR = 2
6
- TINY = 2
6
+ TINY = 3
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.2
4
+ version: 0.2.3
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-03 00:00:00.000000000 Z
12
+ date: 2019-07-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler