Remove old seed scripts
This commit is contained in:
parent
65c4b1ceaf
commit
f9f583058a
5 changed files with 0 additions and 257 deletions
|
|
@ -1,64 +0,0 @@
|
|||
# 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] || read_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 = 'username@example.com'
|
||||
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}"
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
require File.join(File.dirname(__FILE__), "..", "..", "config", "environment")
|
||||
|
||||
def create
|
||||
|
||||
config = YAML.load_file(File.join(File.dirname(__FILE__), "..", "..", "config", "deploy_config.yml"))
|
||||
backer_info = config['servers']['backer']
|
||||
|
||||
backer_number = YAML.load_file(Rails.root.join('config','backer_number.yml'))[:seed_number].to_i
|
||||
|
||||
#set pod url
|
||||
username = backer_info[backer_number]['username'].gsub(/ /,'').downcase
|
||||
set_app_config username unless File.exists?(Rails.root.join('config', 'app.yml'))
|
||||
|
||||
require File.join(File.dirname(__FILE__), "..", "..", "config", "initializers", "_load_app.rb")
|
||||
|
||||
# Create seed user
|
||||
user = User.build(:email => "#{username}@#{username}.joindiaspora.com",
|
||||
:username => username,
|
||||
:password => "#{username+backer_info[backer_number]['pin'].to_s}",
|
||||
:password_confirmation => "#{username+backer_info[backer_number]['pin'].to_s}",
|
||||
:person => {
|
||||
:profile => {:first_name => backer_info[backer_number]['given_name'],
|
||||
:last_name => backer_info[backer_number]['family_name'],
|
||||
:image_url => "http://#{username}.joindiaspora.com/images/user/#{username}.jpg"
|
||||
}
|
||||
}
|
||||
)
|
||||
user.save
|
||||
user.person.save!
|
||||
|
||||
user.aspects.create(:name => "Presidents")
|
||||
end
|
||||
|
||||
def set_app_config username
|
||||
current_config = YAML.load(File.read(Rails.root.join('config', 'app.yml.example')))
|
||||
current_config[Rails.env.to_s] ||= {}
|
||||
current_config[Rails.env.to_s]['pod_url'] = "http://#{username}.joindiaspora.com/"
|
||||
current_config['default']['pod_url'] = "http://#{username}.joindiaspora.com/"
|
||||
file = File.new(Rails.root.join('..','..','shared','app.yml'),'w')
|
||||
file.write(current_config.to_yaml)
|
||||
file.close
|
||||
end
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
require File.join(File.dirname(__FILE__), "..", "..", "config", "environment")
|
||||
require File.join(File.dirname(__FILE__), "..", "..", "spec", "helper_methods")
|
||||
|
||||
def set_app_config username
|
||||
current_config = YAML.load(File.read(Rails.root.join('config', 'app.yml.example')))
|
||||
current_config[Rails.env.to_s] ||= {}
|
||||
current_config[Rails.env.to_s]['pod_url'] ||= "#{username}.joindiaspora.com"
|
||||
current_config['default']['pod_url'] ||= "#{username}.joindiaspora.com"
|
||||
file = File.new(Rails.root.join('config','app.yml'),'w')
|
||||
file.write(current_config.to_yaml)
|
||||
file.close
|
||||
end
|
||||
|
||||
username = "tom"
|
||||
set_app_config username unless File.exists?(Rails.root.join('config', 'app.yml'))
|
||||
|
||||
require Rails.root.join('config', "initializers", "_load_app_config.rb")
|
||||
include HelperMethods
|
||||
module Resque
|
||||
def enqueue(klass, *args)
|
||||
if $process_queue
|
||||
klass.send(:perform, *args)
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
# Create seed user
|
||||
user = User.build( :email => "tom@tom.joindiaspora.com",
|
||||
:username => "tom",
|
||||
:password => "evankorth",
|
||||
:password_confirmation => "evankorth",
|
||||
:person => {
|
||||
:profile => { :first_name => "Alexander", :last_name => "Hamiltom",
|
||||
:image_url => "/images/user/tom.jpg"}})
|
||||
|
||||
user.save!
|
||||
user.person.save!
|
||||
user.seed_aspects
|
||||
|
||||
user2 = User.build( :email => "korth@tom.joindiaspora.com",
|
||||
:password => "evankorth",
|
||||
:password_confirmation => "evankorth",
|
||||
:username => "korth",
|
||||
:person => {:profile => { :first_name => "Evan", :last_name => "Korth",
|
||||
:image_url => "/images/user/korth.jpg"}})
|
||||
|
||||
|
||||
user2.save!
|
||||
user2.person.save!
|
||||
user2.seed_aspects
|
||||
# connecting users
|
||||
|
||||
connect_users(user, user.aspects.first, user2, user2.aspects.first)
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
require File.join(File.dirname(__FILE__), "..", "..", "config", "environment")
|
||||
require File.join(File.dirname(__FILE__), "..", "..", "spec", "helper_methods")
|
||||
|
||||
def set_app_config username
|
||||
current_config = YAML.load(File.read(Rails.root.join('config', 'app.yml.example')))
|
||||
current_config[Rails.env.to_s] ||= {}
|
||||
current_config[Rails.env.to_s]['pod_url'] = "http://#{username}.joindiaspora.com/"
|
||||
current_config['default']['pod_url'] = "http://#{username}.joindiaspora.com/"
|
||||
file = File.new(Rails.root.join('..','..','shared','app.yml'),'w')
|
||||
file.write(current_config.to_yaml)
|
||||
file.close
|
||||
end
|
||||
|
||||
set_app_config "tom" unless File.exists?(Rails.root.join('config', 'app.yml'))
|
||||
|
||||
require 'config/initializers/_load_app_config.rb'
|
||||
include HelperMethods
|
||||
|
||||
# Create seed user
|
||||
user = User.build( :email => "tom@tom.joindiaspora.com",
|
||||
:username => "tom",
|
||||
:password => "evankorth",
|
||||
:password_confirmation => "evankorth",
|
||||
:person => {
|
||||
:profile => { :first_name => "Alexander", :last_name => "Hamiltom",
|
||||
:image_url => "http://tom.joindiaspora.com/images/user/tom.jpg"}})
|
||||
user.save!
|
||||
user.seed_aspects
|
||||
user.person.save!
|
||||
|
||||
user2 = User.build( :email => "korth@tom.joindiaspora.com",
|
||||
:password => "evankorth",
|
||||
:password_confirmation => "evankorth",
|
||||
:username => "korth",
|
||||
:person => {:profile => { :first_name => "Evan", :last_name => "Korth",
|
||||
:image_url => "http://tom.joindiaspora.com/images/user/korth.jpg"}})
|
||||
user2.save!
|
||||
user2.seed_aspects
|
||||
user2.person.save!
|
||||
# connecting users
|
||||
aspect = user.aspects.create(:name => "other dudes")
|
||||
aspect2 = user2.aspects.create(:name => "presidents")
|
||||
|
||||
connect_users(user, aspect, user2, aspect2)
|
||||
user.aspects.create(:name => "Presidents")
|
||||
|
|
@ -21,32 +21,6 @@ namespace :db do
|
|||
end
|
||||
end
|
||||
|
||||
desc 'Seed the current RAILS_ENV database from db/seeds.rb'
|
||||
namespace :seed do
|
||||
task :tom do
|
||||
puts "Seeding the database for #{Rails.env}..."
|
||||
require File.dirname(__FILE__) + '/../../db/seeds/tom'
|
||||
end
|
||||
|
||||
task :dev do
|
||||
puts "Seeding the database for #{Rails.env}..."
|
||||
require File.dirname(__FILE__) + '/../../db/seeds/dev'
|
||||
end
|
||||
|
||||
task :backer do
|
||||
puts "Seeding the database for #{Rails.env}..."
|
||||
require File.dirname(__FILE__) + '/../../db/seeds/backer'
|
||||
create
|
||||
end
|
||||
|
||||
task :first_user, :username, :password, :email do |t, args|
|
||||
puts "Setting up first user in #{Rails.env} database"
|
||||
ARGS = args
|
||||
require File.dirname(__FILE__) + '/../../db/seeds/add_user'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
desc 'Delete the collections in the current RAILS_ENV database'
|
||||
task :purge do
|
||||
require File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment')
|
||||
|
|
@ -67,20 +41,6 @@ namespace :db do
|
|||
puts "Success!"
|
||||
end
|
||||
|
||||
desc "Purge database and then add the first user"
|
||||
task :first_user, :username, :password, :email do |t, args|
|
||||
Rake::Task['db:purge'].invoke
|
||||
Rake::Task['db:seed:first_user'].invoke(args[:username], args[:password], args[:email])
|
||||
end
|
||||
task :first_user => :environment
|
||||
|
||||
desc "Add a new user to the database"
|
||||
task :add_user, :username, :password do |t, args|
|
||||
ARGS = args
|
||||
require File.dirname(__FILE__) + '/../../db/seeds/add_user'
|
||||
end
|
||||
task :add_user => :environment
|
||||
|
||||
task :drop_integration do
|
||||
ActiveRecord::Base.configurations.keys.select{ |k|
|
||||
k.include?("integration")
|
||||
|
|
|
|||
Loading…
Reference in a new issue