<commit_before>require 'net/http'

# Plugin for applications to automatically post errors to Hoptoad.
module HoptoadNotifier

  class << self
    attr_accessor :host, :port, :secure, :project_name, :filter_params
    attr_reader   :backtrace_filters

    def exceptions_for_404
      @exceptions_for_404 ||= []
    end
    
    def filter_backtrace &block
      (@backtrace_filters ||= []) << block
    end

    def port
      @port || (secure ? 443 : 80)
    end

    def params_filters
      @params_filters ||= %w(password)
    end
    
    def configure
      yield self
    end
    
    def protocol
      secure ? "https" : "http"
    end
    
    def url
      URI.parse("#{protocol}://#{host}:#{port}/notices/")
    end
    
    def default_notice_options
      {
        :project_name  => HoptoadNotifier.project_name,
        :error_message => 'Notification',
        :backtrace     => caller,
        :request       => {},
        :session       => {},
        :environment   => ENV.to_hash
      }
    end
    
    def notify notice = {}
      Sender.new.inform_hoptoad( notice )
    end
  end

  filter_backtrace do |line|
    line.gsub(/#{RAILS_ROOT}/, "[RAILS_ROOT]")
  end

  filter_backtrace do |line|
    line.gsub(/^\.\//, "")
  end

  filter_backtrace do |line|
    Gem.path.inject(line) do |line, path|
      line.gsub(/#{path}/, "[GEM_ROOT]")
    end
  end

  module Catcher

    def self.included(base)
      base.alias_method_chain :rescue_action_in_public, :hoptoad
    end
    
    def rescue_action_in_public_with_hoptoad exception
      inform_hoptoad(exception)
      rescue_action_in_public_without_hoptoad(exception)<commit_msg>Preventative measures on hoptoad_notifier and squirrel<commit_after>require 'net/http'

# Plugin for applications to automatically post errors to Hoptoad.
module HoptoadNotifier

  class << self
    attr_accessor :host, :port, :secure, :project_name, :filter_params
    attr_reader   :backtrace_filters

    def exceptions_for_404
      @exceptions_for_404 ||= []
    end
    
    def filter_backtrace &block
      (@backtrace_filters ||= []) << block
    end

    def port
      @port || (secure ? 443 : 80)
    end

    def params_filters
      @params_filters ||= %w(password)
    end
    
    def configure
      yield self
    end
    
    def protocol
      secure ? "https" : "http"
    end
    
    def url
      URI.parse("#{protocol}://#{host}:#{port}/notices/")
    end
    
    def default_notice_options
      {
        :project_name  => HoptoadNotifier.project_name,
        :error_message => 'Notification',
        :backtrace     => caller,
        :request       => {},
        :session       => {},
        :environment   => ENV.to_hash
      }
    end
    
    def notify notice = {}
      Sender.new.inform_hoptoad( notice )
    end
  end

  filter_backtrace do |line|
    line.gsub(/#{RAILS_ROOT}/, "[RAILS_ROOT]")
  end

  filter_backtrace do |line|
    line.gsub(/^\.\//, "")
  end

  filter_backtrace do |line|
    Gem.path.inject(line) do |line, path|
      line.gsub(/#{path}/, "[GEM_ROOT]")
    end
  end

  module Catcher

    def self.included(base)
      return if base.instance_methods.include? 'rescue_action_in_public_with_hoptoad'
      base.alias_method_chain :rescue_action_in_public, :hoptoad
    end
    
    def rescue_action_in_public_with_hoptoad exception
      inform_hoptoad(exception)
      rescue_action_in_public_without_hoptoad(exception)
{'fraction_non_alphanumeric': 0.10595065312046444, 'fraction_numerical': 0.006386066763425254, 'mean_word_length': 2.4322709163346614, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '5795888', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1128, 'n_words': 238}