From: "ara.t.howard" Date: 2007-11-02T11:38:27+09:00 Subject: Re: Who required that!? On Nov 1, 2007, at 6:18 PM, Trans wrote: > Is there any way to ask a file what other file require/load 'd it? I > imagine this has been asked before but I couldnt seem to find good > terms to search for it. > cfp:~ > cat a.rb p Kernel.requiree('main') require 'b' p Kernel.requiree('main') BEGIN { module Kernel h = Hash.new define_method(:requiree) do |of| h[of] end r = method :require define_method(:require) do |*a| r.call *a h[a.first] = caller end end } cfp:~ > cat b.rb require 'main' cfp:~ > ruby a.rb nil ["./b.rb:1", "a.rb:20:in `require'", "a.rb:20:in `call'", "a.rb:20:in `require'", "a.rb:4"] a @ http://codeforpeople.com/ -- share your knowledge. it's a way to achieve immortality. h.h. the 14th dalai lama