<commit_before>
require 'rib'

module Rib::Anchor
  include Rib::Plugin
  Shell.use(self)

  def loop_eval(str)
    case obj_or_binding = (Rib.vars[:anchor] ||= []).last
      when NilClass
        super

      when Binding
        @binding = obj_or_binding
        super

      else
        obj_or_binding.instance_eval(str, "(#{config[:name]})", config[:line])
    end
  end

  def prompt
    if Rib.const_defined?(:Color) && kind_of?(Rib::Color) &&
       obj_or_binding = (Rib.vars[:anchor] ||= []).last

      super.sub(config[:name], format_color(obj_or_binding, config[:name]))
    else
      super
    end
  end

  # if the object is the same, then we're exiting from an anchor,
  # so don't print anything.
  def print_result result
    super unless !result.nil? &&
                 result.object_id == Rib.vars[:anchor_last].object_id
  end

  module Imp
    def short_inspect obj_or_binding
      obj_or_binding.inspect[0..9]
    end
  end

  module AnchorImp
    def anchor obj_or_binding
      return if Rib::Anchor.disabled?

      (Rib.vars[:anchor] ||= []) << obj_or_binding
      name = Rib::P.short_inspect(obj_or_binding)

      Rib.shells <<
        Rib::Shell.new(Rib.config.merge(
          :name   => name,
          :prompt => "#{name}(#{Rib.vars[:anchor].size})" +
                     (Rib.config[:prompt] || '>> ')))

      Rib.shell.loop
      Rib.vars[:anchor].last # the way to hide return value from Rib.anchor

    ensure
      # stores to check if we're exiting from an anchor
      Rib.vars[:anchor_last] = Rib.vars[:anchor].pop
      Rib.shells.pop
    end
  end

  Plugin.extend(Imp)
  Rib   .extend(AnchorImp)<commit_msg>anchor.rb: make anchor could correctly be disabled<commit_after>
require 'rib'

module Rib::Anchor
  include Rib::Plugin
  Shell.use(self)

  def loop_eval str
    return super if Rib::Anchor.disabled?
    case obj_or_binding = (Rib.vars[:anchor] ||= []).last
      when NilClass
        super

      when Binding
        @binding = obj_or_binding
        super

      else
        obj_or_binding.instance_eval(str, "(#{config[:name]})", config[:line])
    end
  end

  def prompt
    return super if Rib::Anchor.disabled?
    if Rib.const_defined?(:Color) && kind_of?(Rib::Color) &&
       obj_or_binding = (Rib.vars[:anchor] ||= []).last

      super.sub(config[:name], format_color(obj_or_binding, config[:name]))
    else
      super
    end
  end

  # if the object is the same, then we're exiting from an anchor,
  # so don't print anything.
  def print_result result
    return super if Rib::Anchor.disabled?
    super unless !result.nil? &&
                 result.object_id == Rib.vars[:anchor_last].object_id
  end

  module Imp
    def short_inspect obj_or_binding
      obj_or_binding.inspect[0..9]
    end
  end

  module AnchorImp
    def anchor obj_or_binding
      return if Rib::Anchor.disabled?

      (Rib.vars[:anchor] ||= []) << obj_or_binding
      name = Rib::P.short_inspect(obj_or_binding)

      Rib.shells <<
        Rib::Shell.new(Rib.config.merge(
          :name   => name,
          :prompt => "#{name}(#{Rib.vars[:anchor].size})" +
                     (Rib.config[:prompt] || '>> ')))

      Rib.shell.loop
      Rib.vars[:anchor].last # the way to hide return value from Rib.anchor

    ensure
      return if Rib::Anchor.disabled?
      # stores to check if we're exiting from an anchor
      Rib.vars[:anchor_last] = Rib.vars[:anchor].pop
      Rib.shells.pop
    end
  end

  Plugin.extend(Imp)
  Rib   .extend(AnchorImp)
{'fraction_non_alphanumeric': 0.12457337883959044, 'fraction_numerical': 0.0011376564277588168, 'mean_word_length': 2.5382293762575454, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '1320945', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1137, 'n_words': 267}