<commit_before>require 'gaffe/version'

require 'ostruct'
require 'gaffe/errors'

module Gaffe
  # Yield a block to populate @configuration
  def self.configure
    yield configuration
  end

  # Return the configuration settings
  def self.configuration
    @configuration ||= OpenStruct.new
  end

  # Return our default controller
  def self.builtin_errors_controller
    require 'gaffe/errors_controller'
    Gaffe::ErrorsController
  end

  # Configure Rails to use our code when encountering exceptions
  def self.enable!
    Rails.application.config.exceptions_app = lambda do |env|
      Gaffe.errors_controller_for_request(env).action(:show).call(env)
    end
  end

  # Return the right errors controller to use for the request that
  # triggered the error
  def self.errors_controller_for_request(env)
    controller = configuration.errors_controller
<commit_msg>Memoize Gaffe.builtin_errors_controller<commit_after>require 'gaffe/version'

require 'ostruct'
require 'gaffe/errors'

module Gaffe
  # Yield a block to populate @configuration
  def self.configure
    yield configuration
  end

  # Return the configuration settings
  def self.configuration
    @configuration ||= OpenStruct.new
  end

  # Return our default controller
  def self.builtin_errors_controller
    @builtin_errors_controller ||= begin
      require 'gaffe/errors_controller'
      Gaffe::ErrorsController
    end
  end

  # Configure Rails to use our code when encountering exceptions
  def self.enable!
    Rails.application.config.exceptions_app = lambda do |env|
      Gaffe.errors_controller_for_request(env).action(:show).call(env)
    end
  end

  # Return the right errors controller to use for the request that
  # triggered the error
  def self.errors_controller_for_request(env)
    controller = configuration.errors_controller

{'fraction_non_alphanumeric': 0.061850027367268745, 'fraction_numerical': 0.0, 'mean_word_length': 4.120448179271708, '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': '1295988', 'n_tokens_mistral': 511, 'n_tokens_neox': 502, 'n_words': 152}