Sha256: 9864f28464326121b267978cb255ba3d36796f9110af429aee479f72d2891d40
Contents?: true
Size: 1.23 KB
Versions: 10
Compression:
Stored size: 1.23 KB
Contents
require 'itamae' module Itamae class Recipe attr_reader :path attr_reader :runner attr_reader :dependencies attr_reader :delayed_actions def initialize(runner, path) @runner = runner @path = path @dependencies = RecipeDependencies.new @delayed_actions = [] load_dependencies end def node @runner.node end def run(options = {}) @dependencies.each do |resource| case resource when Resource::Base resource.run(nil, dry_run: options[:dry_run]) when Recipe resource.run(options) end end @delayed_actions.uniq.each do |action, resource| resource.run(action, dry_run: options[:dry_run]) end end private def load_dependencies instance_eval(File.read(@path), @path, 1) end def method_missing(method, name, &block) klass = Resource.get_resource_class(method) resource = klass.new(self, name, &block) @dependencies << resource rescue NameError super end def include_recipe(target) target = ::File.expand_path(target, File.dirname(@path)) recipe = Recipe.new(@runner, target) @dependencies << recipe end end end
Version data entries
10 entries across 10 versions & 1 rubygems