J
Joel VanderWerf
Trying to run irb on QNX6, I learned that there is a 48 char limit to
file names. The long filenames generated by Tempfile (called from
irb/locale.rb) were preventing irb from running. So I installed the
following code in site_ruby under the name "tempfile.rb" so that it
would be loaded before the real tempfile:
==== tempfile.rb ====
basename = File.basename(__FILE__)
$".delete(basename)
dirname = File.dirname(__FILE__)
idx = $:.index(dirname)
$:.delete(dirname)
require basename
$:.insert(idx, dirname)
class Tempfile
alias long_filename_initialize initialize
def initialize(basename, tmpdir=Dir::tmpdir)
basename = basename[/.{0,25}$/] # last 25 chars
long_filename_initialize(basename, tmpdir)
end
end
=====================
It's a horrible hack. What I would really like is something like "super"
but which applies to the way require finds files, rather than the way
ruby finds methods. (One problem with this hack is that whatever happens
during "require basename" had better not depend on the directory that
was temporarily hidden, or else you may get the wrong file or no file at
all.)
Is there an easy way to implement this in ruby? If not, should it be
provided as a primitive by the interpreter?
file names. The long filenames generated by Tempfile (called from
irb/locale.rb) were preventing irb from running. So I installed the
following code in site_ruby under the name "tempfile.rb" so that it
would be loaded before the real tempfile:
==== tempfile.rb ====
basename = File.basename(__FILE__)
$".delete(basename)
dirname = File.dirname(__FILE__)
idx = $:.index(dirname)
$:.delete(dirname)
require basename
$:.insert(idx, dirname)
class Tempfile
alias long_filename_initialize initialize
def initialize(basename, tmpdir=Dir::tmpdir)
basename = basename[/.{0,25}$/] # last 25 chars
long_filename_initialize(basename, tmpdir)
end
end
=====================
It's a horrible hack. What I would really like is something like "super"
but which applies to the way require finds files, rather than the way
ruby finds methods. (One problem with this hack is that whatever happens
during "require basename" had better not depend on the directory that
was temporarily hidden, or else you may get the wrong file or no file at
all.)
Is there an easy way to implement this in ruby? If not, should it be
provided as a primitive by the interpreter?