Class: Katte::Runner

Inherits:
Object
  • Object
show all
Includes:
Callback
Defined in:
lib/katte/runner.rb

Defined Under Namespace

Modules: Callback

Instance Method Summary collapse

Methods included from Callback

#call_after_callbacks, #call_before_callbacks, included

Constructor Details

#initializeRunner

Returns a new instance of Runner.



16
17
# File 'lib/katte/runner.rb', line 16

def initialize
end

Instance Method Details

#builtin_nodesObject



25
26
27
# File 'lib/katte/runner.rb', line 25

def builtin_nodes
  Plugins::Node.plugins.values
end

#connect_nodesObject



37
38
39
# File 'lib/katte/runner.rb', line 37

def connect_nodes
  @nodes.connect
end

#executeObject



41
42
43
# File 'lib/katte/runner.rb', line 41

def execute
  @summary = Driver.run(@nodes)
end

#load_nodesObject



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


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_nodesObject



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

#runObject



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