For Programmers: Free Programming Magazines  


Home > Archive > Ruby > August 2005 > mod_ruby -- Problem with Changing from $defout > $stdout









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author mod_ruby -- Problem with Changing from $defout > $stdout
Ben Gribaudo

2005-08-30, 7:02 pm

Hi,

I'm working on upgrading some Ruby 1.6.x to prepare for a web-server
wide upgrade to 1.8.2 (We're still running under 1.6.x). $defout is
obsolete in Ruby 1.8.2. In irb, $defout==$stdout, so I would think that
I should be able to replace any usage of $defout in a script with
$stdout. But it doesn't work!

Take the code below. I would expect to be able use either "$defout =
out" and "$defout = starting_stdout" OR "$stdout = out" and "$stdout =
starting_stdout". However, only the $defout lines work

Interestingly, while $stdout==$defout is true in irb, it is false in
mod_ruby as puts puts ($stdout==$defout)==false true.

What am I doing wrong? Why does $stdout==$defout in irb but not in mod_ruby?

Ben


class ...
def get_output
starting_stdout = $stdout
begin
out = Object.new
class << out
attr_reader :output
def write(value)
@output ||= ''
@output << value.to_s
end
alias << write
def flush(*args) end
end
## Either of these lines should result in the same effect,
correct?
$defout = out
#$stdout = out
yield
ensure
## Again, these two lines are identical in function, right?
$defout = starting_stdout
#$stdout = starting_stdout
end
puts ($stdout==$defout)==false
return out.output
end
end


Ben Gribaudo

2005-08-31, 7:00 pm

I moved this message over to the mod_ruby list. -bdg


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com