<commit_before>
require 'rib'

# from https://github.com/janlelis/ripl-multi_line
module Rib::Multiline
  include Rib::Plugin
  Shell.use(self)

  # test those:
  # ruby -e '"'
  # ruby -e '{'
  # ruby -e '['
  # ruby -e '('
  # ruby -e '/'
  # ruby -e 'class C'
  # ruby -e 'def f'
  # ruby -e 'begin'
  ERROR_REGEXP = Regexp.new(
    [ # string or regexp
      "unterminated \\w+ meets end of file",
      # mri and rubinius
      "syntax error, unexpected \\$end",
      # rubinius
      "expecting '.+'( or '.+')*",
      # jruby
      "syntax error, unexpected end-of-file",
    ].join('|'))

  def before_loop
    return super if Multiline.disabled?
    @multiline_buffer = []
    super
  end

  def prompt
    return super if Multiline.disabled?
    if @multiline_buffer.empty?
      super
    else
      "#{' '*(@prompt.size-2)}| "
    end
  end

  def loop_once
    return super if Multiline.disabled?
    catch(:multiline_cont) do
      super
      @multiline_buffer.clear
    end
  end

  def print_eval_error(e)
    return super if Multiline.disabled?
    if e.is_a?(SyntaxError) && e.message =~ ERROR_REGEXP
      @multiline_buffer << @input if @multiline_buffer.empty?
      throw :multiline_cont
    else
      super
    end
  end

  def loop_eval(input)
    return super if Multiline.disabled?
    if @multiline_buffer.empty?
      super
    else
      @multiline_buffer << input
      super @multiline_buffer.join("\n")
    end
  end

  def handle_interrupt
    return super if Multiline.disabled?
    if @multiline_buffer.empty?
      super
    else
      line = @multiline_buffer.pop
      print "[removed this line: #{line}]"
      super
      throw :multiline_cont
    end
  end
end
<commit_msg>fix use of @prompt (should be config[:prompt])<commit_after>
require 'rib'

# from https://github.com/janlelis/ripl-multi_line
module Rib::Multiline
  include Rib::Plugin
  Shell.use(self)

  # test those:
  # ruby -e '"'
  # ruby -e '{'
  # ruby -e '['
  # ruby -e '('
  # ruby -e '/'
  # ruby -e 'class C'
  # ruby -e 'def f'
  # ruby -e 'begin'
  ERROR_REGEXP = Regexp.new(
    [ # string or regexp
      "unterminated \\w+ meets end of file",
      # mri and rubinius
      "syntax error, unexpected \\$end",
      # rubinius
      "expecting '.+'( or '.+')*",
      # jruby
      "syntax error, unexpected end-of-file",
    ].join('|'))

  def before_loop
    return super if Multiline.disabled?
    @multiline_buffer = []
    super
  end

  def prompt
    return super if Multiline.disabled?
    if @multiline_buffer.empty?
      super
    else
      "#{' '*(config[:prompt].size-2)}| "
    end
  end

  def loop_once
    return super if Multiline.disabled?
    catch(:multiline_cont) do
      super
      @multiline_buffer.clear
    end
  end

  def print_eval_error(e)
    return super if Multiline.disabled?
    if e.is_a?(SyntaxError) && e.message =~ ERROR_REGEXP
      @multiline_buffer << @input if @multiline_buffer.empty?
      throw :multiline_cont
    else
      super
    end
  end

  def loop_eval(input)
    return super if Multiline.disabled?
    if @multiline_buffer.empty?
      super
    else
      @multiline_buffer << input
      super @multiline_buffer.join("\n")
    end
  end

  def handle_interrupt
    return super if Multiline.disabled?
    if @multiline_buffer.empty?
      super
    else
      line = @multiline_buffer.pop
      print "[removed this line: #{line}]"
      super
      throw :multiline_cont
    end
  end
end

{'fraction_non_alphanumeric': 0.11459832997408581, 'fraction_numerical': 0.0005758710048949035, 'mean_word_length': 2.3630203291384317, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '4407907', 'n_tokens_mistral': 1253, 'n_tokens_neox': 1172, 'n_words': 312}