<commit_before># Copyright 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


gem 'faraday', '~> 0.8.1'
require 'faraday'
require 'faraday/utils'
require 'multi_json'
require 'addressable/uri'
require 'stringio'
require 'google/api_client/discovery'

# TODO - needs some serious cleanup

module Google
  class APIClient
    class Reference
      MULTIPART_BOUNDARY = "-----------RubyApiMultipartPost".freeze

      def initialize(options={})
        # We only need this to do lookups on method ID String values
        # It's optional, but method ID lookups will fail if the client is
        # omitted.
        @client = options[:client]
        @version = options[:version] || 'v1'

        self.connection = options[:connection] || Faraday.default_connection
        self.authorization = options[:authorization]
        self.api_method = options[:api_method]
        self.parameters = options[:parameters] || {}
        # These parameters are handled differently because they're not
        # parameters to the API method, but rather to the API system.
        if self.parameters.kind_of?(Array)
          if options[:key]
            self.parameters.reject! { |k, _| k == 'key' }
            self.parameters << ['key', options[:key]]
          end
          if options[:user_ip]
            self.parameters.reject! { |k, _| k == 'userIp' }
            self.parameters << ['userIp', options[:user_ip]]
          end
        elsif self.parameters.kind_of?(Hash)
          self.parameters['key'] ||= options[:key] if options[:key]
          self.parameters['userIp'] ||= options[:user_ip] if options[:user_ip]
          # Convert to Array, because they're easier to work with when
          # repeated parameters are an issue.
          self.parameters = self.parameters.to_a
        else
          raise TypeError,
            "Expected Array or Hash, got #{self.parameters.class}."
        end
        self.headers = options[:headers] || {}
        if options[:media]
          self.media = options[:media]
          upload_type = self.parameters.find{|a| ['uploadType', 'upload_type'].include?(a[0])}[1]
          case upload_type
          when "media"
            if options[:body] || options[:body_object]
              raise ArgumentError,
                "Can not specify body & body object for simple uploads."<commit_msg>Syntax change to satisfy pull request<commit_after># Copyright 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


gem 'faraday', '~> 0.8.1'
require 'faraday'
require 'faraday/utils'
require 'multi_json'
require 'addressable/uri'
require 'stringio'
require 'google/api_client/discovery'

# TODO - needs some serious cleanup

module Google
  class APIClient
    class Reference
      MULTIPART_BOUNDARY = "-----------RubyApiMultipartPost".freeze

      def initialize(options={})
        # We only need this to do lookups on method ID String values
        # It's optional, but method ID lookups will fail if the client is
        # omitted.
        @client = options[:client]
        @version = options[:version] || 'v1'

        self.connection = options[:connection] || Faraday.default_connection
        self.authorization = options[:authorization]
        self.api_method = options[:api_method]
        self.parameters = options[:parameters] || {}
        # These parameters are handled differently because they're not
        # parameters to the API method, but rather to the API system.
        if self.parameters.kind_of?(Array)
          if options[:key]
            self.parameters.reject! { |k, _| k == 'key' }
            self.parameters << ['key', options[:key]]
          end
          if options[:user_ip]
            self.parameters.reject! { |k, _| k == 'userIp' }
            self.parameters << ['userIp', options[:user_ip]]
          end
        elsif self.parameters.kind_of?(Hash)
          self.parameters['key'] ||= options[:key] if options[:key]
          self.parameters['userIp'] ||= options[:user_ip] if options[:user_ip]
          # Convert to Array, because they're easier to work with when
          # repeated parameters are an issue.
          self.parameters = self.parameters.to_a
        else
          raise TypeError,
            "Expected Array or Hash, got #{self.parameters.class}."
        end
        self.headers = options[:headers] || {}
        if options[:media]
          self.media = options[:media]
          upload_type = self.parameters.find { |(k, _)| ['uploadType', 'upload_type'].include?(k) }.last
          case upload_type
          when "media"
            if options[:body] || options[:body_object]
              raise ArgumentError,
                "Can not specify body & body object for simple uploads."
{'fraction_non_alphanumeric': 0.10585152838427947, 'fraction_numerical': 0.004541484716157205, 'mean_word_length': 2.6401780038143676, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4420983', 'n_tokens_mistral': 1527, 'n_tokens_neox': 1492, 'n_words': 522}