<commit_before>module Rubygems
  module API
    # The Utilities module allows us to use the same functions throughout
    module Utilities
      def validate_format(format)
        return true if format == 'json' || format == 'yaml'

        fail RuntimeError,
             'Invalid format requested. Please select either json or yaml.'
      end

      def format_body(args = {})
        if args[:skip_format].nil?
          response = format_json_body(args[:response]) if args[:format] == 'json'
          response = format_yaml_body(args[:response]) if args[:format] == 'yaml'
        end

        response
      end

      def format_json_body(response)
        response.body = JSON.parse(response.body)

        response
      end

      def format_yaml_body(response)
        response.body = YAML.load(response.body)

        response
      end

      def ssl(arguments)
        @skip_verification = arguments[:skip_verification] || \
                      true

        @ca_path = arguments[:ca_path]  || \
                   `openssl version -d`.split(/"/)[1] + '/certs'

        @ssl_version = arguments[:ssl_version]  || \
                       'SSLv23'

        @client.ssl_options.skip_verification = @skip_verification
        @client.ssl_options.ca_path = @ca_path
        @client.ssl_options.version = @ssl_version
      end

      def get(url, format, hash, args = {})
        if validate_format format
          response = @client.get(url, hash)

          format_body response: response, skip_format: args[:skip_format],
                      format: format if response.success?
        end

        response
      end

      def yank_api(url, method_symbol, gem_name, gem_version, args = {})
        response = @client.method(method_symbol).call(url, {}.tap do |hash|
          hash[:gem_name] = gem_name
          hash[:gem_version] = gem_version unless gem_version.nil?
          hash[:platform] = args[:platform] unless args[:platform].nil?
        end)

        response
      end

      def api_key(key = nil)
        @api_key = key unless key.nil?
        @client.header[:Authorization] = @api_key unless @api_key.nil?

        @api_key
      end
    end
  end
end
<commit_msg>Remove duplicate<commit_after>module Rubygems
  module API
    # The Utilities module allows us to use the same functions throughout
    module Utilities
      def validate_format(format)
        return true if format == 'json' || format == 'yaml'

        fail RuntimeError,
             'Invalid format requested. Please select either json or yaml.'
      end

      def format_body(args = {})
        if args[:skip_format].nil?
          response = format_json_body(args[:response]) if args[:format] == 'json'
          response = format_yaml_body(args[:response]) if args[:format] == 'yaml'
        end

        response
      end

      def format_json_body(response)
        response.body = JSON.parse(response.body)

        response
      end

      def format_yaml_body(response)
        response.body = YAML.load(response.body)

        response
      end

      def ssl(arguments)
        @skip_verification = arguments[:skip_verification] || \
                      true

        @ca_path = arguments[:ca_path]  || \
                   `openssl version -d`.split(/"/)[1] + '/certs'

        @ssl_version = arguments[:ssl_version]  || \
                       'SSLv23'

        @client.ssl_options.skip_verification = @skip_verification
        @client.ssl_options.ca_path = @ca_path
        @client.ssl_options.version = @ssl_version
      end

      def get(url, format, hash, args = {})
        if validate_format format
          response = @client.get(url, hash)

          format_body response: response, skip_format: args[:skip_format],
                      format: format if response.success?
        end

        response
      end

      def yank_api(url, method_symbol, gem_name, gem_version, args = {})
        response = @client.method(method_symbol).call(url, {}.tap do |hash|
          hash[:gem_name] = gem_name
          hash[:gem_version] = gem_version unless gem_version.nil?
          hash[:platform] = args[:platform] unless args[:platform].nil?
        end)

        response
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.0985616599858524, 'fraction_numerical': 0.0014147606696533837, 'mean_word_length': 2.0895848506919155, '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': '97665', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1169, 'n_words': 290}