<commit_before>begin
  require 'highline/import'
rescue LoadError
  puts 'highline gem not installed'
end

namespace :onebody do
  
  desc 'Initialize database'
  task :init => [:environment, 'db:create', 'db:migrate'] do
    puts
    new_user = agree('Do you want to create a new admin user? ')
    Rake::Task['onebody:newuser'].invoke if new_user
    puts
    puts "Now, test your instance by running the following command:"
    puts 'ruby script/server'
    puts
    puts 'Browse to http://localhost:3000'
    puts 'Sign in with the email and password you just entered.' if new_user
  end

  desc 'Update database and settings.'
  task :update => [:environment, 'db:migrate', 'onebody:settings:update'] do
    puts
    puts 'System updated.'
  end
  
  namespace :settings do
    desc 'Updates all settings'
    task :update do
      Setting.update_all
    end
  end
  
  desc 'Create a new (admin) user. Use SITE="Site Name" for multisite.'
  task :newuser => :environment do
    puts 'Create new admin user...'
    Site.current = site = ENV['SITE'] ? Site.find_by_name(ENV['SITE']) : Site.find(1)
    unless password = ENV['PASSWORD'] or encrypted_password = ENV['ENCRYPTED_PASSWORD']
      password = ask('Password: ')         { |q| q.echo = false }
      confirm  = ask('Password (again): ') { |q| q.echo = false }
      raise 'Passwords do not match.' unless password == confirm
    end
    unless gender = ENV['GENDER']
      gender = ask('Gender ("m" or "f"): ').downcase == 'm' ? 'Male' : 'Female'
    end
    attrs = {
      :email                        => ENV['EMAIL'] || ask('Email Address: '),
      :first_name                   => ENV['FIRST'] || ask('First Name: '),
      :last_name                    => ENV['LAST']  || ask('Last Name: '),
      :gender                       => gender,
      :can_sign_in                  => true,
      :visible_to_everyone          => true,
      :visible_on_printed_directory => true,
      :full_access                  => true
    }
    attrs[:password] = password if password
    attrs[:encrypted_password] = <PASSWORD>_password if encrypted_password
    attrs[:salt] = ENV['SALT'] if ENV['SALT']
    person = site.people.create!(attrs)
    family = site.families.create!(
      :name => person.name,
      :last_name => person.last_name
    )
    family.people << person
    admins = site.settings.find_by_name('Super Admins')
    value = admins.value
    admins.update_attributes! :value => (value << person.email)
  end

end<commit_msg>Remove <EMAIL> from super admins when creating new user.<commit_after>begin
  require 'highline/import'
rescue LoadError
  puts 'highline gem not installed'
end

namespace :onebody do
  
  desc 'Initialize database'
  task :init => [:environment, 'db:create', 'db:migrate'] do
    puts
    new_user = agree('Do you want to create a new admin user? ')
    Rake::Task['onebody:newuser'].invoke if new_user
    puts
    puts "Now, test your instance by running the following command:"
    puts 'ruby script/server'
    puts
    puts 'Browse to http://localhost:3000'
    puts 'Sign in with the email and password you just entered.' if new_user
  end

  desc 'Update database and settings.'
  task :update => [:environment, 'db:migrate', 'onebody:settings:update'] do
    puts
    puts 'System updated.'
  end
  
  namespace :settings do
    desc 'Updates all settings'
    task :update do
      Setting.update_all
    end
  end
  
  desc 'Create a new (admin) user. Use SITE="Site Name" for multisite.'
  task :newuser => :environment do
    puts 'Create new admin user...'
    Site.current = site = ENV['SITE'] ? Site.find_by_name(ENV['SITE']) : Site.find(1)
    unless password = ENV['PASSWORD'] or encrypted_password = ENV['ENCRYPTED_PASSWORD']
      password = ask('Password: ')         { |q| q.echo = false }
      confirm  = ask('Password (again): ') { |q| q.echo = false }
      raise 'Passwords do not match.' unless password == confirm
    end
    unless gender = ENV['GENDER']
      gender = ask('Gender ("m" or "f"): ').downcase == 'm' ? 'Male' : 'Female'
    end
    attrs = {
      :email                        => ENV['EMAIL'] || ask('Email Address: '),
      :first_name                   => ENV['FIRST'] || ask('First Name: '),
      :last_name                    => ENV['LAST']  || ask('Last Name: '),
      :gender                       => gender,
      :can_sign_in                  => true,
      :visible_to_everyone          => true,
      :visible_on_printed_directory => true,
      :full_access                  => true
    }
    attrs[:password] = password if password
    attrs[:encrypted_password] = <PASSWORD> if encrypted_password
    attrs[:salt] = ENV['SALT'] if ENV['SALT']
    person = site.people.create!(attrs)
    family = site.families.create!(
      :name => person.name,
      :last_name => person.last_name
    )
    family.people << person
    admins = site.settings.find_by_name('Super Admins')
    value = admins.value
    admins.update_attributes! :value => (value << person.email).reject { |e| e == '<EMAIL>' }
  end

end
{'fraction_non_alphanumeric': 0.1287519747235387, 'fraction_numerical': 0.0019747235387045812, 'mean_word_length': 2.579505300353357, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 35, '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': '7277578', 'n_tokens_mistral': 1581, 'n_tokens_neox': 1556, 'n_words': 448}