class Amigrind::Blueprints::Evaluator
Attributes
blueprint[R]
Public Class Methods
evaluate(filename, environment = nil)
click to toggle source
# File lib/amigrind/blueprints/evaluator.rb, line 38 def self.evaluate(filename, environment = nil) Evaluator.new(filename, environment).blueprint end
new(filename, environment = nil)
click to toggle source
# File lib/amigrind/blueprints/evaluator.rb, line 9 def initialize(filename, environment = nil) @blueprint = Blueprint.new @blueprint.name = File.basename(filename, ".rb") regex = Amigrind::Core::BLUEPRINT_NAME_REGEX raise "blueprint name (#{@blueprint.name}) must match #{regex.source}" \ unless regex.match(@blueprint.name) @properties = if environment.nil? debug_log "no environment found to use with blueprint" {} else debug_log "using environment '#{environment.name}' with blueprint" environment.properties.merge(environment_name: environment.name) end unless environment.nil? @blueprint.aws.vpc_id = environment.aws.vpc @blueprint.aws.subnet_ids = environment.aws.subnets @blueprint.aws.region = environment.aws.region @blueprint.aws.copy_regions = environment.aws.copy_regions @blueprint.aws.ssh_keypair_name = environment.aws.ssh_keypair_name end instance_eval(IO.read(filename), File.expand_path(filename), 0) end
Public Instance Methods
properties()
click to toggle source
# File lib/amigrind/blueprints/evaluator.rb, line 42 def properties @properties end
Private Instance Methods
aws(&block)
click to toggle source
# File lib/amigrind/blueprints/evaluator.rb, line 76 def aws(&block) AWSConfigEvaluator.new(@blueprint, self, &block) end
build_channel(b)
click to toggle source
# File lib/amigrind/blueprints/evaluator.rb, line 48 def build_channel(b) raise "'build_channel' must be a String or Symbol." \ unless b.is_a?(String) || b.is_a?(Symbol) @blueprint.build_channel = b end
description(d)
click to toggle source
# File lib/amigrind/blueprints/evaluator.rb, line 55 def description(d) raise "'description' must be a String." unless d.is_a?(String) @blueprint.description = d end
parent_blueprint(p)
click to toggle source
# File lib/amigrind/blueprints/evaluator.rb, line 60 def parent_blueprint(p) raise "'parent_blueprint' must be a String." unless p.is_a?(String) @blueprint.source = p end
provisioner(name, provisioner_class, weight: nil, &block)
click to toggle source
# File lib/amigrind/blueprints/evaluator.rb, line 80 def provisioner(name, provisioner_class, weight: nil, &block) highest_provisioner = @blueprint.provisioners.max_by(&:weight) weight ||= (highest_provisioner.nil? ? 0 : highest_provisioner.weight) + 1 raise "'name' must be a String or Symbol." \ unless name.is_a?(String) || name.is_a?(Symbol) raise "'provisioner_class' must inherit from Amigrind::Blueprints::Provisioner" \ unless provisioner_class.ancestors.include?(Amigrind::Blueprints::Provisioner) raise "'weight' must be a Fixnum." unless weight.is_a?(Fixnum) @blueprint.provisioners << ProvisionerEvaluator.new(name, self, weight, provisioner_class, &block).provisioner end
source(type, &block)
click to toggle source
# File lib/amigrind/blueprints/evaluator.rb, line 65 def source(type, &block) case type when :ami BaseAMIEvaluator.new(@blueprint, self, &block) when :parent ParentBlueprintEvaluator.new(@blueprint, self, &block) else raise "Invalid source type: #{type} (must be :ami, :parent)" end end