Class: Itamae::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/itamae/runner.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Runner


93
94
95
96
97
98
99
100
# File 'lib/itamae/runner.rb', line 93

def initialize(node)
  @node = node
  @tmpdir = "/tmp/itamae_tmp"
  @children = RecipeChildren.new

  Backend.instance.run_command(["mkdir", "-p", @tmpdir])
  Backend.instance.run_command(["chmod", "777", @tmpdir])
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children


91
92
93
# File 'lib/itamae/runner.rb', line 91

def children
  @children
end

#nodeObject

Returns the value of attribute node


89
90
91
# File 'lib/itamae/runner.rb', line 89

def node
  @node
end

#tmpdirObject

Returns the value of attribute tmpdir


90
91
92
# File 'lib/itamae/runner.rb', line 90

def tmpdir
  @tmpdir
end

Class Method Details

.run(recipe_files, backend_type, options) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/itamae/runner.rb', line 8

def run(recipe_files, backend_type, options)
  Logger.info "Starting Itamae..."

  set_backend_from_options(backend_type, options)

  runner = self.new(node_from_options(options))
  runner.load_recipes(recipe_files)

  if dot_file = options[:dot]
    Logger.info "Writing dependency graph in DOT to #{dot_file}..."
    open(dot_file, 'w') do |f|
      f.write(runner.children.deps_in_dot)
    end
    return
  end

  runner.run(dry_run: options[:dry_run])
end

Instance Method Details

#load_recipes(paths) ⇒ Object


102
103
104
105
106
107
108
# File 'lib/itamae/runner.rb', line 102

def load_recipes(paths)
  paths.each do |path|
    recipe = Recipe.new(self, File.expand_path(path))
    children << recipe
    recipe.load
  end
end

#run(options) ⇒ Object


110
111
112
# File 'lib/itamae/runner.rb', line 110

def run(options)
  children.run(options)
end