Class: Orchparty::RootBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/orchparty/dsl_parser.rb

Instance Method Summary collapse

Constructor Details

#initializeRootBuilder

Returns a new instance of RootBuilder.



21
22
23
# File 'lib/orchparty/dsl_parser.rb', line 21

def initialize
  @root = AST::Root.new(applications: {}, mixins: {})
end

Instance Method Details

#application(name, &block) ⇒ Object



33
34
35
36
# File 'lib/orchparty/dsl_parser.rb', line 33

def application(name, &block)
  @root.applications[name] = Docile.dsl_eval(ApplicationBuilder.new(name), &block).build
  self
end

#buildObject



43
44
45
# File 'lib/orchparty/dsl_parser.rb', line 43

def build
  @root
end

#import(rel_file) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/orchparty/dsl_parser.rb', line 25

def import(rel_file)
  old_file_path = Pathname.new(caller[0][/[^:]+/]).parent
  rel_file_path = Pathname.new rel_file
  new_file_path = old_file_path + rel_file_path
  file_content = File.read(new_file_path)
  instance_eval(file_content, new_file_path.expand_path.to_s)
end

#mixin(name, &block) ⇒ Object



38
39
40
41
# File 'lib/orchparty/dsl_parser.rb', line 38

def mixin(name, &block)
  @root.mixins[name] = Docile.dsl_eval(MixinBuilder.new(name), &block).build
  self
end