Class: PointRb::LayoutConstructor

Inherits:
Object
  • Object
show all
Defined in:
lib/pointrb/layout_constructor.rb

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ LayoutConstructor

Returns a new instance of LayoutConstructor.



5
6
7
8
9
10
11
12
13
# File 'lib/pointrb/layout_constructor.rb', line 5

def initialize(project)
  @project = project
  @layout = Layout.new

  #this is the root directory and will be used by all other 
  #child nodes
  root_node = Directory.new(@project.path)
  @tree = LayoutTree.new(root_node)
end

Instance Method Details

#parse_dsl(content, path) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/pointrb/layout_constructor.rb', line 15

def parse_dsl(content, path)

  begin
    instance_eval(content, path)
  rescue Exception => e
    file, line_number = filter_file_and_line_number(e.backtrace.first)
    raise Exceptions::SyntaxErrorInLayout, "Syntax error in layout-file \"#{file}\" at line #{line_number}."
  end

  @layout.actions = @tree.serialize do |node|
    #set base_dir based on parent directory
    node.content.base_dir = node.parent.content.full_path if node.parent
    #return the Directory-object
    node.content 
  end

  @layout
end