<commit_before>module Boundio
  class Resource
    class << self
      def user_serial_id
        ENV["BOUNDIO_USER_SERIAL_ID"]
      end
      
      def api_key
        ENV["BOUNDIO_API_KEY"]
      end

      def user_authentication_key
        ENV["BOUNDIO_USER_AUTHENTICATION_KEY"]
      end

      def request(method, path, params)
        params = params.merge(:key => api_key, :auth => user_authentication_key)
        res = RestClient.send method,
          File.join("https://boundio.jp/api/vd1/#{user_serial_id}", path), 
          method == :get ? { :params => params } : params
        res = JSON.parse(res)
        res = res.first if res.is_a?(Array)
        unless res["success"] == "true"
          raise exceptions[res["error"].to_i] || Boundio::Exception.new("Error Code #{res["error"]}")<commit_msg>raise error if keys aren't present<commit_after>module Boundio
  class Resource
    class << self
      %w[user_serial_id api_key user_authentication_key].each do |s|
        var = "BOUNDIO_#{s.upcase}"
        define_method(s) do
          ENV[var] || raise("Please export #{var}")
        end
      end

      def request(method, path, params)
        params = params.merge(:key => api_key, :auth => user_authentication_key)
        res = RestClient.send method,
          File.join("https://boundio.jp/api/vd1/#{user_serial_id}", path), 
          method == :get ? { :params => params } : params
        res = JSON.parse(res)
        res = res.first if res.is_a?(Array)
        unless res["success"] == "true"
          raise exceptions[res["error"].to_i] || Boundio::Exception.new("Error Code #{res["error"]}")
{'fraction_non_alphanumeric': 0.1354996934396076, 'fraction_numerical': 0.001226241569589209, 'mean_word_length': 2.6026490066225167, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '1842187', 'n_tokens_mistral': 515, 'n_tokens_neox': 504, 'n_words': 109}