<commit_before>module BBLib
  # A useable string representation of the command line that evoked this ruby instance (platform agnostic)
  def self.command_line(*args, include_args: true, include_ruby: true, prefix: nil, suffix: nil)
    args = ARGV if args.empty?
    "#{prefix}#{include_ruby ? Command.quote(Gem.ruby) : nil} #{Command.quote($0)}" \
    " #{include_args ? args.map { |a| Command.quote(a) }.join(' ') : nil}#{suffix}"
      .strip
  end

  # EXPERIMENTAL: Reloads the original file that was called
  def self.reload(include_args: true)
    load "#{command_line(*args, include_ruby: false, include_args: false)}"
  end

  # EXPERIMENTAL: Restart the ruby process that is currently running.
  def self.restart(*args, include_args: true, stay_alive: 1)
    exit(0)
  rescue SystemExit
    opts = BBLib::OS.windows? ? { new_pgroup: true } : { pgroup: true }
    pid = spawn(command_line(*args, include_args: include_args, prefix: (BBLib::OS.windows? ? 'start ' : nil)), **opts)
    Process.detach(pid)
    sleep(stay_alive)
  end

  module Command
    def self.quote(arg)
      arg =~ /\s+/ ? "\"#{arg}\"" : arg.to_s
    end
  end

end
<commit_msg>Added handle for special cases for the exerimental reboot and reload methods.<commit_after>module BBLib
  # A useable string representation of the command line that evoked this ruby instance (platform agnostic)
  def self.cmd_line(*args, include_args: true, include_ruby: true, prefix: nil, suffix: nil)
    args = ARGV if args.empty?
    include_ruby = false if special_program?
    "#{prefix}#{include_ruby ? Command.quote(Gem.ruby) : nil} #{Command.quote($PROGRAM_NAME)}" \
    " #{include_args ? args.map { |a| Command.quote(a) }.join(' ') : nil}#{suffix}"
      .strip
  end

  # EXPERIMENTAL: Reloads the original file that was called
  # Use at your own risk, this could cause some weird issues
  def self.reload(include_args: true)
    return false if special_program?
    load cmd_line(*args, include_ruby: false, include_args: include_args)
  end

  # EXPERIMENTAL: Restart the ruby process that is currently running.
  # Use at your own risk
  def self.restart(*args, include_args: true, stay_alive: 1)
    exit(0)
  rescue SystemExit
    opts = BBLib::OS.windows? ? { new_pgroup: true } : { pgroup: true }
    pid = spawn(cmd_line(*args, include_args: include_args, prefix: (BBLib::OS.windows? ? 'start ' : nil)), **opts)
    Process.detach(pid)
    sleep(stay_alive)
    exit(0) if special_program?
  end

  SPECIAL_PROGRAMS = ['pry', 'irb.cmd', 'irb'].freeze

  def self.special_program?
    SPECIAL_PROGRAMS.include?($PROGRAM_NAME)
  end

  module Command
    def self.quote(arg)
      arg =~ /\s+/ ? "\"#{arg}\"" : arg.to_s
    end
  end

end

{'fraction_non_alphanumeric': 0.12693156732891833, 'fraction_numerical': 0.002207505518763797, 'mean_word_length': 3.803886925795053, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6474294', 'n_tokens_mistral': 952, 'n_tokens_neox': 920, 'n_words': 262}