Sha256: 082b6524ca0176f9b000a3aed0dd652a5ce48656c569598b4d0a7157914a0ff0
Contents?: true
Size: 1.32 KB
Versions: 3
Compression:
Stored size: 1.32 KB
Contents
require 'hashie' require 'applb/template_helper' require 'applb/dsl/ec2' module Applb class DSL include Applb::TemplateHelper class << self def define(source, filepath, options) self.new(filepath, options) do eval(source, binding, filepath) end end end attr_reader :result def initialize(filepath, options,&block) @filepath = filepath @result = OpenStruct.new(ec2s: {}) @context = Hashie::Mash.new( filepath: filepath, templates: {}, options: options, ) instance_eval(&block) end def require(file) albfile = (file =~ %r|\A/|) ? file : File.expand_path(File.join(File.dirname(@path), file)) if File.exist?(albfile) instance_eval(File.read(albfile), albfile) elsif File.exist?("#{albfile}.rb") instance_eval(File.read("#{albfile}.rb"), "#{albfile}.rb") else Kernel.require(file) end end def template(name, &block) @context.templates[name.to_s] = block end def ec2(vpc_id, &block) if ec2_result = @result.ec2s[vpc_id] @result.ec2s[vpc_id] = EC2.new(@context, vpc_id, ec2_result.load_balancers, &block).result else @result.ec2s[vpc_id] = EC2.new(@context, vpc_id, [], &block).result end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
applb-0.1.2 | lib/applb/dsl.rb |
applb-0.1.1 | lib/applb/dsl.rb |
applb-0.1.0 | lib/applb/dsl.rb |