Class: Roadworker::DSL

Inherits:
Object
  • Object
show all
Includes:
TemplateHelper
Defined in:
lib/roadworker/dsl.rb,
lib/roadworker/dsl-converter.rb,
lib/roadworker/dsl-tester.rb

Defined Under Namespace

Classes: Converter, Hostedzone, Tester

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TemplateHelper

#context, #include_template

Constructor Details

#initialize(path, &block) ⇒ DSL

Returns a new instance of DSL.



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/roadworker/dsl.rb', line 29

def initialize(path, &block)
  @path = path
  @result = OpenStruct.new({:hosted_zones => []})

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

  instance_eval(&block)
end

Instance Attribute Details

#resultObject (readonly)

of class method



27
28
29
# File 'lib/roadworker/dsl.rb', line 27

def result
  @result
end

Class Method Details

.convert(hosted_zones) ⇒ Object



12
13
14
# File 'lib/roadworker/dsl.rb', line 12

def convert(hosted_zones)
  Converter.convert(hosted_zones)
end

.define(source, path, lineno = 1) ⇒ Object



6
7
8
9
10
# File 'lib/roadworker/dsl.rb', line 6

def define(source, path, lineno = 1)
  self.new(path) do
    eval(source, binding, path, lineno)
  end
end

.normalize_dns_name(name) ⇒ Object



20
21
22
23
24
# File 'lib/roadworker/dsl.rb', line 20

def normalize_dns_name(name)
  # Normalize name. AWS always returns name with trailing dot, and stores name always lowercase.
  # https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/DomainNameFormat.html
  "#{name.downcase}.".sub(/\.+\z/, '.')
end

.test(dsl, options) ⇒ Object



16
17
18
# File 'lib/roadworker/dsl.rb', line 16

def test(dsl, options)
  Tester.test(dsl, options)
end

Instance Method Details

#template(name, &block) ⇒ Object



41
42
43
# File 'lib/roadworker/dsl.rb', line 41

def template(name, &block)
  @context.templates[name.to_s] = block
end