<commit_before># Copyright (c) 2010, Diaspora Inc.  This file is
# licensed under the Affero General Public License version 3 or later.  See
# the COPYRIGHT file.
#
# Add a parameterized user to database.

require 'yaml'
require File.join(File.basename(__FILE__), '..', '..', 'config/environment')

def read_password
  begin
    system('stty -echo')
    while true do
      printf 'Enter password: '
      pw1 = $stdin.gets.chomp
      puts
      printf 'Again: '
      pw2 = $stdin.gets.chomp
      puts
      break if pw1 == pw2
      puts "They don't match, try again"
    end
  ensure
    system('stty echo')
  end
  return pw1
end

username = (ARGS[:username] || 'admin').dup
password = ARGS[:password] || <PASSWORD>
email = ARGS[:email] || "#{username}@#{AppConfig[:pod_uri].host}"
if email =~ /localhost$/
  puts "WARNING: localhost will not validate as an email domain"
  puts "\tupdate your email address, if you require email notifications for this account"
  puts "\trake db:first_user[username,password,email]"
  puts "\trake db:add_user[username,password]"
  puts "\tor modify your data store"
  email = '<EMAIL>'
end

user = User.build(:email => email,
                  :username => username,
                  :password => password,
                  :password_confirmation => password,
                  :person => {
                    :profile => {
                      :first_name => username,
                      :last_name => "Unknown",
                      :image_url => "/images/user/default.png"
                    }
                  }
)

user.valid?
errors = user.errors
errors.delete :person
if errors.size > 0
  raise "Error(s) creating user #{username} / #{email}: #{errors.full_messages.to_s}"
end

user.save
user.person.save!
user.seed_aspects
puts "Created user #{username} with email #{email}"
<commit_msg>basename vs. dirname fail -.-, sorry my bad<commit_after># Copyright (c) 2010, Diaspora Inc.  This file is
# licensed under the Affero General Public License version 3 or later.  See
# the COPYRIGHT file.
#
# Add a parameterized user to database.

require 'yaml'
require File.join(File.dirname(__FILE__), '..', '..', 'config/environment')

def read_password
  begin
    system('stty -echo')
    while true do
      printf 'Enter password: '
      pw1 = $stdin.gets.chomp
      puts
      printf 'Again: '
      pw2 = $stdin.gets.chomp
      puts
      break if pw1 == pw2
      puts "They don't match, try again"
    end
  ensure
    system('stty echo')
  end
  return pw1
end

username = (ARGS[:username] || 'admin').dup
password = ARGS[:password] || <PASSWORD>
email = ARGS[:email] || "#{username}@#{AppConfig[:pod_uri].host}"
if email =~ /localhost$/
  puts "WARNING: localhost will not validate as an email domain"
  puts "\tupdate your email address, if you require email notifications for this account"
  puts "\trake db:first_user[username,password,email]"
  puts "\trake db:add_user[username,password]"
  puts "\tor modify your data store"
  email = '<EMAIL>'
end

user = User.build(:email => email,
                  :username => username,
                  :password => password,
                  :password_confirmation => password,
                  :person => {
                    :profile => {
                      :first_name => username,
                      :last_name => "Unknown",
                      :image_url => "/images/user/default.png"
                    }
                  }
)

user.valid?
errors = user.errors
errors.delete :person
if errors.size > 0
  raise "Error(s) creating user #{username} / #{email}: #{errors.full_messages.to_s}"
end

user.save
user.person.save!
user.seed_aspects
puts "Created user #{username} with email #{email}"

{'fraction_non_alphanumeric': 0.12288249529443399, 'fraction_numerical': 0.005915568701263781, 'mean_word_length': 2.45724907063197, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 27, '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': '5859678', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1101, 'n_words': 336}