<commit_before>require 'sinatra/base'
require 'active_record'
require 'logger'

module Sinatra
  module ActiveRecordHelper
    def database
      settings.database
    end
  end

  module ActiveRecordExtension
    def database=(url)
      set :database_url, url
      database
    end

    def database
      @database ||= begin
        ActiveRecord::Base.logger = activerecord_logger
        spec = database_url.is_a?(String) ? database_url.sub(/^sqlite:/, "sqlite3:") : database_url
        ActiveRecord::Base.establish_connection(spec)
        ActiveRecord::Base
      end
    end

  protected

    def self.registered(app)
      app.set :activerecord_logger, Logger.new(STDOUT)
      app.set :database_url, ENV['DATABASE_URL']<commit_msg>Reset the database connection when explicitly setting a new one<commit_after>require 'sinatra/base'
require 'active_record'
require 'logger'

module Sinatra
  module ActiveRecordHelper
    def database
      settings.database
    end
  end

  module ActiveRecordExtension
    def database=(url)
      set :database_url, url
      @database = nil
      database
    end

    def database
      @database ||= begin
        ActiveRecord::Base.logger = activerecord_logger
        spec = database_url.is_a?(String) ? database_url.sub(/^sqlite:/, "sqlite3:") : database_url
        ActiveRecord::Base.establish_connection(spec)
        ActiveRecord::Base
      end
    end

  protected

    def self.registered(app)
      app.set :activerecord_logger, Logger.new(STDOUT)
      app.set :database_url, ENV['DATABASE_URL']
{'fraction_non_alphanumeric': 0.08483290488431877, 'fraction_numerical': 0.0012853470437017994, 'mean_word_length': 3.129973474801061, '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': '2238273', 'n_tokens_mistral': 468, 'n_tokens_neox': 445, 'n_words': 106}