<commit_before>def databases
  require 'yaml'
  YAML.load(File.read('.kitchen.yml'))['suites'].
    map { |s| begin s['attributes']['mysql']['password'] rescue nil end }.uniq.compact
end

def there_are_databases
  databases.any?
end

desc 'Create database'
task :crebas do
  databases.each do |database|
    puts 'Creating database... '
    sh "mysql -u root -e 'create database if not exists #{database}';"
    sh "mysql -u root -e 'grant all on #{database}.* to \"#{database}\" identified by \"#{database}\";'"
    sh "mysql -u root -e 'flush privileges;'"
  end
end

desc 'Start local MySQL server'
task :start_mysql do
  if there_are_databases
    print 'Starting MySQL... '
    sh 'mysql.server start' do |ok, res|
      if ! ok
        puts '********************************************************'
        puts 'FAIL!'
        puts 'Are you sure MySQL is installed?'
        puts 'Make sure `mysql.server start` works before trying again'
        puts '********************************************************'
      else
        sleep 5
      end
    end
  end
end

desc 'Prepare MySQL for an attack run'
task prepare_database: [:start_mysql, :crebas]

desc 'Destroy test instance'
task :destroy do
  sh 'bundle exec kitchen destroy'
end

desc 'Converge test instance'
task :converge do
  sh 'bundle exec kitchen converge'
end

desc 'Verify test instance'
task :verify do
  sh 'bundle exec kitchen verify'
end

desc 'Run tests from scratch'
task scratch: [
  :destroy,
  :verify
]

desc 'Do everything from a cold start'
task test: [
  :prepare_database,
  :scratch
]

task default: :test
<commit_msg>Use the gem<commit_after>require 'spatula'

desc 'Create database'
task :crebas do
  Spatula::create '.kitchen.yml'
end

desc 'Start local MySQL server'
task :start_mysql do
  if Spatula::any_dbs? '.kitchen.yml'
    Spatula::start_mysql
  end
end

desc 'Prepare MySQL for an attack run'
task prepare_database: [:start_mysql, :crebas]

desc 'Destroy test instance'
task :destroy do
  sh 'bundle exec kitchen destroy'
end

desc 'Converge test instance'
task :converge do
  sh 'bundle exec kitchen converge'
end

desc 'Verify test instance'
task :verify do
  sh 'bundle exec kitchen verify'
end

desc 'Run tests from scratch'
task scratch: [
  :destroy,
  :verify
]

desc 'Do everything from a cold start'
task test: [
  :prepare_database,
  :scratch
]

task default: :test

{'fraction_non_alphanumeric': 0.14447711045779085, 'fraction_numerical': 0.00041999160016799666, 'mean_word_length': 3.754491017964072, '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': '207949', 'n_tokens_mistral': 754, 'n_tokens_neox': 740, 'n_words': 285}