Class: Itamae::Runner
- Inherits:
-
Object
- Object
- Itamae::Runner
- Defined in:
- lib/itamae/runner.rb
Instance Attribute Summary collapse
-
#backend ⇒ Object
readonly
Returns the value of attribute backend.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#tmpdir ⇒ Object
readonly
Returns the value of attribute tmpdir.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(backend, options) ⇒ Runner
constructor
A new instance of Runner.
- #load_recipes(paths) ⇒ Object
- #run(options) ⇒ Object
Constructor Details
#initialize(backend, options) ⇒ Runner
Returns a new instance of Runner.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/itamae/runner.rb', line 32 def initialize(backend, ) @backend = backend @options = @node = create_node @tmpdir = "/tmp/itamae_tmp" @children = RecipeChildren.new @backend.run_command(["mkdir", "-p", @tmpdir]) @backend.run_command(["chmod", "777", @tmpdir]) end |
Instance Attribute Details
#backend ⇒ Object (readonly)
Returns the value of attribute backend.
27 28 29 |
# File 'lib/itamae/runner.rb', line 27 def backend @backend end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
30 31 32 |
# File 'lib/itamae/runner.rb', line 30 def children @children end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
28 29 30 |
# File 'lib/itamae/runner.rb', line 28 def node @node end |
#tmpdir ⇒ Object (readonly)
Returns the value of attribute tmpdir.
29 30 31 |
# File 'lib/itamae/runner.rb', line 29 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 |
# File 'lib/itamae/runner.rb', line 8 def run(recipe_files, backend_type, ) Logger.info "Starting Itamae..." backend = Backend.create(backend_type, ) runner = self.new(backend, ) runner.load_recipes(recipe_files) if dot_file = [: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: [:dry_run]) end |
Instance Method Details
#load_recipes(paths) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/itamae/runner.rb', line 44 def load_recipes(paths) paths.each do |path| recipe = Recipe.new(self, File.(path)) children << recipe recipe.load end end |
#run(options) ⇒ Object
52 53 54 55 |
# File 'lib/itamae/runner.rb', line 52 def run() children.run() @backend.finalize end |