carry_out 1.0.0 → 1.1.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
  SHA1:
3
- metadata.gz: 85928342e0fda93fadd48a0609af90372244b406
4
- data.tar.gz: 50a55f7b851ae3363d1f8ff3a9bccae4720c0963
3
+ metadata.gz: 61806a31006a015a414678cc29c2dfec3102e821
4
+ data.tar.gz: c9119841ad6a1dc4556b8093cc2241b9c8d928fe
5
5
  SHA512:
6
- metadata.gz: bb251b2ce082f94ede7d254a57a6973a1f609c775951e1390dc8105fa14d007bb17a54c7849f51f8f540e9cf293e556137a167d6c9f0dc656f20f9d545d6c122
7
- data.tar.gz: 84f8722a4a273fd1b9ad0e5ce15fb608ba1f66a99681cc2aad81be3c2dee41c5657a313639d3f80fad1ede719c8825219303ce89d3a465453e58987d274a52c5
6
+ metadata.gz: ceae682a4aa09f8d815fa9ac960d451ff9009c2be4ed4c03ca89c020767c8c61854305cd61f2f776dd89468155d572923eed3d317550762c1d141c420e2e32b2
7
+ data.tar.gz: 48ae6d41753a17cb56f3e9515865e9d86c996973542928c88c90abaa7baa81598513f15e4a22beb4a50f954db5afbff0924df3abd39850ebde100d3940ec9330
@@ -14,19 +14,16 @@ module CarryOut
14
14
  begin
15
15
  node_result = node.call(plan_result.artifacts)
16
16
 
17
- if node_result.kind_of?(Plan::NodeResult) && node.returns_as
17
+ if node_result.kind_of?(Plan::NodeResult)
18
18
  plan_result.add(node.returns_as, node_result.value)
19
-
20
- if node_result.value.kind_of?(CarryOut::Result) && !node_result.value.success?
21
- break
22
- end
23
19
  end
24
-
25
- node = node.connects_to
26
20
  rescue StandardError => error
27
- plan_result.add (node.returns_as || :base), CarryOut::Error.new(error.message, error)
28
- break
21
+ error = CarryOut::Error.new(error.message, error) unless error.kind_of?(CarryOut::Error)
22
+ plan_result.add node.returns_as, error
29
23
  end
24
+
25
+ break unless plan_result.success?
26
+ node = node.connects_to
30
27
  end
31
28
  end
32
29
  end
@@ -1,3 +1,5 @@
1
+ require 'carry_out/result_error'
2
+
1
3
  module CarryOut
2
4
  class Result
3
5
 
@@ -7,20 +9,28 @@ module CarryOut
7
9
 
8
10
  def add(group, object)
9
11
  if object.kind_of?(CarryOut::Error)
10
- add_error(group, object)
11
- elsif object.kind_of?(Result)
12
- add(group, object.to_hash)
13
-
14
- object.errors.each do |g, errors|
15
- errors.each { |e| add(g,e) }
16
- end
17
- elsif object.kind_of?(Hash)
18
- artifacts[group] ||= {}
19
- object.each { |k,v| artifacts[group][k] = v }
20
- elsif !artifacts[group].nil?
21
- artifacts[group] = [ artifacts[group], object ].flatten(1)
12
+ errors << ResultError.new(
13
+ group: group,
14
+ message: object.message,
15
+ details: object.details
16
+ )
17
+ elsif object.kind_of?(Enumerable) && !object.kind_of?(Hash)
18
+ object.each { |o| add(group, o) }
22
19
  else
23
- artifacts[group] = object
20
+ unless group.nil?
21
+ if object.kind_of?(Hash)
22
+ artifacts[group] ||= {}
23
+ object.each { |k,v| artifacts[group][k] = v }
24
+ elsif object.kind_of?(Result)
25
+ add(group, object.to_hash)
26
+
27
+ object.errors.each do |error|
28
+ add([group, error.group].flatten(1), e)
29
+ end
30
+ else
31
+ artifacts[group] = object
32
+ end
33
+ end
24
34
  end
25
35
  end
26
36
 
@@ -29,7 +39,7 @@ module CarryOut
29
39
  end
30
40
 
31
41
  def errors
32
- @errors ||= {}
42
+ @errors ||= []
33
43
  end
34
44
 
35
45
  def success?
@@ -39,11 +49,5 @@ module CarryOut
39
49
  def to_hash
40
50
  artifacts
41
51
  end
42
-
43
- private
44
- def add_error(group, error)
45
- group = errors[group] ||= []
46
- group << error
47
- end
48
52
  end
49
53
  end
@@ -0,0 +1,13 @@
1
+ module CarryOut
2
+ class ResultError
3
+ attr_reader :details
4
+ attr_reader :group
5
+ attr_reader :message
6
+
7
+ def initialize(options = {})
8
+ @details = options[:details]
9
+ @group = options[:group]
10
+ @message = options[:message]
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module CarryOut
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/carry_out.rb CHANGED
@@ -27,7 +27,12 @@ module CarryOut
27
27
  def self.plan(options = {}, &block)
28
28
  merged_options = Hash.new.merge(configuration).merge(options)
29
29
  plan = PlanBuilder.build(merged_options, &block)
30
- -> (context = nil) { PlanRunner.run(plan, context) }
30
+
31
+ Proc.new do |context = nil, &block|
32
+ PlanRunner.run(plan, context).tap do |result|
33
+ block.call(result) unless block.nil?
34
+ end
35
+ end
31
36
  end
32
37
 
33
38
  def self.configuration
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carry_out
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Fields
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-11 00:00:00.000000000 Z
11
+ date: 2017-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -112,6 +112,7 @@ files:
112
112
  - lib/carry_out/plan_builder.rb
113
113
  - lib/carry_out/plan_runner.rb
114
114
  - lib/carry_out/result.rb
115
+ - lib/carry_out/result_error.rb
115
116
  - lib/carry_out/unit.rb
116
117
  - lib/carry_out/version.rb
117
118
  homepage: https://github.com/ryanfields/carry_out