Class: Macros::Loader
Instance Method Summary collapse
-
#initialize ⇒ Loader
constructor
A new instance of Loader.
- #load(pathname) ⇒ Object
- #require(name) ⇒ Object
Methods included from Sexp
#node?, #s, #seval, #sfind, #smatch?, #treefilter, #treemap
Constructor Details
Instance Method Details
#load(pathname) ⇒ Object
24 25 26 27 28 29 |
# 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.(rest_ast) end |
#require(name) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# 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 |