Sha256: 075015dd35ad7767ef658f6bfa0ed50db028bc9ccd30b9b1e83a274184cea322
Contents?: true
Size: 1.33 KB
Versions: 3
Compression:
Stored size: 1.33 KB
Contents
# encoding: utf-8 module PointRb class LayoutConstructor 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 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 private def filter_file_and_line_number(backtrace) backtrace.split(':')[0..1] end def layout(name, &block) @layout.name = name.to_sym block.call end def directory(path, &block) @tree.add_node Directory.new(path) block.call if block @tree.up end def file(path, &block) content = block.call.to_s @tree.add_node PointRbFile.new(path, content) @tree.up end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pointrb-0.1.2 | lib/pointrb/layout_constructor.rb |
pointrb-0.1.1 | lib/pointrb/layout_constructor.rb |
pointrb-0.1.0 | lib/pointrb/layout_constructor.rb |