<commit_before># Prompt configuration

brice 'prompt' => nil do |config|

  class IRB::Context
    %w[prompt_i prompt_s prompt_c prompt_n return_format].each { |name|
      define_method(name) {
        ivar = instance_variable_get("@#{name}")
        ivar.respond_to?(:call) ? ivar['%.4f' % @runtime] : ivar
      }
    }

    alias_method :_brice_original_evaluate, :evaluate

    # Capture execution time
    def evaluate(line, line_no)
      @runtime = Benchmark.realtime { _brice_original_evaluate(line, line_no) }
    end
  end

  IRB.conf[:PROMPT] ||= {}  # prevent error in webrick

  # prompt configuration:
  #
  #   PROMPT_I = normal prompt
  #   PROMPT_S = prompt for continuing strings
  #   PROMPT_C = prompt for continuing statement
  #   RETURN   = format to return value

  prefix = "#{RUBY_VERSION}"
  prefix << "p#{RUBY_PATCHLEVEL}" if defined?(RUBY_PATCHLEVEL)

  IRB.conf[:PROMPT].update(
    :BRICE_SIMPLE => {
      :PROMPT_I => '  ',
      :PROMPT_S => '  ',
      :PROMPT_C => '  ',
      :RETURN   => lambda { |rt| "#{rt} => %s\n" }
    },
    :BRICE_VERBOSE => {
      :PROMPT_I => "#{prefix}> ",
      :PROMPT_S => "#{prefix}> ",
      :PROMPT_C => "#{prefix}> ",
      :RETURN   => lambda { |rt| "#{rt} => %s\n" }
    }
  )

  IRB.conf[:PROMPT_MODE] = RUBY_VERSION < '1.9' ? :BRICE_SIMPLE : :BRICE_VERBOSE

end
<commit_msg>lib/rc/030_prompt.rb: Fall back to 0 runtime in case someone's being rude ;-)<commit_after># Prompt configuration

brice 'prompt' => nil do |config|

  class IRB::Context
    %w[prompt_i prompt_s prompt_c prompt_n return_format].each { |name|
      define_method(name) {
        ivar = instance_variable_get("@#{name}")
        ivar.respond_to?(:call) ? ivar['%.4f' % @runtime ||= 0] : ivar
      }
    }

    alias_method :_brice_original_evaluate, :evaluate

    # Capture execution time
    def evaluate(line, line_no)
      @runtime = Benchmark.realtime { _brice_original_evaluate(line, line_no) }
    end
  end

  IRB.conf[:PROMPT] ||= {}  # prevent error in webrick

  # prompt configuration:
  #
  #   PROMPT_I = normal prompt
  #   PROMPT_S = prompt for continuing strings
  #   PROMPT_C = prompt for continuing statement
  #   RETURN   = format to return value

  prefix = "#{RUBY_VERSION}"
  prefix << "p#{RUBY_PATCHLEVEL}" if defined?(RUBY_PATCHLEVEL)

  IRB.conf[:PROMPT].update(
    :BRICE_SIMPLE => {
      :PROMPT_I => '  ',
      :PROMPT_S => '  ',
      :PROMPT_C => '  ',
      :RETURN   => lambda { |rt| "#{rt} => %s\n" }
    },
    :BRICE_VERBOSE => {
      :PROMPT_I => "#{prefix}> ",
      :PROMPT_S => "#{prefix}> ",
      :PROMPT_C => "#{prefix}> ",
      :RETURN   => lambda { |rt| "#{rt} => %s\n" }
    }
  )

  IRB.conf[:PROMPT_MODE] = RUBY_VERSION < '1.9' ? :BRICE_SIMPLE : :BRICE_VERBOSE

end

{'fraction_non_alphanumeric': 0.15609228550829127, 'fraction_numerical': 0.003965392934390771, 'mean_word_length': 2.8865546218487395, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 35, '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': '4186011', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1019, 'n_words': 206}