Class: Orchparty::RootBuilder

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

Instance Method Summary collapse

Methods inherited from Builder

build

Constructor Details

#initializeRootBuilder

Returns a new instance of RootBuilder.



28
29
30
# File 'lib/orchparty/dsl_parser.rb', line 28

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

Instance Method Details

#_buildObject



50
51
52
# File 'lib/orchparty/dsl_parser.rb', line 50

def _build
  @root
end

#application(name, &block) ⇒ Object



40
41
42
43
# File 'lib/orchparty/dsl_parser.rb', line 40

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

#import(rel_file) ⇒ Object



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

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



45
46
47
48
# File 'lib/orchparty/dsl_parser.rb', line 45

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