To be honest, I think ruby should include an ANSI solution in its 
stdlib.

Right now I am using the most stupid approach possible - I aliased 
CONSTANTS to the ANSI colours. Then I use them like:


puts RED+'Hello '+GREEN+' world.'

I found it to be easier for my projects to however use variable names 
that denote the colours. And often enough I then do something like:

puts 'The file '+cfile(file)+' could not be found.'

Which colourizes the file variable (which should be a file).

Other ways could be:

puts 'The file '+file.colourize+' could not be found.'

Where the colourize method somehow is told how to colourize something, 
depending on whether it is a colour or a symlink or something.

But for this, class String has to be extended and I am a bit 
conservative when modifying core classes these days. I'd wish there 
would be a way to not globally modify core classes, and instead limit 
them to a specific project.

But we really need to have one ansi solution within Ruby - I don't mind 
what way, but it's crazy to have everyone cook up their own solutions 
instead.

-- 
Posted via http://www.ruby-forum.com/.