Class: Katte::Runner
Defined Under Namespace
Modules: Callback
Instance Method Summary
collapse
Methods included from Callback
#call_after_callbacks, #call_before_callbacks, included
Constructor Details
#initialize ⇒ Runner
Returns a new instance of Runner.
16
17
|
# File 'lib/katte/runner.rb', line 16
def initialize
end
|
Instance Method Details
#builtin_nodes ⇒ Object
25
26
27
|
# File 'lib/katte/runner.rb', line 25
def builtin_nodes
Plugins::Node.plugins.values
end
|
#connect_nodes ⇒ Object
37
38
39
|
# File 'lib/katte/runner.rb', line 37
def connect_nodes
@nodes.connect
end
|
#execute ⇒ Object
41
42
43
|
# File 'lib/katte/runner.rb', line 41
def execute
@summary = Driver.run(@nodes)
end
|
#load_nodes ⇒ Object
19
20
21
22
23
24
|
# File 'lib/katte/runner.rb', line 19
def load_nodes
@nodes = Katte::Node::Collection.new
(builtin_nodes + recipe_nodes).each {|node| @nodes << node }
call_after_callbacks(:load_nodes, @nodes)
end
|
#print_summary ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/katte/runner.rb', line 45
def print_summary
return if Katte.app.config.mode == 'test'
summray_log_file = File.join(Katte.app.config.log_root, 'summary.log')
File.open(summray_log_file, 'w') do |file|
file.print <<-EOF
Summary:
success: #{@summary[:success].length}
fail: #{@summary[:fail].length}
skip: #{@summary[:skip].length}
EOF
end
failed_log_file = File.join(Katte.app.config.log_root, 'failed.log')
File.open(failed_log_file, 'w') do |file|
@summary[:fail].each do |node|
file.puts node.name
end
end
end
|
#recipe_nodes ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/katte/runner.rb', line 28
def recipe_nodes
node_factory = Katte.app.config.factory || Katte::Recipe::NodeFactory.new
Find.find(Katte.app.config.recipes_root).select {|file|
File.file? file
}.map {|file|
node_factory.load(file)
}
end
|
#run ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/katte/runner.rb', line 6
def run
load_nodes
connect_nodes
execute
print_summary
end
|