Sy_Ali
April 12, 2006, 7:20am
1
http://term-ansicolor.rubyforge.org/
I did a successful gem install of term-ansicolor and am trying to use
it:
include Term::ANSIColor
print red, bold, “red bold”, reset, “\n”
gives me:
uninitialized constant Term
I tried all kinds of variations, found some code where other people
used this and tried all that out. No luck.
Is this a problem with my Ruby or gems installation?
Sy_Ali
April 12, 2006, 8:27am
2
Sy,
On 4/12/06, Sy Ali [email protected] wrote:
I tried all kinds of variations, found some code where other people
used this and tried all that out. No luck.
Is this a problem with my Ruby or gems installation?
make sure you require the correct library (you might need to require
‘rubygems’ first)
require “lib/term/ansicolor”
(why the maintainer chose to put the lib/ prefix, I don’t really know)
Cameron
Sy_Ali
April 12, 2006, 11:51am
3
Hi,
Sy Ali wrote:
I tried all kinds of variations, found some code where other people
used this and tried all that out. No luck.
Is this a problem with my Ruby or gems installation?
It seems to work fine here:
closure:~ flori$ ruby
require ‘term/ansicolor’
include Term::ANSIColor
print red, bold, “red bold”, reset, “\n”
red bold
Have you required the library before trying to use it?
Florian
Sy_Ali
April 12, 2006, 2:50pm
4
On Apr 12, 2006, at 12:18 AM, Sy Ali wrote:
http://term-ansicolor.rubyforge.org/
Just FYI, HighLine can also do ANSI color, and much, much more…
James Edward G. II
Sy_Ali
April 12, 2006, 6:07pm
5
On 4/12/06, Cameron McBride [email protected] wrote:
make sure you require the correct library (you might need to require
‘rubygems’ first)
That was the solution. I needed to require rubygems. Apparently, I
thought everything was more magical.
require ‘rubygems’
require ‘term/ansicolor’
include Term::ANSIColor
print red, bold, “red bold”, reset, “\n”
On 4/12/06, James Edward G. II [email protected] wrote:
Just FYI, HighLine can also do ANSI color, and much, much more…
Thanks. I went poking around for a solution and a quick search came
up with ansicolor. I’ll investigate this one when I have a bit of
time.
http://highline.rubyforge.org/
http://www.rubyquiz.com/quiz29.html
Sy_Ali
April 12, 2006, 6:16pm
6
On 4/12/06, Sy Ali [email protected] wrote:
On 4/12/06, James Edward G. II [email protected] wrote:
Just FYI, HighLine can also do ANSI color, and much, much more…
Thanks. I went poking around for a solution and a quick search came
up with ansicolor. I’ll investigate this one when I have a bit of
time.
http://highline.rubyforge.org/
Ruby Quiz - HighLine (#29)
Silly me, this is Ruby. Although nothing is straightforward, google
gave me the answers I needed:
require ‘rubygems’
require ‘highline/import’
say(“This is <%= color(‘red bold’, red, bold) %>!”)
Sy_Ali
April 12, 2006, 6:22pm
7
On 4/12/06, Sy Ali [email protected] wrote:
Silly me, this is Ruby. Although nothing is straightforward, google
gave me the answers I needed:
I’m not sure that made english sense. Let’s try that again.
Silly me, “a bit of time” for Ruby really is only a small bit of time.
I have some time right now so I’ll play with it.
I played with it, and like everything else I’ve seen I’ll need to
learn a bit more to get it to work. However, I quickly googled for
someone else’s code and easily adapted it to my needs:
require ‘rubygems’
require ‘highline/import’
say(“This is <%= color(‘red bold’, red, bold) %>!”)
Sy_Ali
April 12, 2006, 8:47pm
8
Sy Ali wrote:
That was the solution. I needed to require rubygems. Apparently, I
thought everything was more magical.
require ‘rubygems’
require ‘term/ansicolor’
include Term::ANSIColor
print red, bold, “red bold”, reset, “\n”
You can set RUBYOPT=-rubygems in your environment, if you don’t want to
require ‘rubygems’. So users can transparently either use gems or
install from source or use their package managers.
Sy_Ali
April 12, 2006, 4:59pm
9
On Wed, 12 Apr 2006, Florian F. wrote:
Florian
that’s good stuff florian! any idea how to make this work? (it’s a
snippet out
of something i’m working on attm):
harp:~ > cat a.rb
require 'readline'
require 'rubygems'
require_gem 'term-ansicolor'
class ::String; include Term::ANSIColor; end
complete = lambda do |words|
words = words.strip.split(%r/\s+/) unless Array === words
Readline::completion_proc = lambda do |s|
list = words.select{|c| c.index s}
list = list.empty? ? words : list
list.map{|word| word.blue}
end
end
sif_in = []
readline =
if STDIN.tty?
lambda{|prompt| line =
Readline::readline(prompt.strip.red.dark.bold.underline << "
").to_s.strip; sif_in << line; line.empty? ? nil : line}
else
lambda{|prompt| line = STDIN.gets.to_s.strip; sif_in << line;
line.empty? ? nil : line}
end
complete['one two three']
line = readline['number >']
puts line
the interaction between the completion_proc and term-ansicolor results
in the
the escape codes being shown literally? thoughts?
thanks.
-a
Sy_Ali
April 12, 2006, 10:31pm
10
On Thu, 13 Apr 2006, Sy Ali wrote:
On 4/12/06, Florian F. [email protected] wrote:
You can set RUBYOPT=-rubygems in your environment
Aah, good point. Maybe I should also recommend this for the guys who
handle the packages for my Linux distro.
be careful. it’s breaks some packages, like the gsl.
-a
Sy_Ali
April 12, 2006, 10:53pm
11
On 4/12/06, [email protected] [email protected] wrote:
On Thu, 13 Apr 2006, Sy Ali wrote:
On 4/12/06, Florian F. [email protected] wrote:
You can set RUBYOPT=-rubygems in your environment
Aah, good point. Maybe I should also recommend this for the guys who
handle the packages for my Linux distro.
be careful. it’s breaks some packages, like the gsl.
Always a catch. Ok, I’d rather insert it into my code manually every
time… at this point I"m just goofing around anyways.
Sy_Ali
April 12, 2006, 10:25pm
12
On 4/12/06, Florian F. [email protected] wrote:
You can set RUBYOPT=-rubygems in your environment
Aah, good point. Maybe I should also recommend this for the guys who
handle the packages for my Linux distro.
Sy_Ali
April 13, 2006, 1:20am
13
On Thu, 13 Apr 2006, Jim W. wrote:
be careful. it’s breaks some packages, like the gsl.
Does gsl just not work with gems at all? Or is it that setting RUBYOPT
breaks it?
there is a superclass conflict with with the Rational class. afaik this
is
the fault of the gsl…
i can send the error message later - it’s on a box at home.
cheers.
-a
Sy_Ali
April 13, 2006, 12:08am
14
unknown wrote:
On Thu, 13 Apr 2006, Sy Ali wrote:
On 4/12/06, Florian F. [email protected] wrote:
You can set RUBYOPT=-rubygems in your environment
Aah, good point. Maybe I should also recommend this for the guys who
handle the packages for my Linux distro.
be careful. it’s breaks some packages, like the gsl.
Does gsl just not work with gems at all? Or is it that setting RUBYOPT
breaks it?
Thanks?
–
– Jim W.