<commit_before>require "active_record_migrations/version"
require 'active_record'
require 'active_record/tasks/database_tasks'
require 'rails'
require 'rails/application'
require 'active_record_migrations/configurations'

# those requires are missing from AR but are required:
require 'zlib'
require 'digest'

module ActiveRecordMigrations
  include ActiveRecord::Tasks

  def self.configure(&block)
    create_rails_app_if_not_exists
    configurations.configure &block
  end

  def self.load_tasks
    create_rails_app_if_not_exists

    load 'active_record/railties/databases.rake'
    load 'active_record_migrations/tasks/new_migration.rake'

    ActiveRecord::Base.schema_format = configurations.schema_format
    DatabaseTasks.env = configurations.environment
    DatabaseTasks.seed_loader = configurations.seed_loader
    ActiveRecord::Base.configurations = DatabaseTasks.database_configuration =
      configurations.database_configuration
    ActiveRecord::Base.establish_connection ActiveRecord::Tasks::DatabaseTasks.env.to_sym
    DatabaseTasks.db_dir = configurations.db_dir
    DatabaseTasks.migrations_paths = configurations.migrations_paths
    DatabaseTasks.root = Rails.root
  end

  private

  def self.create_rails_app_if_not_exists
    Class.new(Rails::Application) unless Rails.application<commit_msg>line up 'ar_internal_metadata' env value<commit_after>require "active_record_migrations/version"
require 'active_record'
require 'active_record/tasks/database_tasks'
require 'rails'
require 'rails/application'
require 'active_record_migrations/configurations'

# those requires are missing from AR but are required:
require 'zlib'
require 'digest'

module ActiveRecordMigrations
  include ActiveRecord::Tasks

  def self.configure(&block)
    create_rails_app_if_not_exists
    configurations.configure &block
  end

  def self.load_tasks
    create_rails_app_if_not_exists

    load 'active_record/railties/databases.rake'
    load 'active_record_migrations/tasks/new_migration.rake'

    ActiveRecord::Base.schema_format = configurations.schema_format
    DatabaseTasks.env = configurations.environment
    Rails.env = DatabaseTasks.env
    DatabaseTasks.seed_loader = configurations.seed_loader
    ActiveRecord::Base.configurations = DatabaseTasks.database_configuration =
      configurations.database_configuration
    ActiveRecord::Base.establish_connection ActiveRecord::Tasks::DatabaseTasks.env.to_sym
    DatabaseTasks.db_dir = configurations.db_dir
    DatabaseTasks.migrations_paths = configurations.migrations_paths
    DatabaseTasks.root = Rails.root
  end

  private

  def self.create_rails_app_if_not_exists
    Class.new(Rails::Application) unless Rails.application
{'fraction_non_alphanumeric': 0.06691312384473198, 'fraction_numerical': 0.0, 'mean_word_length': 5.765, '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': '948169', 'n_tokens_mistral': 766, 'n_tokens_neox': 749, 'n_words': 137}