<commit_before>require 'geocoder/lookups/base'
require 'geocoder/results/ipregistry'

module Geocoder::Lookup
  class Ipregistry < Base

    ERROR_CODES = {
      400 => Geocoder::InvalidRequest,
      401 => Geocoder::InvalidRequest,
      402 => Geocoder::OverQueryLimitError,
      403 => Geocoder::InvalidApiKey,
      451 => Geocoder::RequestDenied,
      500 => Geocoder::Error
    }
    ERROR_CODES.default = Geocoder::Error

    def name
      "Ipregistry"
    end

    def supported_protocols
      [:https]
    end

    private

    def base_query_url(query)
      "#{protocol}://#{host}/#{query.sanitized_text}?"
    end

    def cache_key(query)
      query_url(query)
    end

    def host
      configuration[:host] || "api.ipregistry.co"
    end

    def query_url_params(query)
      {
        key: configuration.api_key
      }.merge(super)
    end<commit_msg>Add HTTP to the list of supported protocols<commit_after>require 'geocoder/lookups/base'
require 'geocoder/results/ipregistry'

module Geocoder::Lookup
  class Ipregistry < Base

    ERROR_CODES = {
      400 => Geocoder::InvalidRequest,
      401 => Geocoder::InvalidRequest,
      402 => Geocoder::OverQueryLimitError,
      403 => Geocoder::InvalidApiKey,
      451 => Geocoder::RequestDenied,
      500 => Geocoder::Error
    }
    ERROR_CODES.default = Geocoder::Error

    def name
      "Ipregistry"
    end

    def supported_protocols
      [:https, :http]
    end

    private

    def base_query_url(query)
      "#{protocol}://#{host}/#{query.sanitized_text}?"
    end

    def cache_key(query)
      query_url(query)
    end

    def host
      configuration[:host] || "api.ipregistry.co"
    end

    def query_url_params(query)
      {
        key: configuration.api_key
      }.merge(super)
    end
{'fraction_non_alphanumeric': 0.10831937465103295, 'fraction_numerical': 0.020100502512562814, 'mean_word_length': 2.6948453608247425, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7467378', 'n_tokens_mistral': 616, 'n_tokens_neox': 580, 'n_words': 111}