sample-data
1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/environment'
system('rake db:populate')
people = []
NAMES = %w[ José João Antonio Paulo Maria Joana Paula Angela ]
SURNAMES = %w[ Silva Santos Abreu Oliveira Machado Bonfim ]
User.destroy_all
print "Creating users: "; $stdout.flush
for name in NAMES
for surname in SURNAMES
full_name = [name, surname].join(' ')
user = User.create!(
:login => full_name.to_slug,
:email => full_name.to_slug + '@localhost.localdomain',
:password => 'test',
:password_confirmation => 'test'
)
user.person.name = full_name
user.person.save!
people << user.person
print '.'; $stdout.flush
end
end
puts
print "Creating some friendships: "; $stdout.flush
rand(people.size * 3).times do
from = people.rand
to = people.rand
if from != to && !from.friends.include?(to)
from.add_friend(to)
end
print '.'; $stdout.flush
end
puts
VERBS = ['Save', 'I like', 'I hate', 'Use']
STUFF = ['Free Software', 'Organic food', 'the wales', 'the environment', 'Barack Obama', 'Osama Bin Laden', 'Lula']
Community.destroy_all
print "Creating communities: "; $stdout.flush
for verb in VERBS
for stuff in STUFF
name = [verb, stuff].join(' ')
community = Community.create!(:name => name)
rand(10).times do
community.add_member(people.rand)
end
print '.'; $stdout.flush
end
end
puts
ze = User.create!(:login => "ze", :email => 'root@localhost.localdomain', :password => 'test', :password_confirmation => 'test').person
Environment.default.add_admin(ze)