Class: Applb::DSL
- Inherits:
-
Object
show all
- Includes:
- TemplateHelper
- Defined in:
- lib/applb/dsl.rb,
lib/applb/dsl/ec2.rb,
lib/applb/dsl/rule.rb,
lib/applb/dsl/rules.rb,
lib/applb/dsl/checker.rb,
lib/applb/dsl/listener.rb,
lib/applb/dsl/listeners.rb,
lib/applb/dsl/attributes.rb,
lib/applb/dsl/target_group.rb,
lib/applb/dsl/load_balancer.rb,
lib/applb/dsl/target_groups.rb
Defined Under Namespace
Modules: Checker
Classes: EC2
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#context, #include_template
Constructor Details
#initialize(filepath, options, &block) ⇒ DSL
Returns a new instance of DSL.
19
20
21
22
23
24
25
26
27
28
29
30
|
# 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
|
Instance Attribute Details
#result ⇒ Object
Returns the value of attribute result.
17
18
19
|
# File 'lib/applb/dsl.rb', line 17
def result
@result
end
|
Class Method Details
.define(source, filepath, options) ⇒ Object
10
11
12
13
14
|
# File 'lib/applb/dsl.rb', line 10
def define(source, filepath, options)
self.new(filepath, options) do
eval(source, binding, filepath)
end
end
|
Instance Method Details
#ec2(vpc_id, &block) ⇒ Object
48
49
50
51
52
53
54
|
# 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) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
|
# 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) ⇒ Object
44
45
46
|
# File 'lib/applb/dsl.rb', line 44
def template(name, &block)
@context.templates[name.to_s] = block
end
|