class Macros::Loader
Public Class Methods
new()
click to toggle source
# File lib/macros/loader.rb, line 5 def initialize @compiler = Macros::Compiler.new @macros = {} @expander = Macros::Expander.new(@macros) end
Public Instance Methods
load(pathname)
click to toggle source
# File lib/macros/loader.rb, line 24 def load(pathname) ast = Macros.parse pathname.read @macros.merge! @compiler.collect_defmacros(ast) rest_ast = @compiler.reject_defmacros(ast) MAIN.instance_eval Unparser.unparse @expander.macroexpand(rest_ast) end
require(name)
click to toggle source
# File lib/macros/loader.rb, line 11 def require(name) $LOAD_PATH.each do |p| rb_file = (Pathname(p) + "#{name}.rb") if rb_file.file? unless $".include? rb_file.to_s load(rb_file) $" << rb_file.to_s end end end end