Forum: Ruby Nubish 2 - Of require and Ruby CVS

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
82e62c756d89bc6fa0a0a2d7f2b1e617?d=identicon&s=25 rosco (Guest)
on 2005-11-27 20:58
(Received via mailing list)
Hi again folks,

Thanks for the excellent answers yesterday :) I've been busy again
and now of course I have some more questions. Only a couple, so here

1) I wanted to use Rake's file commands in IRB, but was stuck because I
didn't want the file ops on every object. I guess(?) this is executed by
rake when it's loaded, but by experimenting a bit I found out something
very interesting - if I do the following:

	def init_sh
	  @sh =
	  class << @sh
	    require 'rake'    # <= it works!!

	    # rake doesn't do 'ls' with opts
	    def ls(*o) `ls #{o.join(' ')}`.split("\n") end

then the file op methods get applied to @sh only. Now, I honestly didn't
expect that to work, and I have to say it frightens me a bit. I don't
know, for example, what happens with objects instantiated in that
(or is this about namespaces?) if they get passed back to the main
program? I'd guess the methods are retained, because that's what happens
with the sh object, right? (I can call the file ops from IRB), but I've
fallen into that trap before ;) If that's so, then what happens in case
a conflict?  How does it work, and are there (m)any gotchas to watch

2) Also, if I change the require for include Rake (no require 'rake'
anywhere), then the methods seem to get applied across all Objects, as
before. I cannot understand why, esp. given 1) above.

3) I checked out Ruby CVS (HEAD) to get a look at what might be
I get the feeling this is an obvious question, but make says:

	[ ... ]
	gcc -g -O2  -DRUBY_EXPORT  -I. -I.  -c ruby.c
	gcc -g -O2  -DRUBY_EXPORT  -I. -I.  -c signal.c
	gcc -g -O2  -DRUBY_EXPORT  -I. -I.  -c sjis.c
	make: *** No rule to make target `vsnprintf.c', needed by `sprintf.o'.

I searched around a bit and found a few references, including some to
moved libraries and many other programs, but not a great deal related to
Ruby. Has anyone seen and maybe got past this? I'm on Fedora Core 4,
Kernel 2.6.13-1.1526_FC4, gcc (GCC) 4.0.1 20050727 (Red Hat 4.0.1-5).

Thanks again in advance,
This topic is locked and can not be replied to.