<commit_before>require 'net/http'

module Resque
  module Failure
    class Hoptoad < Base
      ##
      # Resque::Failure::Hoptoad.configure do |config|
      #   config.api_key = 'blah'
      #   config.secure = true
      # end
      class << self
        attr_accessor :secure, :api_key
      end

      def self.configure
        yield self
        Resque::Failure.backend = self
      end

      def save
        data = {
          :api_key       => api_key,
          :error_class   => exception.class.name,
          :error_message => "#{exception.class.name}: #{exception.message}",
          :backtrace     => exception.backtrace,
          :environment   => {},
          :session       => {},
          :request       => {
            :worker => worker.to_s,
            :queue  => queue.to_s,
            :params => payload
          }
        }

        send_to_hoptoad(:notice => data)
      end

      def send_to_hoptoad(data)<commit_msg>Implement `url` for Hoptoad backend<commit_after>require 'net/http'

module Resque
  module Failure
    class Hoptoad < Base
      ##
      # Resque::Failure::Hoptoad.configure do |config|
      #   config.api_key = 'blah'
      #   config.secure = true
      #   config.subdomain = 'your_hoptoad_subdomain'
      # end
      class << self
        attr_accessor :secure, :api_key, :subdomain
      end

      def self.url
        "http://#{subdomain}.hoptoadapp.com/" if subdomain
      end

      def self.configure
        yield self
        Resque::Failure.backend = self
      end

      def save
        data = {
          :api_key       => api_key,
          :error_class   => exception.class.name,
          :error_message => "#{exception.class.name}: #{exception.message}",
          :backtrace     => exception.backtrace,
          :environment   => {},
          :session       => {},
          :request       => {
            :worker => worker.to_s,
            :queue  => queue.to_s,
            :params => payload
          }
        }

        send_to_hoptoad(:notice => data)
      end

      def send_to_hoptoad(data)
{'fraction_non_alphanumeric': 0.11249401627573001, 'fraction_numerical': 0.0, 'mean_word_length': 1.6059850374064837, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 25, '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': '4797287', 'n_tokens_mistral': 623, 'n_tokens_neox': 610, 'n_words': 124}