class RBT::ColourizeParser

Public Class Methods

[](i = ARGV) click to toggle source
#

RBT::ColourizeParser[]

#
# File lib/rbt/misc/colourize_parser.rb, line 879
def self.[](i = ARGV)
  new(i)
end
new( i = nil, run_already = true ) click to toggle source
#

initialize

#
# File lib/rbt/misc/colourize_parser.rb, line 27
def initialize(
    i           = nil,
    run_already = true
  )
  reset
  set_line(i) if i
  run if run_already
end
parse_this_line(line) click to toggle source
#

RBT::ColourizeParser.parse_this_line

#
# File lib/rbt/misc/colourize_parser.rb, line 865
def self.parse_this_line(line)
  new(line).line?
end

Public Instance Methods

colour_for_found(i) click to toggle source
#

colour_for_found

This method will colourize the word “found”. That word is used in particular for checks made in some cmake-based projects, such as the KDE project.

#
# File lib/rbt/misc/colourize_parser.rb, line 840
def colour_for_found(i)
  darkorchid(i)
end
colour_for_warning_and_errors(i)
colour_for_warnings_and_errors(i) click to toggle source
#

colour_for_warnings_and_errors

#
# File lib/rbt/misc/colourize_parser.rb, line 847
def colour_for_warnings_and_errors(i)
  crimson(i)
end
grab_this_line(i = '')
Alias for: set_line
input?()
Alias for: line?
line?() click to toggle source
#

line?

#
# File lib/rbt/misc/colourize_parser.rb, line 52
def line?
  @line
end
Also aliased as: input?
parse_missing_dependency(i) click to toggle source
#

parse_missing_dependency

This method will try to colourize a String such as:

meson.build:38:0: ERROR:  Dependency "telepathy-glib" not found, tried pkgconfig and cmake
#
# File lib/rbt/misc/colourize_parser.rb, line 857
def parse_missing_dependency(i)
  regex_to_use = /ERROR:\s+Dependency "(.+)" not found/
  i.sub(regex_to_use, crimson('\1'))
end
reset() click to toggle source
#

reset (reset tag)

#
Calls superclass method RBT::LeanPrototype#reset
# File lib/rbt/misc/colourize_parser.rb, line 39
def reset
  super()
  infer_the_namespace
  enable_colours
  # ======================================================================= #
  # === @line
  # ======================================================================= #
  @line = ''.dup
end
run() click to toggle source
#

run (run tag)

#
# File lib/rbt/misc/colourize_parser.rb, line 872
def run
  # Empty placeholder.
end
sanitize_line() click to toggle source
#

sanitize_line

We must be careful in this method, as “line.squeeze!()” may fail due to an ArgumentError.

#
# File lib/rbt/misc/colourize_parser.rb, line 73
def sanitize_line
  begin
    stripped_line = @line.strip
  rescue ArgumentError, Encoding::CompatibilityError => error
    pp error if is_on_roebe?
    stripped_line = @line.to_s.dup # Work on a copy nonetheless.
  end
  stripped_line = stripped_line.dup if stripped_line and stripped_line.frozen?

  _paleturquoise = ALL_COLOUR_METHODS.paleturquoise
  # ======================================================================= #
  # === cmake colourizing                                       (cmake tag)
  #
  # Cmake does some colourizing - we will try to re-create this here,
  # starting with 'Building CXX object'.
  # ======================================================================= #
  if @line.include?('Building CXX object')        or
     @line.include?('Linking C shared library')   or
     @line.include?('] Copying llvm')             or
     @line.include?('] Creating export file')     or
     @line.include?('] [FLEX]')                   or
     @line.include?('] Linking target ')          or
     @line.include?('] Generating')               or
     @line.include?('] Running moc')              or
     @line.include?('] Merging translations for') or
     @line.include?('] Making')                   or
     @line.include?('] Updated:')                 or
     @line.include?('] actions for')              or
     @line.include?('] Validating for')           or # Example: "[ 25%] Validating SVG"
     @line.include?('] Built target')             or
     @line.include?('Built target ')              or # Example: "[ 8%] Built target aom_pc"
     @line.include?('] Copying ')                 or # Example: "[ 23%] Copying clang's arm_mve.h..."
     @line.include?('] Gzipping ')                or
     @line.include?('] Generate bindings ')       or # e. g. for "[ 39%] Generate bindings (WebCoreBindings)"
     @line.include?('] Completed ')               or
     @line.include?('] Linking')                  or
     @line.include?('] Compiling')                or
     @line.include?('] Creating')                 or
     @line.include?('] Generate files for')       or
     @line.include?('] Processing ')              or
     @line.include?('] mo-update: ')              or
     @line.include?('] mo-update [')              or
     @line.include?('] Updating ')                or
     @line.include?('] Building ')                or
     @line.include?('] Preparing ')               or
     @line.include?('] Building C object')        or
     @line.include?('] Running AUTOMOC ')         or
     @line.include?('] Built target')             or
     @line.include?('] Linking C executable')     or
     @line.include?('] Compiling C object')       or
     @line.include?('] Compiling C++ object')     or
     @line.include?('] Running rcc ')             or
     @line.include?('] Compiling Vala source')    or
     @line.include?('] Checking the ')            or
     @line.include?('] Linking static target')    or
     @line.include?('] Linking CXX shared')       or
     @line.include?('] Linking CXX static')       or
     @line.include?('] Linking CXX executable')   or
     @line.include?('] Creating library symlink') or
     @line.include?('] Linking C static library') or
     @line.include?('] Linking C shared')         or
     @line.include?('] Installing files.')        or
    (@line.include?('] Automatic ')               and
     @line.include?(' for '))                     or
    (@line.include?('] Compiling ')               and
     @line.include?('.po'))
    @line = limegreen(@line)
  # ======================================================================= #
  # === Colourize cd-related actions (cd stands for change directory)
  #
  # The Qt build-system makes use of the following line:
  #
  #   cd qtsensors/ &&
  #
  # ======================================================================= #
  elsif @line.start_with?('cd ') and @line.include?(' && ')
    @line = orangered(@line)
  # ======================================================================= #
  # === Checking for something
  #
  # This entry point is for Strings such as:
  #   -- Check for working C compiler: /System/Index/bin/cc
  # ======================================================================= #
  elsif @line.start_with?('-- Check for working C')
    if @line.end_with? ' -- works'
      @line.sub!(/(^.+)( -- works$)/, peru('\1')+orange('\2'))
    else
      @line = peru(@line)
    end
  # ======================================================================= #
  # === "Leaving directory" and "Entering directory"
  #
  # We handle both values in the same code, largely due to consistency.
  # ======================================================================= #
  elsif @line.include?('Leaving directory') or
        @line.include?('Entering directory')
    # ===================================================================== #
    # Match against "make[1]: Leaving directory '/Depot/Temp/xz-5.2.3/po'".
    # ===================================================================== #
    leaving_or_entering = 'Leaving' # <- default value.
    case @line
    # ===================================================================== #
    # === Leaving directory
    # ===================================================================== #
    when /Leaving directory/
      use_this_regex = /Leaving directory '(.+)'/
    # ===================================================================== #
    # === Entering directory
    # ===================================================================== #
    when /Entering directory/
      use_this_regex = /Entering directory '(.+)'/
      leaving_or_entering = 'Entering'
    end
    @line.sub!(use_this_regex,
      slategray("#{leaving_or_entering} directory '")+
      colourize_directory_for_system_results('\\1')+
      slategray("'")
    ) 
  # ======================================================================= #
  # === -- Checking for module 'libavformat'
  # ======================================================================= #
  elsif @line.include?('-- Checking for module ') or
        @line.include?('-- Checking for modules ') 
    # ===================================================================== #
    # For the regex, see:
    #   http://rubular.com/r/FQ0kx0tH9n
    # ===================================================================== #
    use_this_regex = /(-- Checking for modules? ')(.+)'$/
    @line.sub!(use_this_regex,
      '\\1'+orchid('\\2')+"'"
    )
  # ======================================================================= #
  # === mkdir -p
  #
  # We will only colourize here if there are at the least two "'" tokens.
  # This should colourize lines such as:
  #
  #   /System/Index/bin/mkdir -p '/usr/bin'
  #
  # ======================================================================= #
  elsif @line.include?('mkdir -p') and (@line.count("'") > 1)
    use_this_regex = /^(\s+.+mkdir -p ')(.+)(')/ # 3 internal regex-matches.
    @line.sub!(
      use_this_regex,
      lightseagreen('\\1')+
      lightslategray('\\2')+
      lightseagreen('\\3')
    )
  # ======================================================================= #
  # === -- Build files have been written to:
  # ======================================================================= #
  elsif @line.include?('-- Build files have been written to: ') or
        @line.include?('-- Configuring done') or # -- Configuring done
        @line.include?('-- Generating done')    # -- Generating done
    if @line.include?('-- Build files have been')
      regex_to_use = /(-- Build files have been written to: )(.+)/
      @line.sub!(
        regex_to_use,
        lightgreen('\\1')+
        lightslategray('\\2')
      )
    else
      @line = lightgreen(@line) # <-- Sync with the above ^^^ if-clause.
    end
  # ======================================================================= #
  # === clang
  # ======================================================================= #
  elsif @line.start_with?('clang') and
        @line.include?('warning: argument unused during compilation:')
    use_this_regex = /(clang.+:)( warning: argument unused during compilation:.+)/
    @line.sub!(use_this_regex, '\\1'+rosybrown('\\2'))
  # ======================================================================= #
  # === GEN and others
  #
  # Note that most of these entries start with 2 ' ' tokens, but some
  # also use 4 ' ' tokens. (This refers to leading spaces.)
  # ======================================================================= #
  elsif @line.start_with?(
    '  GEN    ',
    '    GEN ',
    '  GUILEC ',
    'wrote `',
    '  CC   ',
    '  BUNZIP2 ',
    '  XS ',
    '  BS ',
    ' BLIB  ', # This weird leading mini-indent is correct, though (Sep 2019).
    ' CHMOD  ',
    '  CP ',
    '  CCLD ',
    '  A11Y ',
    '  NASM ',
    '  HUGE ',
    '    CC ',
    '  AR    ',
    '    [CC]     ',
    '  HOSTCC',
    '  DOC',
    '  VDSO2C',
    '  SYSHDR',
    '  WRAP',
    '  GISCAN',
    '    [LN]     ',
    '    [STRIP] ',
    '    [PY] ',
    '  SED','   [HEADERS] ','  SPLIT','    [GENERATE] ',
    '  CCAS ',
    '    [TEST]    ',
    '  LN_S ',
    '  GISCAN ',
    '  GICOMP ',
    '  PPFC ',
    '  FCLD ',
    '  CPPAS ',
    '  LTLINK ',
    '  AR ',
    '  LD ',
    '  RANLIB ',
    '  MSGFMT ',
    '  ITMRG ',
    '   INSTALL ',
    '    SUBDIR',
    '  GENERATE',
    '  UIC',
    '  MOC ',
    '  HOSTLD',
    '  SHIPPED',
    '  PC ',
    '    [INSTALL]     ',
    '  LINK',
    '  CHK ',
    '  DESCEND ',
    '  CALL ',
    '  VERT ',
    '  FRAG ',
    '  AS ',
    '  AS [M] ',
    '  CC [M] ',
    '  VDSO ',
    '  LDS ',
    '    [DEP] ',
    '    [CC] ',
    '    [SED] ',
    '    [DOXY] ',
    '    [CREATE] ',
    '    [CXX] ',
    '    [AR] ',
    '    [AS] ',
    '    [LD] ',
    '    [LD]     ',
    '    [INSTALL] ',
    '    AR ',
    '    RANLIB ',
    '    C++ ',
    '    LINK ',
    '    BUILTIN ',
    '    MSGFMT ',
    '    LN/CP ',
    '   (deps)      ',
    '    OBJCOPY ',
    '  OBJCOPY ',
    '    CXX',
    '    YACC',
    '    SWIG',
    '    YACC',
    '  CXX ',
    '  CXXLD '
  )
    @line = darkseagreen(@line) # Colourize green.
  # ======================================================================= #
  # === R-like installation procedures, starting with the String "installing "
  #     but it will also be used for other instances of the word
  #     "installing".
  # ======================================================================= #
  elsif (@line.start_with?('installing ') and
        (@line =~ /^installing .+ \.\.\./)) or
        (@line.start_with?('Installing ') and
         @line.include?(' to ')) or
        (@line.start_with?('Making directory /')) or
        (@line.start_with?('installing  ') and
         @line.include?(' in /')) or
        (@line.include?('Installing ') and @line.include?(' as '))
    @line = darkseagreen(@line) # Colourize green; sync with the ^^^ above.
  # ======================================================================= #
  # === *new something
  #
  # This is similar to the entry above but we will try the colour
  # skyblue.
  # ======================================================================= #
  elsif @line.start_with?(
    '    * new build flags',
    '    * new link flags',
    '    * new perl-specific parameters',
    '    * new prefix flags',
    '    * new script parameters',
    'Note: ',
    'Creating makefiles for ' # This too, so that the user knows about it.
    )
    @line = skyblue(@line) # Colourize green.
  # ======================================================================= #
  # === config.status
  # ======================================================================= #
  elsif @line.start_with?('config.status')
    @line = limegreen(@line)
  # ======================================================================= #
  # === "which seems to be undefined.  Please make sure it is defined"
  # ======================================================================= #
  elsif @line.start_with?('which seems to be undefined.  Please make sure it is defined')
    # ===================================================================== #
    # This entry point here is assumed to belong to a config.status
    # derived notification.
    # ===================================================================== #
    @line = limegreen('which seems to be undefined.  ')+
            crimson('Please make sure it is defined')
  end
  # ======================================================================= #
  # === Scanning dependencies of
  #
  # This is mostly for some cmake-related build systems.
  # ======================================================================= #
  if @line.start_with?('Scanning dependencies of ') or
     @line.start_with?('Generating MOC')
    @line = mediumaquamarine(@line)
  # ======================================================================= #
  # === Colourize lines that start with "sed -"
  # ======================================================================= #
  elsif @line.start_with?('sed -')
    @line = skyblue(@line)
  # ======================================================================= #
  # === Building package xyz
  # ======================================================================= #
  elsif @line.start_with?('Building package') or
        @line.start_with?('Installing package')
    @line = teal(@line)
  end
  # ======================================================================= #
  # === The Meson build system
  #
  # Ideally every meson-related entry point can be defined in the
  # if-clause below this comment.
  # ======================================================================= #
  if @line.include? 'The Meson build system'
    @line = orchid(@line)
  elsif @line.include?('meson.build') and @line.include?('ERROR:  Dependency') and
        @line.include?('not found')
    # ===================================================================== #
    # We have encountered a missing dependency. We will in particular
    # colourize that dependency in a ~red colour.
    # ===================================================================== #
    @line = parse_missing_dependency(@line)
  end
  # ======================================================================= #
  # Next, colourize gcc, g++ and clang specifically - only these
  # three words, in the same colour. First, gcc.
  # ======================================================================= #
  if @line.start_with?('gcc -')
    use_this_regex = /^(gcc)( -)/
    @line.sub!(use_this_regex, orange('\\1')+'\\2')
    if @line.include? '-std=gnu++'
      use_this_regex = /(.+)(-std=gnu\+\+\d{1,2})(.+)/ # See: http://rubular.com/r/Oqk5yfzMkT
      @line.sub!(use_this_regex, '\\1'+khaki('\\2')+'\\3')
    end
  # ======================================================================= #
  # === g++
  # ======================================================================= #
  elsif @line.start_with?('g++') or
       (@line.include?('g++') and @line.include?('-DHAVE'))
    use_this_regex = /^(g\+\+)/
    @line.sub!(use_this_regex, orange('\\1'))
  # ======================================================================= #
  # === clang
  # ======================================================================= #
  elsif @line.start_with?('clang')
    use_this_regex = /(clang-?\d?\.?\d?):/
    @line.sub!(use_this_regex, orange('\\1')+':')
  # ======================================================================= #
  # === strip:
  # ======================================================================= #
  elsif @line.start_with?('strip:')
    use_this_regex = /^(strip):/
    @line.sub!(use_this_regex, orange('\\1')+':')
  # ======================================================================= #
  # === ranlib
  # ======================================================================= #
  elsif @line.start_with?('ranlib')
    use_this_regex = /^(ranlib)/
    @line.sub!(use_this_regex, orange('\\1'))
  # ======================================================================= #
  # === chmod
  # ======================================================================= #
  elsif @line.start_with?('chmod')
    use_this_regex = /^(chmod)/
    @line.sub!(use_this_regex, orange('\\1'))
  # ======================================================================= #
  # === /bin/sh
  # ======================================================================= #
  elsif @line.start_with?('/bin/sh')
    @line = paleturquoise(@line)
  # ======================================================================= #
  # === configure: creating ./config.status
  # ======================================================================= #
  elsif @line.start_with?('configure: creating ./config.status')
    @line = salmon(@line)
  end
  @line = @line.dup if @line.frozen?
  # ======================================================================= #
  # === -fno-strict-overflow
  # ======================================================================= #
  if @line.include? '-fno-strict-overflow'
    @line.sub!(
      /(-?fno-?strict-?overflow)/, colour_for_warnings_and_errors('\\1')
    )
  # ======================================================================= #
  # === I/O warning : failed to load external entity
  # ======================================================================= #
  elsif @line.include? 'I/O warning : failed to load external entity'
    @line = colour_for_warnings_and_errors(@line)
  # ======================================================================= #
  # === -- Configuring incomplete, errors occurred!
  # ======================================================================= #
  elsif @line.include? '-- Configuring incomplete, errors occurred!'
    @line = colour_for_warnings_and_errors(@line)
  # ======================================================================= #
  # === ld: error: cannot find -l
  # ======================================================================= #
  elsif @line.include? 'ld: error: cannot find -l'
    @line = colour_for_warnings_and_errors(@line)
  # ======================================================================= #
  # === git repository (or any of the parent directories): .git
  # ======================================================================= #
  elsif @line.include? 'fatal: not a'
    @line = colour_for_warnings_and_errors(@line)
  end
  # ======================================================================= #
  # === -Wno-error
  # ======================================================================= #
  if @line.include? '-Wno-error'
    @line.sub!(/(-?Wno-?error)/, colour_for_warnings_and_errors('\\1')+_paleturquoise)
  end
  # ======================================================================= #
  # === rm -f
  # ======================================================================= #
  if @line.start_with?('rm -f')
    @line.sub!(/^rm -f/, colour_for_warnings_and_errors('\\1'))
  end
  # ======================================================================= #
  # === make
  #
  # Colourize leading "make" instances.
  # ======================================================================= #
  if @line.include?('make') and
     @line.include?(':')
    use_this_regex = /^(make)(\[\d{1}\])(:)/ # See: http://rubular.com/r/ECr3ERniGs
    @line =~ use_this_regex
    @line.sub!(use_this_regex, lightseagreen('\\1')+lightsteelblue('\\2')+('\\3'))
  # ======================================================================= #
  # === make all-recursive
  # ======================================================================= #
  elsif @line.include?('make') and
        @line.include?('all-recursive')
    @line = lightseagreen(@line)
  # ======================================================================= #
  # === make install-am
  # ======================================================================= #
  elsif @line.include?('make') and
        @line.include?('all-am') # This also covers install-am.
    @line = lightseagreen(@line)
  # ======================================================================= #
  # === Making all in (or "Making install in")
  # ======================================================================= #
  elsif @line.include?('Making all in') or
        @line.include?('Making install in') or
        @line.include?('make  install-exec-hook')
    @line = lightseagreen(@line)
  end
  # ======================================================================= #
  # === make ("Nothing to be done for 'xyz'".)
  # ======================================================================= #
  if @line.include?('Nothing to be done for') and
     @line.include?('make')
    use_this_regex = /( Nothing to be done for ')(.+)'\./
    @line.sub!(
      use_this_regex,
      slategray('\\1')+cadetblue('\\2')+slategray("'.")
    )
  # ======================================================================= #
  # === 'installing' or '.gmo '
  #
  # Examples for what triggers the next line would be:
  #   installing sr.gmo link as /Programs/Coreutils/8.30/share/locale/sr/LC_TIME/coreutils.mo
  #   installing sv.gmo as /Programs/Coreutils/8.30/share/locale/sv/LC_MESSAGES/coreutils.mo
  # ======================================================================= #
  elsif (@line.include?('installing') and
         @line.include?('.gmo '))
    use_this_regex = /^(installing .{1,15}\.gmo .+)$/
    @line.sub!(use_this_regex, darkcyan('\\1'))
  # ======================================================================= #
  # === 'Nothing to be done for'
  # ======================================================================= #
  elsif @line.include?('Nothing to be done for')
    use_this_regex = /(Nothing to be done for)/
    @line.sub!(use_this_regex, darkcyan('\\1'))
  end
  # ======================================================================= #
  # === Colourize PROGRAMS entries, in combination with 'install:'
  # ======================================================================= #
  if @line.include?('install:') and
     @line.include?(programs_dir?)
     programs_dir = Regexp.quote(programs_dir?)
     use_this_regex = /(.+)(#{programs_dir}.+?\/\d{1,3}\.\d{1,3}\.\d{1,3})(.+)/ # See: http://rubular.com/r/CpflAmlajz
    @line.sub!(use_this_regex,
      '\\1'+colourize_directory_for_system_results('\\2')+'\\3')
  end
  # ======================================================================= #
  # === Handle Libtool next - we may have to put these entries into a
  #     new subsections altogether.
  # ======================================================================= #
  # === Handle 'libtool: compile:' entry points next
  # ======================================================================= #
  if @line.include?('libtool: compile:  gcc -')
    use_this_regex = /(gcc)( -)/
    @line.sub!(use_this_regex, orange('\\1')+'\\2')
  # ======================================================================= #
  # === libtool: compile:  gcc -
  # ======================================================================= #
  elsif @line.include?('libtool: compile:') 
    use_this_regex = /(libtool: compile:)/
    @line.sub!(use_this_regex, cadetblue('\\1'))
  # ======================================================================= #
  # === libtool: install:
  # ======================================================================= #
  elsif @line.include?('libtool: install: ') or # === libtool: install:
        @line.include?('libtool: finish: ') or  # === libtool: finish:
        @line.include?('libtool: link: ')       # === libtool: link:
    @line = cadetblue(@line)
  # ======================================================================= #
  # === 'libtool: warning:' and ' seems to be moved'
  # ======================================================================= #
  elsif (@line.include?('libtool: warning: ') and
        @line.include?(' seems to be moved'))
    @line = colour_for_warning_and_errors(@line)
  # ======================================================================= #
  # === 'ERROR: Neither directory contains a build file meson.build.'
  # ======================================================================= #
  elsif @line.include?('ERROR: Neither directory contains a build file meson.build.')
    @line = colour_for_warning_and_errors(@line)
    opne 'An error will be shown next, in red colour (if colours are used).'
    opne 'To aid in debugging, the current '\
         'working directory is:'
    opne sdir("  #{return_pwd}")
  # ======================================================================= #
  # === Libtool .la files
  # ======================================================================= #
  elsif @line.include? ".la' "
    use_this_regex = /'(.+\.la)'/ # See: http://rubular.com/r/KU3tB8ImeD
    @line.sub!(use_this_regex, "'"+lightgreen('\\1')+"'")
  end
  # ======================================================================= #
  # === Cmake log file
  # ======================================================================= #
  if @line.include?('See also "') and
     @line.include?('CMake') and
     @line.include?('.log')
    use_this_regex = /(See also ")(.+\.log)(".)/
    @line.sub!(use_this_regex, '\\1'+navajowhite('\\2')+'\\3')
  end
  # ======================================================================= #
  # === General warnings and errors
  #
  # This entry point will colourize the whole line.
  #
  # Some programs may use their own escape-code here, such as
  # "cc1: warning", which will appear colourized. Since this may
  # interfere with the colourizing that we do, the RBT project
  # will completely remove this colourization before doing
  # its own colourization.
  #
  # It will also match to lines such as the following one:
  #   valacodecontext.c:241:2: warning: 'g_static_private_get' is deprecated: Use 'g_private_get' instead [-Wdeprecated-declarations]
  # ======================================================================= #
  if (@line.include?("make: *** No rule to make target 'install'.  Stop.")) or
     (@line.include?("make: *** No targets specified and no makefile found.  Stop")) or
     (@line.include?('libtool: warning: relinking')) or
     (@line.include?('-- The following REQUIRED packages have not been found:')) or
     (@line.include?('ImportWarning:') and (@line.include?('.py') )) or
     (@line.include?('  from') and @line.include?('import')) or
     (@line.include?('.c: At top level:')) or
     (@line.include?('.c:') and @line.include?('warning: ') and @line.include?('is deprecated')) or
     (@line.include?('.cpp: In member function')) or
     (@line.include?('.cpp: In lambda function')) or
     (@line.include?('   ^~~~~~~~~~~~~~~~~~~')) or
     (@line.include?('cc1:') and @line.include?('warning:')) or # <- colourize cc1-related warnings in general
     (@line.include?('cc1:') and @line.include?('note:')) or
     (@line.include?('.la: No such file or directory')) or
     (@line.include?('No ') and @line.include?(' localization of ') and @line.include?(' exists; using')) or
     (@line.include?('Compilation failed: ') and @line.include?('error')) or # <- For lines such as this: "Compilation failed: 1 error(s), 8 warning(s)"
     (@line.include?('ninja: build stopped: subcommand failed.')) or # <- For lines such as "ninja: build stopped: subcommand failed."
     (@line.include?('UnicodeEncodeError: ')) or # <- Meson had some Unicode-related error
     (@line.include?(': DeprecationWarning: ')) or
     (@line.include?('ResourceWarning: unclosed file')) or
     (@line.include?(': warning: ')) or
     (@line.include?(".cpp: In static member function '")) or
     (@line.include?(": In function '") and @line.include?("':")) or
     (@line.include?('     ^~~~~~')) or
     (@line.end_with?('      ^')) or
     (@line.start_with?('Warn: '))
    # ===================================================================== #
    # We will colourize such lines in red - or rather, whatever the
    # method colour_for_warnings_and_errors() will assign to this line.
    # ===================================================================== #
    @line = colour_for_warnings_and_errors(
      Colours.remove_escape_sequences(@line)
    )
  end
  # ======================================================================= #
  # === General error handling past this point
  # ======================================================================= #
  if @line.start_with?("Couldn't find include") or
     @line.start_with?('configure: error:') or
     @line.include?('ld: warning:') or
    (@line.include?('fatal error: ') and @line.include?('.h: No such file or directory')) or
    (@line.start_with?('sh: ') and @line.include?('configure: No such file or directory'))
    @line = colourize_this_error(@line)
  # ======================================================================= #
  # === Cmake warning that "a required package was not found"
  # ======================================================================= #
  elsif @line.include?('A required package was not found') or
        @line.include?('-- Configuring incomplete, errors occurred!') or
        @line.include?('CMake Error at ') or
        @line.include?('  file RENAME failed to rename')
    @line = colourize_this_error(@line)
  # ======================================================================= #
  # === CMake Warning
  # ======================================================================= #
  elsif @line.include?('CMake Warning')
    @line.sub!(/(CMake Warning)/, colourize_this_warning('\\1'))
  # ======================================================================= #
  # === Cmake could not find OPTIONAL or RECOMMENDED packages
  # ======================================================================= #
  elsif @line.include?('-- The following OPTIONAL packages have not been found:') or
        @line.include?('-- The following RECOMMENDED packages have not been found:') or
        @line.include?('-- The following features have been disabled:')
    @line = colourize_this_warning(@line)
  # ======================================================================= #
  # === Colourize config.log entries
  # ======================================================================= #
  elsif @line.include?('config.log')
    @line.sub!(/(config\.log)/, sfile('\\1'))
  end
  # ======================================================================= #
  # === Simple line-colourizers start in this if clause
  #
  # Entries added past this point MUST colourize the WHOLE line -
  # otherwise they are simply not allowed to be here at all.
  # Additionally, colours for errors or warnings are NOT allowed here
  # either. Use earlier entry points for these.
  # ======================================================================= #
  # ======================================================================= #
  # === "install -c -m" or "install -c ./" or "install -c -m" or
  #     "mkdir -p "
  # ======================================================================= #
  if @line.include?('install -c -m') or
     @line.include?('install -c ./') or
     @line.include?('install -c ')   or
     @line.include?('mkdir -p ')     or
     @line.include?('ln -s -f')
    @line = lightseagreen(@line)
  # ======================================================================= #
  # === CSC lines
  #
  # The project called "mono" makes use of these, for example.
  # ======================================================================= #
  elsif @line.include?('CSC     [basic]') or # For mono and similar variants.
        @line.include?('     [build-linux] ') # <- This includes 'CSC' and 'AOT', too.
    @line = lightseagreen(@line)
  # ======================================================================= #
  # === This clause handles 'WARNING: Using xyz' or
  #     lines with ^~~~~~~~.
  # ======================================================================= #
  elsif @line.start_with?('WARNING: ') or
        @line.start_with?('   ^~~~~~~~~~~~~~~~~~~~~~~~')
    @line = colourize_for_warnings(@line)
  # ======================================================================= #
  # === Updating Gtk icon cache.
  # ======================================================================= #
  elsif @line.include?('Updating Gtk icon cache.')
    @line = gray(@line)
  # ======================================================================= #
  # === "Libraries have been installed in:"
  # ======================================================================= #
  elsif @line.include?('Libraries have been installed in:')
    @line = lightsteelblue(@line)
  # ======================================================================= #
  # === Handle KDE-runtime and optional packages
  #
  # This class will also handle (cmake-related) entries such as:
  #
  #  '-- The following REQUIRED packages have been found:'
  #
  # The four entry points include RUNTIME packages, OPTIONAL packages,
  # REQUIRED packages and RECOMMENDED packages.
  # ======================================================================= #
  elsif @line.include?('-- The following RUNTIME packages have been found:')  or
        @line.include?('-- The following OPTIONAL packages have been found:') or
        @line.include?('-- The following REQUIRED packages have been found:') or
        @line.include?('-- The following RECOMMENDED packages have been found:')
    @line = skyblue(@line)
  # ======================================================================= #
  # === "-- Looking for include file getopt.h - found"
  # ======================================================================= #
  elsif @line.include?('-- Looking for include file') and 
        @line.include?(' - found') # <- and include " - found".
    use_this_regex = /(-- Looking for include file )(.+.h)( - )([a-z]+)/ # See: https://rubular.com/r/lGSyJHlmd8HGfd
    @line.gsub!(
      use_this_regex, '\1'+cadetblue('\2')+'\3'+colour_for_found('\4')
    )
  # ======================================================================= #
  # === "-- Looking for include file getopt.h
  # ======================================================================= #
  elsif @line.include?('-- Looking for include file') and
       !@line.include?(' - found') # <- and NOT include " - found".
    use_this_regex = /(-- Looking for include file )(.+.h)/ # See: https://rubular.com/r/lGSyJHlmd8HGfd
    @line.gsub!(
      use_this_regex, '\1'+cadetblue('\2')
    )
  # ======================================================================= #
  # === "-- Looking for setmntent"
  #
  # This entry point really checks only for a one-word entry.
  # ======================================================================= #
  elsif @line.include?('-- Looking for ')
    use_this_regex = /^(-- Looking for )(\w+)$/ # See: https://rubular.com/r/SGXkPGeCStr7mo
    # ===================================================================== #
    # And append a colourized "- found" variant.
    # ===================================================================== #
    if stripped_line.end_with?(' - found')
      @line.sub!(/(found)$/, colour_for_found('\1'))
    end
    @line.gsub!(
      use_this_regex, '\1'+cadetblue('\2')
    )
  # ======================================================================= #
  # === Build Configuration:
  # ======================================================================= #
  elsif @line.include?('Build Configuration:')
    @line = orchid(@line)
  # ======================================================================= #
  # === The line ends with " - found"
  # ======================================================================= #
  elsif @line.end_with?(' - found')
    @line.sub!(/(found)$/, colour_for_found('\1'))
  # ======================================================================= #
  # === Colourize existing directories
  # ======================================================================= #
  elsif File.directory?(stripped_line)
    @line = sdir(stripped_line)
  end
  return @line # Also return it here, so that other programs can use this return value.
end
set_line(i = '') click to toggle source
#

set_line

#
# File lib/rbt/misc/colourize_parser.rb, line 59
def set_line(i = '')
  i = i.first if i.is_a? Array
  i = i.to_s.dup.chomp # We also .chomp on the input.
  @line = i
  sanitize_line if use_colours?
  return @line
end
Also aliased as: grab_this_line