lib/xcres/logger.rb
# Prints a formatted message in a given color, and prints its arguments
# with bold font weight
#
# @param [String] message
#        the message, which can have format placeholders
#
# @param [Symbol] color
#        the color, String has to #respond_to? this
#
# @param [#to_s...] format_args
#        will be passed as right hand side to the percent operator,
#        which will fill the format placeholders used in the message
#
Prints a formatted message in a given color, and prints its arguments
with bold font weight
Prints a formatted message in a given color and prints its arguments with bold font weight
def inform_colored message, color, *format_args
    if colored?
      parts = message
         .gsub(/%[\ +#]?\d*\.?\d*[a-z]/, "\0"+'\0'+"\0")
         .split("\0")
         .reject(&:empty?)
      message = parts.map do |part|
        if part[0] == '%' && part[1] != '%'
          (part % [format_args.shift]).bold.gsub('%', '%%')
        else
          part
        end
      end.map(&color).join('')
    end
    inform message, *format_args
  end
def inform_colored message , color , * format_args if colored? parts = message . gsub ( / %[ \  +#]? \d * \. ? \d *[a-z] / , "\0" + '\0' + "\0" ) . split ( "\0" ) . reject ( & :empty? ) message = parts . map do | part | if part [ 0 ] == '%' && part [ 1 ] != '%' ( part % [ format_args . shift ] ) . bold . gsub ( '%' , '%%' ) else part end end . map ( & color ) . join ( '' ) end inform message , * format_args end
Prints a formatted message in a given color, and prints its arguments
with bold font weight
Prints a formatted message in a given color and prints its arguments with bold font weight
message
color
format_args
format_args will be passed as right hand side to the percent operator, which will fill the format placeholders used in the message
format_args will be passed as right hand side to the percent operator which will fill the format placeholders used in the message