Class: MyScripts::Ansi

Inherits:
Script
  • Object
show all
Defined in:
lib/my_scripts/scripts/ansi.rb

Overview

This script should be used as a pipe to colorize ANSI output on Windows Use case is like this (provides colorized autotest output):

> autotest | ansi

Constant Summary collapse

VERSION =
'0.0.1'

Instance Method Summary collapse

Methods inherited from Script

#error, #gets, #puts, #system, #to_s, #usage, #version

Constructor Details

#initialize(name, cli, argv, argf) ⇒ Ansi

Returns a new instance of Ansi.



10
11
12
13
14
15
# File 'lib/my_scripts/scripts/ansi.rb', line 10

def initialize(name, cli, argv, argf)
  require 'win32console'
  @cli = cli
  @io = Win32::Console::ANSI::IO.new()
  super
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
# File 'lib/my_scripts/scripts/ansi.rb', line 17

def run
  Signal.trap('INT', nil)  # Ignores Interrupt (Ctrl-C) - it is used by autotest

  until @cli.stdin.eof? do
    line = @cli.stdin.gets
    @io.puts line
  end
  @io.flush
end