[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

autotest, unit-diff, and color output?

Rob Sanheim

12/8/2006 5:26:00 PM

I'm using autotest with all its test driven goodness, and I believe
that uses unit-diff to present a "saner" view of test difference
output.

I'd like to do colorize the output from unit-diff so its similar to
what you see on a changeset on trac, for instance. Does anyone know
anything that can colorize diffs in ruby, or know of a good starting
point? Or at least where to start for outputting color in the
terminal, so I can do "#{color.red} stuff" instead of using control
characters.

thanks,
Rob

--
http://www.robs...
http://www.seekin...
http://www.a...

8 Answers

Trans

12/8/2006 6:08:00 PM

0


Rob Sanheim wrote:
> I'm using autotest with all its test driven goodness, and I believe
> that uses unit-diff to present a "saner" view of test difference
> output.
>
> I'd like to do colorize the output from unit-diff so its similar to
> what you see on a changeset on trac, for instance. Does anyone know
> anything that can colorize diffs in ruby, or know of a good starting
> point? Or at least where to start for outputting color in the
> terminal, so I can do "#{color.red} stuff" instead of using control
> characters.

you can try facets' ansicode lib written primarily by Florian Frank.

t.


Paul Lutus

12/8/2006 6:41:00 PM

0

Rob Sanheim wrote:

> I'm using autotest with all its test driven goodness, and I believe
> that uses unit-diff to present a "saner" view of test difference
> output.
>
> I'd like to do colorize the output from unit-diff so its similar to
> what you see on a changeset on trac, for instance. Does anyone know
> anything that can colorize diffs in ruby, or know of a good starting
> point? Or at least where to start for outputting color in the
> terminal, so I can do "#{color.red} stuff" instead of using control
> characters.

An easy, lightweight way to go would be to write a script that creates an
HTML file out of the diff data, popping in color-change tags as required,
using your own choice of colors and syntax rules. This would be very easy
to do, once you have decided how you want the output to look.

Of the available choices, HTML is actually very easy to exploit for a
formatting task like this.

Whoops, I just saw your having mentioned a terminal. Okay, then, you can use
ANSI colors instead, using a similar process, this time the script could be
a filter, the last step before displaying the data on the terminal. Same
syntax rules, different way to create the colors.

> so I can do "#{color.red} stuff ...

Okay, here is an example:

-------------------------------------------------

#!/usr/bin/ruby -w

class ANSIColors

ANSIColors::Col_hash = {
:black => 30,
:red => 31,
:green => 32,
:yellow => 33,
:blue => 34,
:magenta => 35,
:cyan => 36,
:white => 37
}

def ANSIColors::color(s)
return "\033[#{Col_hash[s]}m"
end
end

puts "#{ANSIColors::color(:red)} this should be red."

puts "#{ANSIColors::color(:green)} this should be green."

puts "#{ANSIColors::color(:blue)} this should be blue."

puts "#{ANSIColors::color(:black)} this should be black."

-------------------------------------------------

Try it on your terminal. If it doesn't work, chances are your terminal is
not ANSI-color enabled.

--
Paul Lutus
http://www.ara...

Eric Hodel

12/9/2006 12:26:00 AM

0

On Dec 8, 2006, at 09:26 , Rob Sanheim wrote:

> I'm using autotest with all its test driven goodness, and I believe
> that uses unit-diff to present a "saner" view of test difference
> output.

It does.

> I'd like to do colorize the output from unit-diff so its similar to
> what you see on a changeset on trac, for instance. Does anyone know
> anything that can colorize diffs in ruby, or know of a good starting
> point? Or at least where to start for outputting color in the
> terminal, so I can do "#{color.red} stuff" instead of using control
> characters.

The easiest way to do this is to write (or find) a color-capable diff
executable. This way you don't have to change unit_diff, just your
path.

--
Eric Hodel - drbrain@segment7.net - http://blog.se...

I LIT YOUR GEM ON FIRE!


Rob Sanheim

12/10/2006 8:31:00 PM

0

On 12/8/06, Eric Hodel <drbrain@segment7.net> wrote:
>
> The easiest way to do this is to write (or find) a color-capable diff
> executable. This way you don't have to change unit_diff, just your
> path.
>

Thanks for the responses everyone. Some quick google searches didn't
turn up any drop in color replacements for diff, though I did find it
as a feature request submitted for diff, but way to recently for any
code to be written yet.

- Rob

Martin DeMello

12/10/2006 9:33:00 PM

0

On 12/11/06, Rob Sanheim <rsanheim@gmail.com> wrote:
>
> Thanks for the responses everyone. Some quick google searches didn't
> turn up any drop in color replacements for diff, though I did find it
> as a feature request submitted for diff, but way to recently for any
> code to be written yet.

$ esearch colordiff
[ Results for search key : colordiff ]
[ Applications found : 1 ]

* app-misc/colordiff
Latest version available: 1.0.5-r2
Latest version installed: 1.0.5-r2
Size of downloaded files: 41 kB
Homepage: http://colordiff.source...
Description: Colorizes output of diff
License: GPL-2

martin

Rob Sanheim

12/11/2006 1:00:00 AM

0

On 12/10/06, Martin DeMello <martindemello@gmail.com> wrote:
> $ esearch colordiff
> [ Results for search key : colordiff ]
> [ Applications found : 1 ]
>
> * app-misc/colordiff
> Latest version available: 1.0.5-r2
> Latest version installed: 1.0.5-r2
> Size of downloaded files: 41 kB
> Homepage: http://colordiff.source...
> Description: Colorizes output of diff
> License: GPL-2
>
> martin

Thanks, apparently I should've searched on one word instead of "color diff". :)

- rob

Martin DeMello

12/11/2006 10:18:00 AM

0

On 12/11/06, Rob Sanheim <rsanheim@gmail.com> wrote:
> On 12/10/06, Martin DeMello <martindemello@gmail.com> wrote:
> > $ esearch colordiff
> > [ Results for search key : colordiff ]
> > [ Applications found : 1 ]
>
> Thanks, apparently I should've searched on one word instead of "color diff". :)

It's easier when you know it's there :) I found it the first time by
searching for 'diff' in the portage tree

martin

Joseph of Mount Ephraim

7/30/2012 9:04:00 AM

0

On Monday, July 30, 2012 1:29:39 AM UTC-5, Carolina Reb wrote:
> On Jul 29, 11:26 pm, Joseph R Loegering <josephloeger...@gmail.com>
>
> wrote:
>
> > They outlawed the Law
>
>
>
> Stupid Christian bullshit if you really think anyone actually reads
>
> all this dribble. Screw you and your dead-jew-on-a-stick jesus.

Amazing, because we are children of Israel called Samaritans that believe upon Yahshua called Jesus in the scriptures, many that call themselves Jews will have nothing to so with us, and because we are children of Israel, many that call themselves Christians will have nothing to do with us, because they call us Jews, and the same is true with many that call themselves Islam. Yet we don't hate them for their ignorance, but you hate both Jews and Christians, and Muslims too.

But as Samaritans we believe in God Almighty named Yahweh, and in what he revealed unto us, and in what he revealed unto Abraham and Ishmael and Isaac and Jacob and the tribes, and in what was given unto Moses and Yahshua called Jesus, and in what was given unto the prophets and apostles from their Lord, and we do not differentiate between any one of them, having submitted to God Almighty named Yahweh. And whoever desires other than this as their religion, never will it be accepted from him, and he, in the last day, will be the loser.