Gem Version Gem Downloads

ExAequo::Color

Describing how this gem works with some speculations...

The ExAequo::Color module exposes three methods

  • colorize
  • colorize_file
  • colorize_lines

Context: colorize, returning a result

Given we inlude ExAequo::Color

    require 'ex_aequo/color'
    include ExAequo::Color

Then we can colorize some strings

        expect(colorize('hello')).to eq(ok: true, result: 'hello')

And we can also colorize it with colors

        expect(colorize('<bold>world$!')).to eq(ok: true, result: "\e[1mworld\e[0m!")

And of course we obey the POSIX rule for the $NO_COLOR environment variable

    expect(ENV).to receive(:fetch).with('NO_COLOR', false).and_return(true)
    expect(colorize('<bold>world$!')).to eq(ok: true, result: "world!")

Context: colorize_lines

Given that you might not just get a result but just a colorized string Then you can do the following


Author

Copyright 2025 Robert Dober [email protected]

LICENSE

AGPL-3.0-or-later c.f LICENSE