carry_out 1.2.0 → 1.3.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 +4 -4
- data/lib/carry_out.rb +9 -1
- data/lib/carry_out/plan_runner.rb +8 -5
- data/lib/carry_out/result.rb +14 -21
- data/lib/carry_out/result_error.rb +0 -2
- data/lib/carry_out/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93f80c00a226b8751663d149943b30aeb5c2dd35
|
4
|
+
data.tar.gz: 4561dba1b6110b7dbc1a4712ba4fde4204910608
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f5521e863a205ae3345357df363613e5ef14c29974a31e08f67367aab963c0c7303caa2a43fa78db1dab3d8b8890fe18825dbf4273e1a7f7f27b538ca4f84bc
|
7
|
+
data.tar.gz: a390316064acff75e07c46dbb9124278bdcc27baa9584a1f75de23cf4be38a894dd27adb7a27759c6edbafe9c3353222d5c0d85832199f16b88426104dbc46ea
|
data/lib/carry_out.rb
CHANGED
@@ -18,6 +18,14 @@ module CarryOut
|
|
18
18
|
def plan(options = {}, &block)
|
19
19
|
CarryOut.plan(Hash.new.merge(@options).merge(options), &block)
|
20
20
|
end
|
21
|
+
|
22
|
+
def call_unit(*args, &block)
|
23
|
+
CarryOut.call_unit(*args)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.call_unit(*args, &block)
|
28
|
+
PlanRunner.call_unit(*args, &block)
|
21
29
|
end
|
22
30
|
|
23
31
|
def self.configure(&block)
|
@@ -29,7 +37,7 @@ module CarryOut
|
|
29
37
|
plan = PlanBuilder.build(merged_options, &block)
|
30
38
|
|
31
39
|
Proc.new do |context = nil, &block|
|
32
|
-
PlanRunner.
|
40
|
+
PlanRunner.call(plan, context).tap do |result|
|
33
41
|
block.call(result) unless block.nil?
|
34
42
|
end
|
35
43
|
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module CarryOut
|
2
2
|
class PlanRunner
|
3
|
-
def self.
|
4
|
-
PlanRunner.new.run(plan, context)
|
5
|
-
end
|
6
|
-
|
7
|
-
def run(plan, context = {})
|
3
|
+
def self.call(plan, context = {})
|
8
4
|
Result.new(context).tap do |plan_result|
|
9
5
|
node = plan
|
10
6
|
|
@@ -27,5 +23,12 @@ module CarryOut
|
|
27
23
|
end
|
28
24
|
end
|
29
25
|
end
|
26
|
+
|
27
|
+
def self.call_unit(unit, context = {}, &block)
|
28
|
+
node = Plan::Node.new(unit)
|
29
|
+
Plan::NodeContext.new(node).instance_eval(&block) unless block.nil?
|
30
|
+
|
31
|
+
call(node, context)
|
32
|
+
end
|
30
33
|
end
|
31
34
|
end
|
data/lib/carry_out/result.rb
CHANGED
@@ -9,11 +9,16 @@ module CarryOut
|
|
9
9
|
|
10
10
|
def add(group, object)
|
11
11
|
if object.kind_of?(CarryOut::Error)
|
12
|
-
|
13
|
-
group: group,
|
12
|
+
object = ResultError.new(
|
14
13
|
message: object.message,
|
15
14
|
details: object.details
|
16
15
|
)
|
16
|
+
end
|
17
|
+
|
18
|
+
if object.kind_of?(CarryOut::ResultError)
|
19
|
+
group = group || :_unlabeled
|
20
|
+
errors[group] ||= []
|
21
|
+
errors[group] << object
|
17
22
|
elsif object.kind_of?(Enumerable) && object.all? { |o| o.kind_of?(CarryOut::Error) }
|
18
23
|
object.each { |o| add(group, o) }
|
19
24
|
else
|
@@ -22,10 +27,12 @@ module CarryOut
|
|
22
27
|
artifacts[group] ||= {}
|
23
28
|
object.each { |k,v| artifacts[group][k] = v }
|
24
29
|
elsif object.kind_of?(Result)
|
25
|
-
add(group, object.
|
26
|
-
|
27
|
-
object.errors.each do |
|
28
|
-
|
30
|
+
add(group, object.artifacts)
|
31
|
+
|
32
|
+
object.errors.each do |g, errors|
|
33
|
+
error_group = [ group, g ]
|
34
|
+
|
35
|
+
errors.each { |e| add(error_group, e) }
|
29
36
|
end
|
30
37
|
else
|
31
38
|
artifacts[group] = object
|
@@ -39,25 +46,11 @@ module CarryOut
|
|
39
46
|
end
|
40
47
|
|
41
48
|
def errors
|
42
|
-
@errors ||=
|
43
|
-
end
|
44
|
-
|
45
|
-
def errors_hash
|
46
|
-
Hash.new.tap do |h|
|
47
|
-
errors.each do |e|
|
48
|
-
if e.details.kind_of?(Hash)
|
49
|
-
h.merge!(e.details)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
49
|
+
@errors ||= {}
|
53
50
|
end
|
54
51
|
|
55
52
|
def success?
|
56
53
|
@errors.nil? || @errors.empty?
|
57
54
|
end
|
58
|
-
|
59
|
-
def to_hash
|
60
|
-
artifacts
|
61
|
-
end
|
62
55
|
end
|
63
56
|
end
|
data/lib/carry_out/version.rb
CHANGED
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.
|
4
|
+
version: 1.3.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
|
+
date: 2017-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|