<commit_before>require 'capistrano-zen/base'
require 'yaml'

configuration = Capistrano::Configuration.respond_to?(:instance) ?
  Capistrano::Configuration.instance(:must_exist) :
  Capistrano.configuration(:must_exist)

configuration.load do

  _cset(:pg_config_path) { abort "[Error] posgtresql recipes need `pg_config_path` to find the database.yml file." }
  _cset(:pg_backup_path) { abort "[Error] posgtresql recipes need `pg_backup_path` to execute backups." }

  DB_FILE_PATH = "#{pg_config_path}/database.yml"
  DBCONFIG = YAML.load_file(DB_FILE_PATH)

  _cset(:postgresql_host) { DBCONFIG['production']['host'] }
  _cset(:postgresql_user) { DBCONFIG['production']['username'] }
  _cset(:postgresql_password) { DBCONFIG['production']['password'] }
  _cset(:postgresql_database) { DBCONFIG['production']['database'] }

  namespace :pg do
    desc "Install the latest stable release of PostgreSQL."
    task :install, roles: :db, only: {primary: true} do
      run "#{sudo} add-apt-repository -y ppa:pitti/postgresql"
      run "#{sudo} apt-get -y update"
      run "#{sudo} apt-get -y install postgresql libpq-dev"
    end

    desc "Create a database for this application."
    task :init, roles: :db, only: {primary: true} do
      # reset the database and role
      run %Q{#{sudo} -u postgres psql -c "CREATE USER #{postgresql_user} WITH PASSWORD '#{<PASSWORD>}';"}
      run %Q{#{sudo} -u postgres psql -c "CREATE DATABASE #{postgresql_database} OWNER #{postgresql_user};"}
    end

    desc "Reset the database and role for this application."
    task :reset, roles: :db, only: {primary: true} do<commit_msg>correct formats in postgresql<commit_after>require 'capistrano-zen/base'
require 'yaml'

configuration = Capistrano::Configuration.respond_to?(:instance) ?
  Capistrano::Configuration.instance(:must_exist) :
  Capistrano.configuration(:must_exist)

configuration.load do

  _cset(:pg_config_path) { abort "[Error] posgtresql recipes need `pg_config_path` to find the database.yml file." }
  _cset(:pg_backup_path) { abort "[Error] posgtresql recipes need `pg_backup_path` to execute backups." }

  DB_FILE_PATH = "#{pg_config_path}/database.yml"
  DBCONFIG = YAML.load_file(DB_FILE_PATH)

  _cset(:postgresql_host) { DBCONFIG['production']['host'] }
  _cset(:postgresql_user) { DBCONFIG['production']['username'] }
  _cset(:postgresql_password) { DBCONFIG['production']['password'] }
  _cset(:postgresql_database) { DBCONFIG['production']['database'] }

  namespace :pg do
    desc "Install the latest stable release of PostgreSQL."
    task :install, roles: :db, only: {primary: true} do
      run "#{sudo} add-apt-repository -y ppa:pitti/postgresql"
      run "#{sudo} apt-get -y update"
      run "#{sudo} apt-get -y install postgresql libpq-dev"
    end

    desc "Create a database for this application."
    task :init, roles: :db, only: { primary: true } do
      # reset the database and role
      run %Q{#{sudo} -u postgres psql -c "CREATE USER #{postgresql_user} WITH PASSWORD '#{<PASSWORD>}';"}
      run %Q{#{sudo} -u postgres psql -c "CREATE DATABASE #{postgresql_database} OWNER #{postgresql_user};"}
    end

    desc "Reset the database and role for this application."
    task :reset, roles: :db, only: { primary: true } do
{'fraction_non_alphanumeric': 0.134886572654813, 'fraction_numerical': 0.0, 'mean_word_length': 4.645328719723183, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1860872', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1077, 'n_words': 286}