<commit_before>require 'json'
require 'cgi'
require 'rest-client'
require 'sqlite3'

module CloudDrive

  class Account

    attr_reader :access_token, :metadata_url, :content_url, :email, :token_store, :db

    def initialize(email, client_id, client_secret)
      @email = email
      @cache_file = File.expand_path("~/.clouddrive/#{email}.cache")
      @client_id = client_id
      @client_secret = client_secret

      @db = SQLite3::Database.new(File.expand_path("~/.clouddrive/#{@email}.db"))
      if @db.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='nodes';").empty?
        @db.execute <<-SQL
         CREATE TABLE nodes(
            id VARCHAR PRIMARY KEY NOT NULL,
            name VARCHAR NOT NULL,
            kind VARCHAR NOT NULL,
            md5 VARCHAR,
            created DATETIME NOT NULL,
            modified DATETIME NOT NULL,
            raw_data TEXT NOT NULL
         );
        SQL
      end
    end

    def authorize(auth_url = nil)
      retval = {
        :success => true,
        :data => {}
      }

      @token_store = {
          "checkpoint" => nil,
          "nodes" => {}
      }

      if File.exists?(@cache_file)
        @token_store = JSON.parse(File.read(@cache_file))
      end

      if !@token_store.has_key?("access_token")
        if auth_url.nil?
          retval[:success] = false
          retval[:data]["message"] = "Initial authorization required."
          retval[:data]["auth_url"] = "https://www.amazon.com/ap/oa?client_id=#{@client_id}&scope=clouddrive%3Aread%20clouddrive%3Awrite&response_type=code&redirect_uri=http://localhost"

          return retval
        else
          data = request_authorization(auth_url)
        end

        if data[:success] === true<commit_msg>simplified retval value for method<commit_after>require 'json'
require 'cgi'
require 'rest-client'
require 'sqlite3'

module CloudDrive

  class Account

    attr_reader :access_token, :metadata_url, :content_url, :email, :token_store, :db

    def initialize(email, client_id, client_secret)
      @email = email
      @cache_file = File.expand_path("~/.clouddrive/#{email}.cache")
      @client_id = client_id
      @client_secret = client_secret

      @db = SQLite3::Database.new(File.expand_path("~/.clouddrive/#{@email}.db"))
      if @db.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='nodes';").empty?
        @db.execute <<-SQL
         CREATE TABLE nodes(
            id VARCHAR PRIMARY KEY NOT NULL,
            name VARCHAR NOT NULL,
            kind VARCHAR NOT NULL,
            md5 VARCHAR,
            created DATETIME NOT NULL,
            modified DATETIME NOT NULL,
            raw_data TEXT NOT NULL
         );
        SQL
      end
    end

    def authorize(auth_url = nil)
      retval = {
        :success => true,
        :data => {}
      }

      @token_store = {
          "checkpoint" => nil,
          "nodes" => {}
      }

      if File.exists?(@cache_file)
        @token_store = JSON.parse(File.read(@cache_file))
      end

      if !@token_store.has_key?("access_token")
        if auth_url.nil?
          retval = {
            :success => false,
            :data => {
              "message" => "Initial authorization required",
              "auth_url" => "https://www.amazon.com/ap/oa?client_id=#{@client_id}&scope=clouddrive%3Aread%20clouddrive%3Awrite&response_type=code&redirect_uri=http://localhost"
            }
          }

          return retval
        else
          data = request_authorization(auth_url)
        end

        if data[:success] === true
{'fraction_non_alphanumeric': 0.11764705882352941, 'fraction_numerical': 0.0039029829941455256, 'mean_word_length': 2.2093023255813953, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 2, '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': '7287808', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1062, 'n_words': 235}