<commit_before>require "hasu/version"

module Hasu
  def self.reloads
    @files ||= {}
  end

  def self.load(path)
    reloads[path] = File.mtime(path)
    begin
      super
      true
    rescue Exception => e
      Hasu.error = e
      false
    end
  end

  def self.error
    @error
  end

  def self.error=(error)
    @error = error
  end

  def self.run(window)
    unless @running
      @running = true
      window.new.show
    end
  end

  def self.reload!
    to_reload = reloads.select{|f,t| File.mtime(f) > t}

    !to_reload.empty? && to_reload.all? do |file,_|
      puts "Reloading #{file}"
      load(file)
    end
  end

  def self.prepended(other)
    includer = caller.first.split(":").first
    reloads[includer] = File.mtime(includer)<commit_msg>Print errors when they occur<commit_after>require "hasu/version"

module Hasu
  def self.reloads
    @files ||= {}
  end

  def self.load(path)
    reloads[path] = File.mtime(path)
    begin
      super
      true
    rescue Exception => e
      Hasu.error = e
      false
    end
  end

  def self.error
    @error
  end

  def self.error=(error)
    @error = error

    $stderr.puts @error.inspect
    $stderr.puts @error.backtrace.join("\n")
  end

  def self.run(window)
    unless @running
      @running = true
      window.new.show
    end
  end

  def self.reload!
    to_reload = reloads.select{|f,t| File.mtime(f) > t}

    !to_reload.empty? && to_reload.all? do |file,_|
      puts "Reloading #{file}"
      load(file)
    end
  end

  def self.prepended(other)
    includer = caller.first.split(":").first
    reloads[includer] = File.mtime(includer)
{'fraction_non_alphanumeric': 0.11894543225015328, 'fraction_numerical': 0.0, 'mean_word_length': 2.3442622950819674, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 7, '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': '1006311', 'n_tokens_mistral': 603, 'n_tokens_neox': 588, 'n_words': 133}