<commit_before>if defined?(ActionMailer)
  require File.join(File.dirname(__FILE__), 'handlers', 'mandrill_delivery_handler')
end

module Mailchimp
  class Mandrill
    include HTTParty
    parser MailchimpPsuedoJSONParser
    default_timeout 30

    attr_accessor :api_key, :timeout, :options

    def initialize(api_key = nil, extra_params = {})
      @api_key = api_key || ENV['MAILCHIMP_API_KEY'] || self.class.api_key
      @default_params = {
        :key => @api_key,
        :options => {
          :track_opens => true,
          :track_clicks => true
        }
      }.merge(extra_params)
    end

    def api_key=(value)
      @api_key = value
      @default_params = @default_params.merge({:key => @api_key})
    end

    def base_api_url
      "http://mandrillapp.com/api/1.0/"
    end

    def call(method, params = {})
      url = "#{base_api_url}#{method}"
      params = @default_params.merge(params)
      response = self.class.post(url, :body => params, :timeout => @timeout)

      begin
        response = JSON.parse(response.body)
      rescue
        response = response.body
      end
      response
    end

    def method_missing(method, *args)
      match = method.to_s.match(/([a-z]*)_([a-z]*)_?([a-z]*)/)
      method = "#{match[1]}/#{match[2]}#{match[3] == '' ? "" : "-"+match[3]}"
      args = {} unless args.length > 0
      args = args[0] if (args.class.to_s == "Array")
      call(method, args)
    end
    
    def valid_api_key?(*args)
      puts args.inspect
      '"PONG!"' == self.users_ping
    end
    
    class << self
      attr_accessor :api_key
      
      def method_missing(sym, *args, &block)
        self.api_key = args[0] if sym == :valid_api_key?
        new(self.api_key).send(sym, *args, &block)
      end
    end
  end
end
<commit_msg>Remove debug puts<commit_after>if defined?(ActionMailer)
  require File.join(File.dirname(__FILE__), 'handlers', 'mandrill_delivery_handler')
end

module Mailchimp
  class Mandrill
    include HTTParty
    parser MailchimpPsuedoJSONParser
    default_timeout 30

    attr_accessor :api_key, :timeout, :options

    def initialize(api_key = nil, extra_params = {})
      @api_key = api_key || ENV['MAILCHIMP_API_KEY'] || self.class.api_key
      @default_params = {
        :key => @api_key,
        :options => {
          :track_opens => true,
          :track_clicks => true
        }
      }.merge(extra_params)
    end

    def api_key=(value)
      @api_key = value
      @default_params = @default_params.merge({:key => @api_key})
    end

    def base_api_url
      "http://mandrillapp.com/api/1.0/"
    end

    def call(method, params = {})
      url = "#{base_api_url}#{method}"
      params = @default_params.merge(params)
      response = self.class.post(url, :body => params, :timeout => @timeout)

      begin
        response = JSON.parse(response.body)
      rescue
        response = response.body
      end
      response
    end

    def method_missing(method, *args)
      match = method.to_s.match(/([a-z]*)_([a-z]*)_?([a-z]*)/)
      method = "#{match[1]}/#{match[2]}#{match[3] == '' ? "" : "-"+match[3]}"
      args = {} unless args.length > 0
      args = args[0] if (args.class.to_s == "Array")
      call(method, args)
    end
    
    def valid_api_key?(*args)
      '"PONG!"' == self.users_ping
    end
    
    class << self
      attr_accessor :api_key
      
      def method_missing(sym, *args, &block)
        self.api_key = args[0] if sym == :valid_api_key?
        new(self.api_key).send(sym, *args, &block)
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.14345873104997192, 'fraction_numerical': 0.006176305446378439, 'mean_word_length': 2.4794921875, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '7216367', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1232, 'n_words': 240}