From: Clifford Heath Date: 2009-05-31T12:05:30+09:00 Subject: Re: [ANN] Endless Ruby 0.0.2 Juan Zanos wrote: >> Ouch. But this is a good candidate for using Polyglot. Just name >> your files .rbe, and when you require 'endless', it registers that >> extension with Polyglot to be used with the endless loader. Then >> you can just "require 'fred'", and it will endless-load "fred.rbe". > How would this work? Would endless.rb just load the polyglot gem > and automatically set itself up? So all you'd need to do is require > 'endless' and then make some rbe files? Exactly. My ActiveFacts gem implements a language called CQL. When you require 'activefacts/cql', it does this: require 'polyglot' module ActiveFacts class CQLLoader def self.load(file) .. end end Polyglot.register('cql', CQLLoader) end Now you can require 'fred', and CQLLoader gets to load "fred.cql" (assuming that "fred.rb" isn't found first). The CQL is translated into Ruby module and class definitions which are then eval'ed. Same deal with Treetop. When you require 'treetop', it requires Polyglot, and does this: Polyglot.register(["treetop", "tt"], Treetop) where the Treetop class has a self.load method. Clifford Heath.