class Applb::DSL
Attributes
result[R]
Public Class Methods
define(source, filepath, options)
click to toggle source
# File lib/applb/dsl.rb, line 10 def define(source, filepath, options) self.new(filepath, options) do eval(source, binding, filepath) end end
new(filepath, options,&block)
click to toggle source
# File lib/applb/dsl.rb, line 19 def initialize(filepath, options,&block) @filepath = filepath @result = OpenStruct.new(ec2s: {}) @context = Hashie::Mash.new( filepath: filepath, templates: {}, options: options, ) instance_eval(&block) end
Public Instance Methods
ec2(vpc_id, &block)
click to toggle source
# File lib/applb/dsl.rb, line 48 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
require(file)
click to toggle source
# File lib/applb/dsl.rb, line 32 def require(file) albfile = (file =~ %r|\A/|) ? file : File.expand_path(File.join(File.dirname(@filepath), 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
template(name, &block)
click to toggle source
# File lib/applb/dsl.rb, line 44 def template(name, &block) @context.templates[name.to_s] = block end