Class: Amigrind::Blueprints::Evaluator

Inherits:
Object
  • Object
show all
Includes:
Provisioners, Core::Logging::Mixin
Defined in:
lib/amigrind/blueprints/evaluator.rb

Defined Under Namespace

Classes: AWSConfigEvaluator, BaseAMIEvaluator, ParentBlueprintEvaluator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, environment = nil) ⇒ Evaluator

Returns a new instance of Evaluator.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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

Instance Attribute Details

#blueprintObject (readonly)

Returns the value of attribute blueprint.



7
8
9
# File 'lib/amigrind/blueprints/evaluator.rb', line 7

def blueprint
  @blueprint
end

Class Method Details

.evaluate(filename, environment = nil) ⇒ Object



38
39
40
# File 'lib/amigrind/blueprints/evaluator.rb', line 38

def self.evaluate(filename, environment = nil)
  Evaluator.new(filename, environment).blueprint
end

Instance Method Details

#propertiesObject



42
43
44
# File 'lib/amigrind/blueprints/evaluator.rb', line 42

def properties
  @properties
end