Sha256: f0abb9260dafdb270e28895cc85fcb7daac8139294f50099e871902491712d93
Contents?: true
Size: 991 Bytes
Versions: 3
Compression:
Stored size: 991 Bytes
Contents
# encoding: UTF-8 module Bunch class Compiler def self.register(extension, klass) compilers[extension] = klass end def self.compilers @compilers ||= {} end def initialize(tree) @input = tree @output = FileTree.new end def result @path = [] @input.accept(self) @output end def enter_tree(tree) @path << tree.name if tree.name end def leave_tree(tree) @path.pop if tree.name end def visit_file(file) compiler = compiler_for file write_file compiler.path, compiler.content end private def compiler_for(file) klass = self.class.compilers.fetch file.extension, Compilers::Null klass.new file, @input, absolute_path(file.path) end def write_file(relative_path, content) @output.write absolute_path(relative_path), content end def absolute_path(relative_path) (@path + [relative_path]).join("/") end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bunch-1.0.0pre3 | lib/bunch/compiler.rb |
bunch-1.0.0pre2 | lib/bunch/compiler.rb |
bunch-1.0.0pre1 | lib/bunch/compiler.rb |