<commit_before>module Shiny
  # Shiny::ANSI gives you some common ansi escape sequences, which
  # are available over a defined proxy method called 'shell', in
  # the core ruby String class.
  #
  # Some colors examples:
  #
  # puts "magenta".shell.magenta
  # puts "bold blue".shell.bold.blue
  # puts "yellow on cyan".shell.yellow.on_cyan
  # puts "bright blue on green".shell.bright_blue.on_green
  # puts "red on bright blue".shell.red.on_bright_blue
  #
  # Some other effect examples:
  #
  # puts "bold".shell.bold
  # puts "oh! i'm blinking".shell.blink
  # puts "nice and underlined".shell.underline
  # puts "other side, please".shell.negative
  class ANSI < Basic

    # ansi escape sequences list
    CODES = {
      'black'             =>   "\e[30m",
      'red'               =>   "\e[31m",
      'green'             =>   "\e[32m",
      'yellow'            =>   "\e[33m",
      'blue'              =>   "\e[34m",
      'magenta'           =>   "\e[35m",
      'cyan'              =>   "\e[36m",
      'white'             =>   "\e[37m",
      'bright_black'      =>   "\e[90m",
      'bright_red'        =>   "\e[91m",
      'bright_green'      =>   "\e[92m",
      'bright_yellow'     =>   "\e[93m",
      'bright_blue'       =>   "\e[94m",
      'bright_magenta'    =>   "\e[95m",
      'bright_cyan'       =>   "\e[96m",
      'bright_white'      =>   "\e[97m",
      'on_black'          =>   "\e[40m",
      'on_red'            =>   "\e[41m",
      'on_green'          =>   "\e[42m",
      'on_yellow'         =>   "\e[43m",
      'on_blue'           =>   "\e[44m",
      'on_magenta'        =>   "\e[45m",
      'on_cyan'           =>   "\e[46m",
      'on_white'          =>   "\e[47m",
      'on_bright_black'   =>  "\e[100m",
      'on_bright_red'     =>  "\e[101m",
      'on_bright_green'   =>  "\e[102m",
      'on_bright_yellow'  =>  "\e[103m",
      'on_bright_blue'    =>  "\e[104m",
      'on_bright_magenta' =>  "\e[105m",
      'on_bright_cyan'    =>  "\e[106m",
      'on_bright_white'   =>  "\e[107m",
      'reset'             =>    "\e[0m",
      'bold'              =>    "\e[1m",
      'underline'         =>    "\e[4m",
      'negative'          =>    "\e[7m",
      'blink'             =>    "\e[5m"
    }

    # list of available ansi colors
    COLORS  = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']

    # list of available ansi effects
    EFFECTS = ['bold', 'underline', 'negative', 'blink']

    # generate instance methods
    CODES.each do |code, value|
      next if code == 'reset'
      reset = CODES['reset']
      class_eval <<-DEF
        def #{code}
          @string = "#{value}" + @string + "#{reset}"
          self
        end
      DEF
    end

    # remove all ansi escape sequences
    def blank
      @string.gsub(/\e\[[0-9]+m/,'')
    end
  end
end<commit_msg>use symbols instead strings for performance<commit_after>module Shiny
  # Shiny::ANSI gives you some common ansi escape sequences, which
  # are available over a defined proxy method called 'shell', in
  # the core ruby String class.
  #
  # Some colors examples:
  #
  # puts "magenta".shell.magenta
  # puts "bold blue".shell.bold.blue
  # puts "yellow on cyan".shell.yellow.on_cyan
  # puts "bright blue on green".shell.bright_blue.on_green
  # puts "red on bright blue".shell.red.on_bright_blue
  #
  # Some other effect examples:
  #
  # puts "bold".shell.bold
  # puts "oh! i'm blinking".shell.blink
  # puts "nice and underlined".shell.underline
  # puts "other side, please".shell.negative
  class ANSI < Basic

    # ansi escape sequences list
    CODES = {
      :black             =>   "\e[30m",
      :red               =>   "\e[31m",
      :green             =>   "\e[32m",
      :yellow            =>   "\e[33m",
      :blue              =>   "\e[34m",
      :magenta           =>   "\e[35m",
      :cyan              =>   "\e[36m",
      :white             =>   "\e[37m",
      :bright_black      =>   "\e[90m",
      :bright_red        =>   "\e[91m",
      :bright_green      =>   "\e[92m",
      :bright_yellow     =>   "\e[93m",
      :bright_blue       =>   "\e[94m",
      :bright_magenta    =>   "\e[95m",
      :bright_cyan       =>   "\e[96m",
      :bright_white      =>   "\e[97m",
      :on_black          =>   "\e[40m",
      :on_red            =>   "\e[41m",
      :on_green          =>   "\e[42m",
      :on_yellow         =>   "\e[43m",
      :on_blue           =>   "\e[44m",
      :on_magenta        =>   "\e[45m",
      :on_cyan           =>   "\e[46m",
      :on_white          =>   "\e[47m",
      :on_bright_black   =>  "\e[100m",
      :on_bright_red     =>  "\e[101m",
      :on_bright_green   =>  "\e[102m",
      :on_bright_yellow  =>  "\e[103m",
      :on_bright_blue    =>  "\e[104m",
      :on_bright_magenta =>  "\e[105m",
      :on_bright_cyan    =>  "\e[106m",
      :on_bright_white   =>  "\e[107m",
      :reset             =>    "\e[0m",
      :bold              =>    "\e[1m",
      :underline         =>    "\e[4m",
      :negative          =>    "\e[7m",
      :blink             =>    "\e[5m"
    }

    # list of available ansi colors
    COLORS  = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']

    # list of available ansi effects
    EFFECTS = ['bold', 'underline', 'negative', 'blink']

    # generate instance methods
    CODES.each do |code, value|
      next if code == :reset
      reset = CODES[:reset]
      class_eval <<-DEF
        def #{code.to_s}
          @string = "#{value}" + @string + "#{reset}"
          self
        end
      DEF
    end

    # remove all ansi escape sequences
    def blank
      @string.gsub(/\e\[[0-9]+m/,'')
    end
  end
end
{'fraction_non_alphanumeric': 0.17017543859649123, 'fraction_numerical': 0.027719298245614036, 'mean_word_length': 1.6187413872301333, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '184956', 'n_tokens_mistral': 2158, 'n_tokens_neox': 2022, 'n_words': 420}