class Kelbim::DSL

Attributes

result[R]

Public Class Methods

convert(exported, instance_names) click to toggle source
# File lib/kelbim/dsl.rb, line 12
def convert(exported, instance_names)
  Converter.convert(exported, instance_names)
end
define(source, path) click to toggle source
# File lib/kelbim/dsl.rb, line 6
def define(source, path)
  self.new(path) do
    eval(source, binding, path)
  end
end
new(path, &block) click to toggle source
# File lib/kelbim/dsl.rb, line 19
def initialize(path, &block)
  @path = path
  @result = OpenStruct.new(:ec2s => {})

  @context = Hashie::Mash.new(
    :path => path,
    :templates => {}
  )

  instance_eval(&block)
end

Private Instance Methods

ec2(vpc = nil, &block) click to toggle source
# File lib/kelbim/dsl.rb, line 49
def ec2(vpc = nil, &block)
  if (ec2_result = @result.ec2s[vpc])
    @result.ec2s[vpc] = EC2.new(@context, vpc, ec2_result.load_balancers, &block).result
  else
    @result.ec2s[vpc] = EC2.new(@context, vpc, [], &block).result
  end
end
require(file) click to toggle source
# File lib/kelbim/dsl.rb, line 33
def require(file)
  balancerfile = (file =~ %r|\A/|) ? file : File.expand_path(File.join(File.dirname(@path), file))

  if File.exist?(balancerfile)
    instance_eval(File.read(balancerfile), balancerfile)
  elsif File.exist?(balancerfile + '.rb')
    instance_eval(File.read(balancerfile + '.rb'), balancerfile + '.rb')
  else
    Kernel.require(file)
  end
end
template(name, &block) click to toggle source
# File lib/kelbim/dsl.rb, line 45
def template(name, &block)
  @context.templates[name.to_s] = block
end