From: Tony Arcieri Date: 2010-10-30T12:36:50+09:00 Subject: Re: Constant lookup as-if toplevel --001636c5a75eeb7a810493cd4834 Content-Type: text/plain; charset=ISO-8859-1 I ran into this same problem today myself, although attempting something different. I wanted to stylize a constant name with a bang! Our company's name happens to be stylized with a bang, so I thought I'd be silly and try to translate that into Ruby itself (I was inspired by Rainbows!) So I tried this: http://gist.github.com/653850 Which is fine, but when I created classes within the namespace of my bangmodule, they still inspect without the bang! I want the bang! Bring on the bang! On Fri, Oct 29, 2010 at 4:06 PM, Intransition wrote: > I'm evaluating a ruby script against a testing DSL that I wrote. Now I > would have loved to run the scripts at the toplevel, but the > contamination of the Object class makes that infeasible. So I run them > within a Scope object. Basically: > > class Scope < Module > > def initialize > extend self > end > > def execute(script, filename) > eval(script, binding, filename) > end > > end > > My problem arises when a script uses a constant that isn't defined and > the error message looks like this: > > ERROR: NameError uninitialized constant #::Foo > > I'm trying to find a way to get rid of the `#::` part. To > the end user it should at least *look* like things are running at > toplevel. > > I tried adding to Scope: > > def inspect; ""; end > > But that did not work. Any ideas? > > -- Tony Arcieri Medioh! A Kudelski Brand --001636c5a75eeb7a810493cd4834--