sportdb 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -3,9 +3,17 @@ Manifest.txt
3
3
  README.markdown
4
4
  Rakefile
5
5
  bin/sportdb
6
+ db/cl/2011_12/cl.rb
7
+ db/cl/2011_12/el.rb
8
+ db/cl/2012_13/cl.rb
9
+ db/cl/teams.rb
10
+ db/euro/2012.rb
11
+ db/euro/teams.rb
12
+ db/world/quali_2012_13.rb
6
13
  lib/sportdb.rb
7
14
  lib/sportdb/cli/opts.rb
8
15
  lib/sportdb/cli/runner.rb
16
+ lib/sportdb/loader.rb
9
17
  lib/sportdb/models.rb
10
18
  lib/sportdb/schema.rb
11
19
  lib/sportdb/utils.rb
@@ -0,0 +1,86 @@
1
+ # encoding: utf-8
2
+
3
+ # note: timezone for games (play_at) is *always* CET (central european time)
4
+
5
+ #################################
6
+ ## Champions League 2011/12
7
+
8
+ ## note :team3 => false CL has no 3rd place (only final game)
9
+ cl = Event.create!( :key => 'cl',
10
+ :title => 'Champions League 2011/12',
11
+ :start_at => Time.cet( '2011-10-10 17:00' ) )
12
+
13
+ inter = Team.find_by_key!( 'inter' )
14
+ marseille = Team.find_by_key!( 'marseille' )
15
+ bayern = Team.find_by_key!( 'bayern' )
16
+ basel = Team.find_by_key!( 'basel' )
17
+
18
+ chelsea = Team.find_by_key!( 'chelsea' )
19
+ napoli = Team.find_by_key!( 'napoli' )
20
+ madrid = Team.find_by_key!( 'madrid' )
21
+ moskva = Team.find_by_key!( 'moskva' )
22
+
23
+ milan = Team.find_by_key!( 'milan' )
24
+ benfica = Team.find_by_key!( 'benfica' )
25
+ barcelona = Team.find_by_key!( 'barcelona' )
26
+ apoel = Team.find_by_key!( 'apoel' )
27
+
28
+ cl.teams << milan
29
+ cl.teams << benfica
30
+ cl.teams << barcelona
31
+ cl.teams << apoel
32
+
33
+ cl.teams << chelsea
34
+ cl.teams << madrid
35
+ cl.teams << marseille
36
+ cl.teams << bayern
37
+
38
+
39
+ cl16 = Round.create!( :event => cl, :pos => 1, :title => 'Achtelfinale' )
40
+ cl16_2 = Round.create!( :event => cl, :pos => 2, :title => 'Achtelfinale Rückspiele' )
41
+ cl8 = Round.create!( :event => cl, :pos => 3, :title => 'Viertelfinale', :title2 => '27.+28. März 2012' )
42
+ cl8_2 = Round.create!( :event => cl, :pos => 4, :title => 'Viertelfinale Rückspiele', :title2 => '3.+4. April 2012' )
43
+ cl4 = Round.create!( :event => cl, :pos => 5, :title => 'Halbfinale', :title2 => '17.+18. April 2012' )
44
+ cl4_2 = Round.create!( :event => cl, :pos => 6, :title => 'Halbfinale Rückspiele', :title2 => '24.+25. April 2012' )
45
+ cl1 = Round.create!( :event => cl, :pos => 7, :title => 'Finale', :title2 => '19. Mai 2012' )
46
+
47
+
48
+ games_cl16 = [
49
+ [[ 1, napoli, [3, 1], chelsea, Time.cet('2012-02-21 20:45') ],
50
+ [ 3, chelsea, [3, 1, 4, 1], napoli, Time.cet('2012-03-14 20:45') ]],
51
+ [[ 2, moskva, [1, 1], madrid, Time.cet('2012-02-21 20:45') ],
52
+ [ 4, madrid, [4, 1], moskva, Time.cet('2012-03-14 20:45') ]],
53
+ [[ 3, marseille, [1, 0], inter, Time.cet('2012-02-22 20:45') ],
54
+ [ 1, inter, [2, 1], marseille, Time.cet('2012-03-13 20:45') ]],
55
+ [[ 4, basel, [1, 0], bayern, Time.cet('2012-02-22 20:45') ],
56
+ [ 2, bayern, [7, 0], basel, Time.cet('2012-03-13 20:45') ]]
57
+ ]
58
+
59
+ games_cl8 = [
60
+ [[ 1, apoel, [0, 3], madrid, Time.cet('2012-03-27 20:45') ],
61
+ [ 4, madrid, [5, 2], apoel, Time.cet('2012-04-04 20:45') ]],
62
+ [[ 2, benfica, [0, 1], chelsea, Time.cet('2012-03-27 20:45') ],
63
+ [ 3, chelsea, [2, 1], benfica, Time.cet('2012-04-04 20:45') ]],
64
+ [[ 3, marseille, [0, 2], bayern, Time.cet('2012-03-28 20:45') ],
65
+ [ 2, bayern, [2, 0], marseille, Time.cet('2012-04-03 20:45') ]],
66
+ [[ 4, milan, [0, 0], barcelona, Time.cet('2012-03-28 20:45') ],
67
+ [ 1, barcelona, [3, 1], milan, Time.cet('2012-04-03 20:45') ]]
68
+ ]
69
+
70
+ games_cl4 = [
71
+ [[ 1, bayern, [2, 1], madrid, Time.cet('2012-04-17 20:45') ],
72
+ [ 2, madrid, [2, 1, 2, 1, 3, 4], bayern, Time.cet('2012-04-25 20:45') ]],
73
+ [[ 2, chelsea, [1, 0], barcelona, Time.cet('2012-04-18 20:45') ],
74
+ [ 1, barcelona , [2, 2], chelsea, Time.cet('2012-04-24 20:45') ]]
75
+ ]
76
+
77
+ games_cl1 = [
78
+ [ 1, bayern, [1,1,1,1,3,4], chelsea, Time.cet('2012-05-19 20:45') ]]
79
+
80
+
81
+ Game.create_knockout_pairs_from_ary!( games_cl16, cl16, cl16_2 )
82
+ Game.create_knockout_pairs_from_ary!( games_cl8, cl8, cl8_2 )
83
+ Game.create_knockout_pairs_from_ary!( games_cl4, cl4, cl4_2 )
84
+ Game.create_knockouts_from_ary!( games_cl1, cl1 )
85
+
86
+ Prop.create!( :key => 'db.cl.2011/12.version', :value => '1' )
@@ -0,0 +1,64 @@
1
+ # encoding: utf-8
2
+
3
+ # note: timezone for games (play_at) is *always* CET (central european time)
4
+
5
+ #################################
6
+ ## Europa League 2012
7
+
8
+ el = Event.create!( :key => 'el',
9
+ :title => 'Europa League 2011/12',
10
+ :start_at => Time.cet( '2011-10-10 17:00' ))
11
+
12
+ az = Team.find_by_key!( 'az' )
13
+ valencia = Team.find_by_key!( 'valencia' )
14
+ schalke = Team.find_by_key!( 'schalke' )
15
+ athletic = Team.find_by_key!( 'athletic' )
16
+ sporting = Team.find_by_key!( 'sporting' )
17
+ metalist = Team.find_by_key!( 'metalist' )
18
+ atletico = Team.find_by_key!( 'atletico' )
19
+ hannover = Team.find_by_key!( 'hannover' )
20
+
21
+ el.teams << az
22
+ el.teams << valencia
23
+ el.teams << schalke
24
+ el.teams << athletic
25
+ el.teams << sporting
26
+ el.teams << metalist
27
+ el.teams << atletico
28
+ el.teams << hannover
29
+
30
+ el8 = Round.create!( :event => el, :pos => 1, :title => 'Viertelfinale', :title2 => '29. März 2012' )
31
+ el8_2 = Round.create!( :event => el, :pos => 2, :title => 'Viertelfinale Rückspiele', :title2 => '5. April 2012' )
32
+ el4 = Round.create!( :event => el, :pos => 3, :title => 'Halbfinale', :title2 => '19. April 2012' )
33
+ el4_2 = Round.create!( :event => el, :pos => 4, :title => 'Halbfinale Rückspiele', :title2 => '26. April 2012' )
34
+ el1 = Round.create!( :event => el, :pos => 5, :title => 'Finale', :title2 => '9. Mai 2012' )
35
+
36
+
37
+ games_el8 = [
38
+ [[ 1, az, [2, 1], valencia, Time.cet('2012-03-29 21:05') ],
39
+ [ 1, valencia, [4, 0], az, Time.cet('2012-04-05 21:05') ]],
40
+ [[ 2, schalke, [2, 4], athletic, Time.cet('2012-03-29 21:05') ],
41
+ [ 2, athletic, [2, 2], schalke, Time.cet('2012-04-05 21:05') ]],
42
+ [[ 3, sporting, [2, 1], metalist, Time.cet('2012-03-29 21:05') ],
43
+ [ 3, metalist, [1, 1], sporting, Time.cet('2012-04-05 21:05') ]],
44
+ [[ 4, atletico, [2, 1], hannover, Time.cet('2012-03-29 21:05') ],
45
+ [ 4, hannover, [1, 2], atletico, Time.cet('2012-04-05 21:05') ]]
46
+ ]
47
+
48
+ games_el4 = [
49
+ [[ 1, atletico, [4, 2], valencia, Time.cet('2012-04-19 21:05') ],
50
+ [ 1, valencia, [0, 1], atletico, Time.cet('2012-04-26 21:05') ]],
51
+ [[ 2, sporting, [2, 1], athletic, Time.cet('2012-04-19 21:05') ],
52
+ [ 2, athletic, [3, 1], sporting, Time.cet('2012-04-26 21:05') ]]
53
+ ]
54
+
55
+ games_el1 = [
56
+ [ 1, atletico, [3, 0], athletic, Time.cet('2012-05-09 20:45') ]]
57
+
58
+
59
+ Game.create_knockout_pairs_from_ary!( games_el8, el8, el8_2 )
60
+ Game.create_knockout_pairs_from_ary!( games_el4, el4, el4_2 )
61
+ Game.create_knockouts_from_ary!( games_el1, el1 )
62
+
63
+
64
+ Prop.create!( :key => 'db.el.2011/12.version', :value => '1' )
@@ -0,0 +1,322 @@
1
+ # encoding: utf-8
2
+
3
+ # note: timezone for games (play_at) is *always* CET (central european time)
4
+
5
+ #################################
6
+ ## Champions League 2012/13
7
+
8
+ cl = Event.create!( :key => 'cl.2012/13',
9
+ :title => 'Champions League 2012/13',
10
+ :start_at => Time.cet( '2012-09-18 18:30' ) )
11
+
12
+ porto = Team.find_by_key!( 'porto' )
13
+ kiew = Team.find_by_key!( 'kiew' )
14
+ paris = Team.find_by_key!( 'paris' )
15
+ zagreb = Team.find_by_key!( 'zagreb' )
16
+
17
+ arsenal = Team.find_by_key!( 'arsenal' )
18
+ schalke = Team.find_by_key!( 'schalke' )
19
+ olympiacos = Team.find_by_key!( 'olympiacos' )
20
+ montpellier = Team.find_by_key!( 'montpellier' )
21
+
22
+ milan = Team.find_by_key!( 'milan' )
23
+ zenit = Team.find_by_key!( 'zenit' )
24
+ anderlecht = Team.find_by_key!( 'anderlecht' )
25
+ malaga = Team.find_by_key!( 'malaga' )
26
+
27
+ madrid = Team.find_by_key!( 'madrid' )
28
+ mancity = Team.find_by_key!( 'mancity' )
29
+ ajax = Team.find_by_key!( 'ajax' )
30
+ dortmund = Team.find_by_key!( 'dortmund' )
31
+
32
+ chelsea = Team.find_by_key!( 'chelsea' )
33
+ donezk = Team.find_by_key!( 'donezk' )
34
+ juventus = Team.find_by_key!( 'juventus' )
35
+ nordsjalland = Team.find_by_key!( 'nordsjalland' )
36
+
37
+ bayern = Team.find_by_key!( 'bayern' )
38
+ valencia = Team.find_by_key!( 'valencia' )
39
+ lille = Team.find_by_key!( 'lille' )
40
+ borissow = Team.find_by_key!( 'borissow' )
41
+
42
+ barcelona = Team.find_by_key!( 'barcelona' )
43
+ benfica = Team.find_by_key!( 'benfica' )
44
+ spartak = Team.find_by_key!( 'spartak' )
45
+ celtic = Team.find_by_key!( 'celtic' )
46
+
47
+ manunited = Team.find_by_key!( 'manunited' )
48
+ braga = Team.find_by_key!( 'braga' )
49
+ galatasaray = Team.find_by_key!( 'galatasaray' )
50
+ cluj = Team.find_by_key!( 'cluj' )
51
+
52
+
53
+
54
+ cl.teams << porto
55
+ cl.teams << kiew
56
+ cl.teams << paris
57
+ cl.teams << zagreb
58
+
59
+ cl.teams << arsenal
60
+ cl.teams << schalke
61
+ cl.teams << olympiacos
62
+ cl.teams << montpellier
63
+
64
+ cl.teams << milan
65
+ cl.teams << zenit
66
+ cl.teams << anderlecht
67
+ cl.teams << malaga
68
+
69
+ cl.teams << madrid
70
+ cl.teams << mancity
71
+ cl.teams << ajax
72
+ cl.teams << dortmund
73
+
74
+ cl.teams << chelsea
75
+ cl.teams << donezk
76
+ cl.teams << juventus
77
+ cl.teams << nordsjalland
78
+
79
+ cl.teams << bayern
80
+ cl.teams << valencia
81
+ cl.teams << lille
82
+ cl.teams << borissow
83
+
84
+ cl.teams << barcelona
85
+ cl.teams << benfica
86
+ cl.teams << spartak
87
+ cl.teams << celtic
88
+
89
+ cl.teams << manunited
90
+ cl.teams << braga
91
+ cl.teams << galatasaray
92
+ cl.teams << cluj
93
+
94
+
95
+ cla = Group.create!( :event => cl, :pos => 1, :title => 'Gruppe A' )
96
+ clb = Group.create!( :event => cl, :pos => 2, :title => 'Gruppe B' )
97
+ clc = Group.create!( :event => cl, :pos => 3, :title => 'Gruppe C' )
98
+ cld = Group.create!( :event => cl, :pos => 4, :title => 'Gruppe D' )
99
+ cle = Group.create!( :event => cl, :pos => 5, :title => 'Gruppe E' )
100
+ clf = Group.create!( :event => cl, :pos => 6, :title => 'Gruppe F' )
101
+ clg = Group.create!( :event => cl, :pos => 7, :title => 'Gruppe G' )
102
+ clh = Group.create!( :event => cl, :pos => 8, :title => 'Gruppe H' )
103
+
104
+ #################################
105
+ # Gruppe A
106
+
107
+ cla.teams << porto
108
+ cla.teams << kiew
109
+ cla.teams << paris
110
+ cla.teams << zagreb
111
+
112
+
113
+ #################################
114
+ # Gruppe B
115
+
116
+ clb.teams << arsenal
117
+ clb.teams << schalke
118
+ clb.teams << olympiacos
119
+ clb.teams << montpellier
120
+
121
+
122
+ #################################
123
+ # Gruppe C
124
+
125
+ clc.teams << milan
126
+ clc.teams << zenit
127
+ clc.teams << anderlecht
128
+ clc.teams << malaga
129
+
130
+ #################################
131
+ # Gruppe D
132
+
133
+ cld.teams << madrid
134
+ cld.teams << mancity
135
+ cld.teams << ajax
136
+ cld.teams << dortmund
137
+
138
+
139
+ #################################
140
+ # Gruppe E
141
+
142
+ cle.teams << chelsea
143
+ cle.teams << donezk
144
+ cle.teams << juventus
145
+ cle.teams << nordsjalland
146
+
147
+
148
+ #################################
149
+ # Gruppe F
150
+
151
+ clf.teams << bayern
152
+ clf.teams << valencia
153
+ clf.teams << lille
154
+ clf.teams << borissow
155
+
156
+
157
+ #################################
158
+ # Gruppe G
159
+
160
+ clg.teams << barcelona
161
+ clg.teams << benfica
162
+ clg.teams << spartak
163
+ clg.teams << celtic
164
+
165
+
166
+ #################################
167
+ # Gruppe H
168
+
169
+ clh.teams << manunited
170
+ clh.teams << braga
171
+ clh.teams << galatasaray
172
+ clh.teams << cluj
173
+
174
+
175
+ clr1 = Round.create!( :event => cl, :pos => 1, :title => 'Spieltag 1', :title2 => 'Di./Mi., 18.+19. Sep 2012' )
176
+ clr2 = Round.create!( :event => cl, :pos => 2, :title => 'Spieltag 2', :title2 => 'Di./Mi., 2.+3. Okt 2012' )
177
+ clr3 = Round.create!( :event => cl, :pos => 3, :title => 'Spieltag 3', :title2 => 'Di./Mi., 23.+24. Okt 2012' )
178
+ clr4 = Round.create!( :event => cl, :pos => 4, :title => 'Spieltag 4', :title2 => 'Di./Mi., 6.+7. Nov 2012' )
179
+ clr5 = Round.create!( :event => cl, :pos => 5, :title => 'Spieltag 5', :title2 => 'Di./Mi., 20.+21. Nov 2012' )
180
+ clr6 = Round.create!( :event => cl, :pos => 6, :title => 'Spieltag 6', :title2 => 'Di./Mi., 4.+5. Dez 2012' )
181
+
182
+ cl16 = Round.create!( :event => cl, :pos => 7, :title => 'Achtelfinale', :title2 => 'Di./Mi., 12.+13./19.+20. Feb 2013' )
183
+ cl16_2 = Round.create!( :event => cl, :pos => 8, :title => 'Achtelfinale Rückspiele', :title2 => 'Di./Mi., 5.+6./12.+13. Mär 2013' )
184
+ cl8 = Round.create!( :event => cl, :pos => 9, :title => 'Viertelfinale', :title2 => 'Di./Mi., 2.+3. Apr 2013' )
185
+ cl8_2 = Round.create!( :event => cl, :pos => 10, :title => 'Viertelfinale Rückspiele', :title2 => 'Di./Mi., 9.+10. Apr 2013' )
186
+ cl4 = Round.create!( :event => cl, :pos => 11, :title => 'Halbfinale', :title2 => 'Di./Mi., 23.+24. Apr 2013' )
187
+ cl4_2 = Round.create!( :event => cl, :pos => 12, :title => 'Halbfinale Rückspiele', :title2 => 'Di./Mi., 30. Apr/1. Mai 2013' )
188
+ cl1 = Round.create!( :event => cl, :pos => 13, :title => 'Finale', :title2 => 'Sa. 25. Mai 2013' )
189
+
190
+
191
+ games_cla = [
192
+ [[ 1, zagreb, [0,2], porto, Time.cet('2012-09-18 20:45'), clr1 ],
193
+ [ 2, porto, [], zagreb, Time.cet('2012-11-21 20:45'), clr5 ]],
194
+ [[ 2, paris, [4,1], kiew, Time.cet('2012-09-18 20:45'), clr1 ],
195
+ [ 1, kiew, [], paris, Time.cet('2012-11-21 20:45'), clr5 ]],
196
+ [[ 1, kiew, [2,0], zagreb, Time.cet('2012-10-03 20:45'), clr2 ],
197
+ [ 2, zagreb, [], kiew, Time.cet('2012-12-04 20:45'), clr6 ]],
198
+ [[ 2, porto, [1,0], paris, Time.cet('2012-10-03 20:45'), clr2 ],
199
+ [ 1, paris, [], porto, Time.cet('2012-12-04 20:45'), clr6 ]],
200
+ [[ 1, porto, [], kiew, Time.cet('2012-10-24 20:45'), clr3 ],
201
+ [ 1, kiew, [], porto, Time.cet('2012-11-06 20:45'), clr4 ]],
202
+ [[ 2, zagreb, [], paris, Time.cet('2012-10-24 20:45'), clr3 ],
203
+ [ 2, paris, [], zagreb, Time.cet('2012-11-06 20:45'), clr4 ]]
204
+ ]
205
+
206
+ games_clb = [
207
+ [[ 3, montpellier, [1,2], arsenal, Time.cet('2012-09-18 20:45'), clr1 ],
208
+ [ 4, arsenal, [], montpellier, Time.cet('2012-11-21 20:45'), clr5 ]],
209
+ [[ 4, olympiacos, [1,2], schalke, Time.cet('2012-09-18 20:45'), clr1 ],
210
+ [ 3, schalke, [], olympiacos, Time.cet('2012-11-21 20:45'), clr5 ]],
211
+ [[ 3, arsenal, [3,1], olympiacos, Time.cet('2012-10-03 20:45'), clr2 ],
212
+ [ 3, olympiacos, [], arsenal, Time.cet('2012-12-04 20:45'), clr6 ]],
213
+ [[ 4, schalke, [2,2], montpellier, Time.cet('2012-10-03 20:45'), clr2 ],
214
+ [ 4, montpellier, [], schalke, Time.cet('2012-12-04 20:45'), clr6 ]],
215
+ [[ 3, arsenal, [], schalke, Time.cet('2012-10-24 20:45'), clr3 ],
216
+ [ 3, schalke, [], arsenal, Time.cet('2012-11-06 20:45'), clr4 ]],
217
+ [[ 4, montpellier, [], olympiacos, Time.cet('2012-10-24 20:45'), clr3 ],
218
+ [ 4, olympiacos, [], montpellier, Time.cet('2012-11-06 20:45'), clr4 ]]
219
+ ]
220
+
221
+ games_clc = [
222
+ [[ 5, malaga, [3,0], zenit, Time.cet('2012-09-18 20:45'), clr1 ],
223
+ [ 5, zenit, [], malaga, Time.cet('2012-11-21 18:00'), clr5 ]],
224
+ [[ 6, milan, [0,0], anderlecht, Time.cet('2012-09-18 20:45'), clr1 ],
225
+ [ 6, anderlecht, [], milan, Time.cet('2012-11-21 20:45'), clr5 ]],
226
+ [[ 5, zenit, [2,3], milan, Time.cet('2012-10-03 18:00'), clr2 ],
227
+ [ 5, milan, [], zenit, Time.cet('2012-12-04 20:45'), clr6 ]],
228
+ [[ 6, anderlecht, [0,3], malaga, Time.cet('2012-10-03 20:45'), clr2 ],
229
+ [ 6, malaga, [], anderlecht, Time.cet('2012-12-04 20:45'), clr6 ]],
230
+ [[ 5, zenit, [], anderlecht, Time.cet('2012-10-24 18:00'), clr3 ],
231
+ [ 5, anderlecht, [], zenit, Time.cet('2012-11-06 20:45'), clr4 ]],
232
+ [[ 6, malaga, [], milan, Time.cet('2012-10-24 20:45'), clr3 ],
233
+ [ 6, milan, [], malaga, Time.cet('2012-11-06 20:45'), clr4 ]]
234
+ ]
235
+
236
+ games_cld = [
237
+ [[ 7, madrid, [3,2], mancity, Time.cet('2012-09-18 20:45'), clr1 ],
238
+ [ 7, mancity, [], madrid, Time.cet('2012-11-21 20:45'), clr5 ]],
239
+ [[ 8, dortmund, [1,0], ajax, Time.cet('2012-09-18 20:45'), clr1 ],
240
+ [ 8, ajax, [], dortmund, Time.cet('2012-11-21 20:45'), clr5 ]],
241
+ [[ 7, ajax, [1,4], madrid, Time.cet('2012-10-03 20:45'), clr2 ],
242
+ [ 8, madrid, [], ajax, Time.cet('2012-12-04 20:45'), clr6 ]],
243
+ [[ 8, mancity, [1,1], dortmund, Time.cet('2012-10-03 20:45'), clr2 ],
244
+ [ 7, dortmund, [], mancity, Time.cet('2012-12-04 20:45'), clr6 ]],
245
+ [[ 7, dortmund, [], madrid, Time.cet('2012-10-24 20:45'), clr3 ],
246
+ [ 8, madrid, [], dortmund, Time.cet('2012-11-06 20:45'), clr4 ]],
247
+ [[ 8, ajax, [], mancity, Time.cet('2012-10-24 20:45'), clr3 ],
248
+ [ 7, mancity, [], ajax, Time.cet('2012-11-06 20:45'), clr4 ]]
249
+ ]
250
+
251
+
252
+ games_cle = [
253
+ [[ 9, chelsea, [2,2], juventus, Time.cet('2012-09-19 20:45'), clr1 ],
254
+ [ 9, juventus, [], chelsea, Time.cet('2012-11-20 20:45'), clr5 ]],
255
+ [[ 10, donezk, [2,0], nordsjalland, Time.cet('2012-09-19 20:45'), clr1 ],
256
+ [ 10, nordsjalland, [], donezk, Time.cet('2012-11-20 20:45'), clr5 ]],
257
+ [[ 9, nordsjalland, [0,4], chelsea, Time.cet('2012-10-02 20:45'), clr2 ],
258
+ [ 9, chelsea, [], nordsjalland, Time.cet('2012-12-05 20:45'), clr6 ]],
259
+ [[ 10, juventus, [1,1], donezk, Time.cet('2012-10-02 20:45'), clr2 ],
260
+ [ 10, donezk, [], juventus, Time.cet('2012-12-05 20:45'), clr6 ]],
261
+ [[ 9, donezk, [], chelsea, Time.cet('2012-10-23 20:45'), clr3 ],
262
+ [ 9, chelsea, [], donezk, Time.cet('2012-11-07 20:45'), clr4 ]],
263
+ [[ 10, nordsjalland, [], juventus, Time.cet('2012-10-23 20:45'), clr3 ],
264
+ [ 10, juventus, [], nordsjalland, Time.cet('2012-11-07 20:45'), clr4 ]]
265
+ ]
266
+
267
+ games_clf = [
268
+ [[ 11, bayern, [2,1], valencia, Time.cet('2012-09-19 20:45'), clr1 ],
269
+ [ 11, valencia, [], bayern, Time.cet('2012-11-20 20:45'), clr5 ]],
270
+ [[ 12, lille, [1,3], borissow, Time.cet('2012-09-19 20:45'), clr1 ],
271
+ [ 12, borissow, [], lille, Time.cet('2012-11-20 20:45'), clr5 ]],
272
+ [[ 11, borissow, [3,1], bayern, Time.cet('2012-10-02 20:45'), clr2 ],
273
+ [ 12, bayern, [], borissow, Time.cet('2012-12-05 20:45'), clr6 ]],
274
+ [[ 12, valencia, [2,0], lille, Time.cet('2012-10-02 20:45'), clr2 ],
275
+ [ 11, lille, [], valencia, Time.cet('2012-12-05 20:45'), clr6 ]],
276
+ [[ 11, lille, [], bayern, Time.cet('2012-10-23 20:45'), clr3 ],
277
+ [ 11, bayern, [], lille, Time.cet('2012-11-07 20:45'), clr4 ]],
278
+ [[ 12, borissow, [], valencia, Time.cet('2012-10-23 20:45'), clr3 ],
279
+ [ 12, valencia, [], borissow, Time.cet('2012-11-07 20:45'), clr4 ]]
280
+ ]
281
+
282
+ games_clg = [
283
+ [[ 13, celtic, [0,0], benfica, Time.cet('2012-09-19 20:45'), clr1 ],
284
+ [ 14, benfica, [], celtic, Time.cet('2012-11-20 20:45'), clr5 ]],
285
+ [[ 14, barcelona, [3,2], spartak, Time.cet('2012-09-19 20:45'), clr1 ],
286
+ [ 13, spartak, [], barcelona, Time.cet('2012-11-20 18:00'), clr5 ]],
287
+ [[ 13, spartak, [2,3], celtic, Time.cet('2012-10-02 18:00'), clr2 ],
288
+ [ 14, celtic, [], spartak, Time.cet('2012-12-05 20:45'), clr6 ]],
289
+ [[ 14, benfica, [0,2], barcelona, Time.cet('2012-10-02 20:45'), clr2 ],
290
+ [ 13, barcelona, [], benfica, Time.cet('2012-12-05 20:45'), clr6 ]],
291
+ [[ 13, spartak, [], benfica, Time.cet('2012-10-23 18:00'), clr3 ],
292
+ [ 14, benfica, [], spartak, Time.cet('2012-11-07 20:45'), clr4 ]],
293
+ [[ 14, barcelona, [], celtic, Time.cet('2012-10-23 20:45'), clr3 ],
294
+ [ 13, celtic, [], barcelona, Time.cet('2012-11-07 20:45'), clr4 ]]
295
+ ]
296
+
297
+ games_clh = [
298
+ [[ 15, manunited, [1,0], galatasaray, Time.cet('2012-09-19 20:45'), clr1 ],
299
+ [ 15, galatasaray, [], manunited, Time.cet('2012-11-20 20:45'), clr5 ]],
300
+ [[ 16, braga, [0,2], cluj, Time.cet('2012-09-19 20:45'), clr1 ],
301
+ [ 16, cluj, [], braga, Time.cet('2012-11-20 20:45'), clr5 ]],
302
+ [[ 15, cluj, [1,2], manunited, Time.cet('2012-10-02 20:45'), clr2 ],
303
+ [ 16, manunited, [], cluj, Time.cet('2012-12-05 20:45'), clr6 ]],
304
+ [[ 16, galatasaray, [0,2], braga, Time.cet('2012-10-02 20:45'), clr2 ],
305
+ [ 15, braga, [], galatasaray, Time.cet('2012-12-05 20:45'), clr6 ]],
306
+ [[ 15, manunited, [], braga, Time.cet('2012-10-23 20:45'), clr3 ],
307
+ [ 15, braga, [], manunited, Time.cet('2012-11-07 20:45'), clr4 ]],
308
+ [[ 16, galatasaray, [], cluj, Time.cet('2012-10-23 20:45'), clr3 ],
309
+ [ 16, cluj, [], galatasaray, Time.cet('2012-11-07 20:45'), clr4 ]]
310
+ ]
311
+
312
+ Game.create_pairs_from_ary_for_group!( games_cla, cla )
313
+ Game.create_pairs_from_ary_for_group!( games_clb, clb )
314
+ Game.create_pairs_from_ary_for_group!( games_clc, clc )
315
+ Game.create_pairs_from_ary_for_group!( games_cld, cld )
316
+ Game.create_pairs_from_ary_for_group!( games_cle, cle )
317
+ Game.create_pairs_from_ary_for_group!( games_clf, clf )
318
+ Game.create_pairs_from_ary_for_group!( games_clg, clg )
319
+ Game.create_pairs_from_ary_for_group!( games_clh, clh )
320
+
321
+
322
+ Prop.create!( :key => 'db.cl.2012/13.version', :value => '1' )
data/db/cl/teams.rb ADDED
@@ -0,0 +1,66 @@
1
+ # encoding: utf-8
2
+
3
+ teams = [
4
+ [ 'porto', 'FC Porto' ],
5
+ [ 'kiew', 'Dynamo Kiew' ],
6
+ [ 'paris', 'Paris St. Germain' ],
7
+ [ 'zagreb', 'Dinamo Zagreb' ],
8
+
9
+ [ 'arsenal', 'FC Arsenal' ],
10
+ [ 'schalke', 'FC Schalke 04' ],
11
+ [ 'olympiacos', 'Olympiakos Piräus' ],
12
+ [ 'montpellier', 'HSC Montpellier' ],
13
+
14
+ [ 'milan', 'AC Mailand' ],
15
+ [ 'zenit', 'Zenit St. Petersburg' ],
16
+ [ 'anderlecht', 'RSC Anderlecht' ],
17
+ [ 'malaga', 'FC Málaga' ],
18
+
19
+ [ 'madrid', 'Real Madrid' ],
20
+ [ 'mancity', 'Manchester City' ],
21
+ [ 'ajax', 'Ajax Amsterdam' ],
22
+ [ 'dortmund', 'Borussia Dortmund' ],
23
+
24
+ [ 'chelsea', 'FC Chelsea' ],
25
+ [ 'donezk', 'Schachtjor Donezk' ],
26
+ [ 'juventus', 'Juventus Turin' ],
27
+ [ 'nordsjalland', 'FC Nordsjælland' ],
28
+
29
+ [ 'bayern', 'Bayern München' ],
30
+ [ 'valencia', 'FC Valencia' ],
31
+ [ 'lille', 'OSC Lille' ],
32
+ [ 'borissow', 'BATE Borissow' ],
33
+
34
+ [ 'barcelona', 'FC Barcelona' ],
35
+ [ 'benfica', 'Benfica Lissabon' ],
36
+ [ 'spartak', 'Spartak Moskau' ],
37
+ [ 'celtic', 'Celtic Glasgow' ],
38
+
39
+ [ 'manunited', 'Manchester United' ],
40
+ [ 'braga', 'Sporting Braga' ],
41
+ [ 'galatasaray', 'Galatasaray' ],
42
+ [ 'cluj', 'CFR Cluj' ],
43
+
44
+ ###################
45
+ # more teams from cl/el 2011-12
46
+ #
47
+ [ 'inter', 'FC Internazionale Milano' ],
48
+ [ 'marseille', 'Olympique Marseille' ],
49
+ [ 'basel', 'FC Basel 1893' ],
50
+ [ 'napoli', 'SSC Napoli' ],
51
+ [ 'moskva', 'PFC CSKA Moskva' ],
52
+ [ 'apoel', 'APOEL Nikosia' ],
53
+
54
+ [ 'az', 'AZ Alkmaar' ],
55
+ [ 'athletic', 'Athletic Bilbao' ],
56
+ [ 'sporting', 'Sporting Lisboa' ],
57
+ [ 'metalist', 'FC Metalist Kharkiv' ],
58
+ [ 'atletico', 'Atlético Madrid' ],
59
+ [ 'hannover', 'Hannover 96' ]
60
+ ]
61
+
62
+ Team.create_from_ary!( teams )
63
+
64
+
65
+ Prop.create!( :key => 'db.cl.teams.version', :value => '1' )
66
+ Prop.create!( :key => 'db.el.teams.version', :value => '1' )
data/db/euro/2012.rb ADDED
@@ -0,0 +1,165 @@
1
+ # encoding: utf-8
2
+
3
+ # note: timezone for games (play_at) is *always* CET (central european time)
4
+
5
+ #################################
6
+ ## Euro 2012
7
+
8
+ # see http://en.wikipedia.org/wiki/UEFA_Euro_2012
9
+ # or http://de.wikipedia.org/wiki/Fu%C3%9Fball-Europameisterschaft_2012
10
+
11
+
12
+ euro = Event.create!( :key => 'euro',
13
+ :title => 'Euro 2012',
14
+ :start_at => Time.cet( '2012-06-07 17:00' ))
15
+
16
+ pol = Team.find_by_key!( 'pol' )
17
+ gre = Team.find_by_key!( 'gre' )
18
+ rus = Team.find_by_key!( 'rus' )
19
+ cze = Team.find_by_key!( 'cze' )
20
+
21
+ ned = Team.find_by_key!( 'ned' )
22
+ den = Team.find_by_key!( 'den' )
23
+ ger = Team.find_by_key!( 'ger' )
24
+ por = Team.find_by_key!( 'por' )
25
+
26
+ esp = Team.find_by_key!( 'esp' )
27
+ ita = Team.find_by_key!( 'ita' )
28
+ irl = Team.find_by_key!( 'irl' )
29
+ cro = Team.find_by_key!( 'cro' )
30
+
31
+ ukr = Team.find_by_key!( 'ukr' )
32
+ swe = Team.find_by_key!( 'swe' )
33
+ fra = Team.find_by_key!( 'fra' )
34
+ eng = Team.find_by_key!( 'eng' )
35
+
36
+
37
+ euro.teams << pol
38
+ euro.teams << gre
39
+ euro.teams << rus
40
+ euro.teams << cze
41
+ euro.teams << ned
42
+ euro.teams << den
43
+ euro.teams << ger
44
+ euro.teams << por
45
+ euro.teams << esp
46
+ euro.teams << ita
47
+ euro.teams << irl
48
+ euro.teams << cro
49
+ euro.teams << ukr
50
+ euro.teams << swe
51
+ euro.teams << fra
52
+ euro.teams << eng
53
+
54
+
55
+
56
+ euroa = Group.create!( :event => euro, :pos => 1, :title => 'Gruppe A' )
57
+ eurob = Group.create!( :event => euro, :pos => 2, :title => 'Gruppe B' )
58
+ euroc = Group.create!( :event => euro, :pos => 3, :title => 'Gruppe C' )
59
+ eurod = Group.create!( :event => euro, :pos => 4, :title => 'Gruppe D' )
60
+
61
+ #################################
62
+ # Gruppe A
63
+
64
+ euroa.teams << pol
65
+ euroa.teams << gre
66
+ euroa.teams << rus
67
+ euroa.teams << cze
68
+
69
+
70
+ #################################
71
+ # Gruppe B
72
+
73
+ eurob.teams << ned
74
+ eurob.teams << den
75
+ eurob.teams << ger
76
+ eurob.teams << por
77
+
78
+
79
+ #################################3
80
+ # Gruppe C
81
+
82
+ euroc.teams << esp
83
+ euroc.teams << ita
84
+ euroc.teams << irl
85
+ euroc.teams << cro
86
+
87
+ #################################3
88
+ # Gruppe D
89
+
90
+ eurod.teams << ukr
91
+ eurod.teams << swe
92
+ eurod.teams << fra
93
+ eurod.teams << eng
94
+
95
+
96
+ euro_round1 = Round.create!( :event => euro, :pos => 1, :title => 'Vorrunde 1. Spieltag', :title2 => '8.-11. Juni' )
97
+ euro_round2 = Round.create!( :event => euro, :pos => 2, :title => 'Vorrunde 2. Spieltag', :title2 => '12.-15. Juni' )
98
+ euro_round3 = Round.create!( :event => euro, :pos => 3, :title => 'Vorrunde 3. Spieltag', :title2 => '16.-19. Juni' )
99
+
100
+
101
+
102
+ games_euro_round1 = [
103
+ [ 1, pol, [1,1], gre, Time.cet('2012-06-08 18:00'), euroa ],
104
+ [ 2, rus, [4,1], cze, Time.cet('2012-06-08 20:45'), euroa ],
105
+ [ 3, ned, [0,1], den, Time.cet('2012-06-09 18:00'), eurob ],
106
+ [ 4, ger, [1,0], por, Time.cet('2012-06-09 20:45'), eurob ],
107
+ [ 5, esp, [1,1], ita, Time.cet('2012-06-10 18:00'), euroc ],
108
+ [ 6, irl, [1,3], cro, Time.cet('2012-06-10 20:45'), euroc ],
109
+ [ 7, fra, [1,1], eng, Time.cet('2012-06-11 18:00'), eurod ],
110
+ [ 8, ukr, [2,1], swe, Time.cet('2012-06-11 20:45'), eurod ]
111
+ ]
112
+
113
+ games_euro_round2 = [
114
+ [ 9, gre, [1,2], cze, Time.cet('2012-06-12 18:00'), euroa ],
115
+ [ 10, pol, [1,1], rus, Time.cet('2012-06-12 20:45'), euroa ],
116
+ [ 11, den, [2,3], por, Time.cet('2012-06-13 18:00'), eurob ],
117
+ [ 12, ned, [1,2], ger, Time.cet('2012-06-13 20:45'), eurob ],
118
+ [ 13, ita, [1,1], cro, Time.cet('2012-06-14 18:00'), euroc ],
119
+ [ 14, esp, [4,0], irl, Time.cet('2012-06-14 20:45'), euroc ],
120
+ [ 15, swe, [2,3], eng, Time.cet('2012-06-15 20:45'), eurod ],
121
+ [ 16, ukr, [0,2], fra, Time.cet('2012-06-15 18:00'), eurod ]
122
+ ]
123
+
124
+ games_euro_round3 = [
125
+ [ 17, cze, [1,0], pol, Time.cet('2012-06-16 20:45'), euroa ],
126
+ [ 18, gre, [1,0], rus, Time.cet('2012-06-16 20:45'), euroa ],
127
+ [ 19, por, [2,1], ned, Time.cet('2012-06-17 20:45'), eurob ],
128
+ [ 20, den, [1,2], ger, Time.cet('2012-06-17 20:45'), eurob ],
129
+ [ 21, cro, [0,1], esp, Time.cet('2012-06-18 20:45'), euroc ],
130
+ [ 22, ita, [2,0], irl, Time.cet('2012-06-18 20:45'), euroc ],
131
+ [ 23, eng, [1,0], ukr, Time.cet('2012-06-19 20:45'), eurod ],
132
+ [ 24, swe, [2,0], fra, Time.cet('2012-06-19 20:45'), eurod ]
133
+ ]
134
+
135
+ Game.create_from_ary!( games_euro_round1, euro_round1 )
136
+ Game.create_from_ary!( games_euro_round2, euro_round2 )
137
+ Game.create_from_ary!( games_euro_round3, euro_round3 )
138
+
139
+
140
+
141
+ euro8 = Round.create!( :event => euro, :pos => 4, :title => 'Viertelfinale' )
142
+ euro4 = Round.create!( :event => euro, :pos => 5, :title => 'Halbfinale' )
143
+ euro1 = Round.create!( :event => euro, :pos => 6, :title => 'Finale' )
144
+
145
+
146
+ games_euro8 = [
147
+ [ 25, cze, [0,1], por, Time.cet('2012-06-21 20:45') ],
148
+ [ 26, ger, [4,2], gre, Time.cet('2012-06-22 20:45') ],
149
+ [ 27, esp, [2,0], fra, Time.cet('2012-06-23 20:45') ],
150
+ [ 28, eng, [0,0,0,0,2,4], ita, Time.cet('2012-06-24 20:45') ]]
151
+
152
+ games_euro4 = [
153
+ [ 29, por, [0,0,0,0,2,4], esp, Time.cet('2012-06-27 20:45') ],
154
+ [ 30, ger, [1,2], ita, Time.cet('2012-06-28 20:45') ]]
155
+
156
+ games_euro1 = [
157
+ [ 31, esp, [4,0], ita, Time.cet('2012-07-01 20:45') ]]
158
+
159
+
160
+ Game.create_knockouts_from_ary!( games_euro8, euro8 )
161
+ Game.create_knockouts_from_ary!( games_euro4, euro4 )
162
+ Game.create_knockouts_from_ary!( games_euro1, euro1 )
163
+
164
+
165
+ Prop.create!( :key => 'db.euro.2012.version', :value => '1' )
data/db/euro/teams.rb ADDED
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+
3
+ teams = [
4
+ [ 'pol', 'Polen', 'POL' ],
5
+ [ 'gre', 'Griechenland', 'GRE' ],
6
+ [ 'rus', 'Russland', 'RUS' ],
7
+ [ 'cze', 'Tschechien', 'CZE' ],
8
+ [ 'ned', 'Niederlande', 'NED' ],
9
+ [ 'den', 'Dänemark', 'DEN' ],
10
+ [ 'ger', 'Deutschland', 'GER' ],
11
+ [ 'por', 'Portugal', 'POR' ],
12
+ [ 'esp', 'Spanien', 'ESP' ],
13
+ [ 'ita', 'Italien', 'ITA' ],
14
+ [ 'irl', 'Irland', 'IRL' ],
15
+ [ 'cro', 'Kroatien', 'CRO' ],
16
+ [ 'ukr', 'Ukraine', 'UKR' ],
17
+ [ 'swe', 'Schweden', 'SWE' ],
18
+ [ 'fra', 'Frankreich', 'FRA' ],
19
+ [ 'eng', 'England', 'ENG' ],
20
+ [ 'fro', 'Färöer', 'FRO' ],
21
+ [ 'kaz', 'Kasachstan', 'KAZ' ],
22
+ [ 'aut', 'Österreich', 'AUT' ]
23
+ ]
24
+
25
+
26
+
27
+ Team.create_from_ary!( teams )
28
+
29
+
30
+ Prop.create!( :key => 'db.euro.teams.version', :value => '1' )
@@ -0,0 +1,102 @@
1
+ # encoding: utf-8
2
+
3
+ # note: timezone for games (play_at) is *always* CET (central european time)
4
+
5
+ #################################
6
+ ## WM 2014 - Qualification Europe
7
+
8
+
9
+ world = Event.create!( :key => 'wmql',
10
+ :title => 'World Cup Quali. Europe 2012/13',
11
+ :start_at => Time.cet( '2012-09-07 00:00' ))
12
+
13
+ worldc = Group.create!( :event => world, :pos => 1, :title => 'Gruppe C' )
14
+
15
+
16
+ #################################3
17
+ # Gruppe C
18
+
19
+ # note: for teams see seeds/euro/teams.rb
20
+
21
+ ger = Team.find_by_key!( 'ger' )
22
+ fro = Team.find_by_key!( 'fro' )
23
+ irl = Team.find_by_key!( 'irl' )
24
+ kaz = Team.find_by_key!( 'kaz' )
25
+ aut = Team.find_by_key!( 'aut' )
26
+ swe = Team.find_by_key!( 'swe' )
27
+
28
+ worldc.teams << ger
29
+ worldc.teams << fro
30
+ worldc.teams << irl
31
+ worldc.teams << kaz
32
+ worldc.teams << aut
33
+ worldc.teams << swe
34
+
35
+
36
+ world.teams << ger
37
+ world.teams << fro
38
+ world.teams << irl
39
+ world.teams << kaz
40
+ world.teams << aut
41
+ world.teams << swe
42
+
43
+
44
+ world1 = Round.create!( :event => world, :pos => 1, :title => 'Quali - 7.+11. Sep 2012' )
45
+ world2 = Round.create!( :event => world, :pos => 2, :title => 'Quali - 12.+16. Okt 2012' )
46
+ world3 = Round.create!( :event => world, :pos => 3, :title => 'Quali - 22.+26. Mär 2013' )
47
+ world4 = Round.create!( :event => world, :pos => 4, :title => 'Quali - 7.+11. Jun 2013' )
48
+ world5 = Round.create!( :event => world, :pos => 5, :title => 'Quali - 6.+10. Sep 2013' )
49
+ world6 = Round.create!( :event => world, :pos => 6, :title => 'Quali - 11.+15. Okt 2013' )
50
+
51
+ games_world1 = [
52
+ [ 1, ger, [3,0], fro, Time.cet( '2012-09-07 00:00' ) ],
53
+ [ 2, kaz, [1,2], irl, Time.cet( '2012-09-07 00:00' ) ],
54
+ [ 3, aut, [1,2], ger, Time.cet( '2012-09-11 00:00' ) ],
55
+ [ 4, swe, [2,0], kaz, Time.cet( '2012-09-11 00:00' ) ]]
56
+
57
+ games_world2 = [
58
+ [ 5, irl, [], ger, Time.cet( '2012-10-12 00:00' ) ],
59
+ [ 6, fro, [], swe, Time.cet( '2012-10-12 00:00' ) ],
60
+ [ 7, kaz, [], aut, Time.cet( '2012-10-12 00:00' ) ],
61
+ [ 8, ger, [], swe, Time.cet( '2012-10-16 00:00' ) ],
62
+ [ 9, fro, [], irl, Time.cet( '2012-10-16 00:00' ) ],
63
+ [ 10, aut, [], kaz, Time.cet( '2012-10-16 00:00' ) ]]
64
+
65
+ games_world3 = [
66
+ [ 11, kaz, [], ger, Time.cet( '2013-03-22 00:00' ) ],
67
+ [ 12, aut, [], fro, Time.cet( '2013-03-22 00:00' ) ],
68
+ [ 13, swe, [], irl, Time.cet( '2013-03-22 00:00' ) ],
69
+ [ 14, ger, [], kaz, Time.cet( '2013-03-26 00:00' ) ],
70
+ [ 15, irl, [], aut, Time.cet( '2013-03-26 00:00' ) ]]
71
+
72
+ games_world4 = [
73
+ [ 16, irl, [], fro, Time.cet( '2013-06-07 00:00' ) ],
74
+ [ 17, aut, [], swe, Time.cet( '2013-06-07 00:00' ) ],
75
+ [ 18, swe, [], fro, Time.cet( '2013-06-11 00:00' ) ]]
76
+
77
+ games_world5 = [
78
+ [ 19, ger, [], aut, Time.cet( '2013-09-06 00:00' ) ],
79
+ [ 20, kaz, [], fro, Time.cet( '2013-09-06 00:00' ) ],
80
+ [ 21, irl, [], swe, Time.cet( '2013-09-06 00:00' ) ],
81
+ [ 22, fro, [], ger, Time.cet( '2013-09-10 00:00' ) ],
82
+ [ 23, aut, [], irl, Time.cet( '2013-09-10 00:00' ) ],
83
+ [ 24, kaz, [], swe, Time.cet( '2013-09-10 00:00' ) ]]
84
+
85
+ games_world6 = [
86
+ [ 25, ger, [], irl, Time.cet( '2013-10-11 00:00' ) ],
87
+ [ 26, fro, [], kaz, Time.cet( '2013-10-11 00:00' ) ],
88
+ [ 27, swe, [], aut, Time.cet( '2013-10-11 00:00' ) ],
89
+ [ 28, swe, [], ger, Time.cet( '2013-10-15 00:00' ) ],
90
+ [ 29, fro, [], aut, Time.cet( '2013-10-15 00:00' ) ],
91
+ [ 30, irl, [], kaz, Time.cet( '2013-10-15 00:00' ) ]]
92
+
93
+
94
+ Game.create_from_ary!( games_world1, world1 )
95
+ Game.create_from_ary!( games_world2, world2 )
96
+ Game.create_from_ary!( games_world3, world3 )
97
+ Game.create_from_ary!( games_world4, world4 )
98
+ Game.create_from_ary!( games_world5, world5 )
99
+ Game.create_from_ary!( games_world6, world6 )
100
+
101
+
102
+ Prop.create!( :key => 'db.world.quali.2012/13.version', :value => '1' )
data/lib/sportdb.rb CHANGED
@@ -22,6 +22,7 @@ require 'active_record' ## todo: add sqlite3? etc.
22
22
  require 'sportdb/schema'
23
23
  require 'sportdb/models'
24
24
  require 'sportdb/utils'
25
+ require 'sportdb/loader'
25
26
  require 'sportdb/version'
26
27
  require 'sportdb/cli/opts'
27
28
  require 'sportdb/cli/runner'
@@ -39,6 +40,14 @@ module SportDB
39
40
  def self.main
40
41
  Runner.new.run(ARGV)
41
42
  end
43
+
44
+
45
+ # load built-in (that is, bundled within the gem) named seeds
46
+ # - pass in an array of seed names e.g. [ 'cl/teams', 'cl/2012_13/cl' ] etc.
47
+
48
+ def self.load( args )
49
+ Loader.new.run( args )
50
+ end
42
51
 
43
52
  end # module SportDB
44
53
 
@@ -12,6 +12,17 @@ class Opts
12
12
  end
13
13
 
14
14
 
15
+ # use loader? (that is, built-in seed data)
16
+ def load=(boolean)
17
+ @load = boolean
18
+ end
19
+
20
+ def load?
21
+ return false if @load.nil? # default create flag is false
22
+ @load == true
23
+ end
24
+
25
+
15
26
  def output_path=(value)
16
27
  @output_path = value
17
28
  end
@@ -12,6 +12,7 @@ class Runner
12
12
 
13
13
  attr_reader :logger, :opts
14
14
 
15
+
15
16
  def run( args )
16
17
  opt=OptionParser.new do |cmd|
17
18
 
@@ -20,6 +21,8 @@ class Runner
20
21
  ## todo: change to different flag?? use -c/--config ???
21
22
  cmd.on( '-c', '--create', 'Create DB Schema' ) { opts.create = true }
22
23
 
24
+ cmd.on( '--load', 'Use Loader for Builtin Sports Data' ) { opts.load = true }
25
+
23
26
  cmd.on( '-o', '--output PATH', "Output Path (default is #{opts.output_path})" ) { |path| opts.output_path = path }
24
27
 
25
28
  ### todo: in future allow multiple search path??
@@ -80,8 +83,30 @@ EOS
80
83
  CreateDB.up
81
84
  end
82
85
 
86
+ loader = nil
87
+ if opts.load?
88
+ loader = Loader.new
89
+ end
90
+
83
91
  args.each do |arg|
84
92
  name = arg # File.basename( arg, '.*' )
93
+
94
+ if opts.load?
95
+ loader.load_fixtures( name ) # load from gem (built-in)
96
+ else
97
+ load_fixtures( name ) # load from file system
98
+ end
99
+ end
100
+
101
+ dump_stats
102
+ dump_props
103
+
104
+ puts 'Done.'
105
+
106
+ end # method run
107
+
108
+
109
+ def load_fixtures( name )
85
110
  path = "#{opts.data_path}/#{name}.rb"
86
111
 
87
112
  puts "*** loading data '#{name}' (#{path})..."
@@ -100,16 +125,11 @@ EOS
100
125
  # require "#{Dir.pwd}/db/#{seed}.rb"
101
126
 
102
127
  # Prop.create!( :key => "db.#{name}.version", :value => SportDB::VERSION )
103
-
104
- end
105
-
106
- dump_stats
107
- dump_props
108
-
109
- puts 'Done.'
110
-
111
- end # method run
128
+ end
129
+
130
+
112
131
 
132
+ ##### fix/todo: reuse between runner/loader - include w/ helper module?
113
133
  def dump_stats
114
134
  # todo: use %5d or similar to format string
115
135
  puts "Stats:"
@@ -0,0 +1,73 @@
1
+
2
+ module SportDB
3
+
4
+ class Loader
5
+
6
+ def initialize
7
+ @logger = Logger.new(STDOUT)
8
+ @logger.level = Logger::INFO
9
+
10
+ end
11
+
12
+ attr_reader :logger
13
+
14
+
15
+ def run( args )
16
+
17
+ puts SportDB.banner
18
+
19
+ puts "working directory: #{Dir.pwd}"
20
+
21
+ ## assume active activerecord connection
22
+ ##
23
+
24
+ args.each do |arg|
25
+ name = arg # File.basename( arg, '.*' )
26
+ load_fixtures( name )
27
+ end
28
+
29
+ dump_stats
30
+ dump_props
31
+
32
+ puts 'Done.'
33
+
34
+ end # method run
35
+
36
+
37
+
38
+ def load_fixtures( name )
39
+
40
+ path = "#{SportDB.root}/db/#{name}.rb"
41
+
42
+ puts "*** loading data '#{name}' (#{path})..."
43
+
44
+ text = File.read( path )
45
+
46
+ SportDB.module_eval( text )
47
+
48
+ # NB: same as
49
+ #
50
+ # module SportDB
51
+ # <code here>
52
+ # end
53
+ end
54
+
55
+ ##### fix/todo: reuse between runner/loader - include w/ helper module?
56
+ def dump_stats
57
+ # todo: use %5d or similar to format string
58
+ puts "Stats:"
59
+ puts " #{Event.count} events"
60
+ puts " #{Team.count} teams"
61
+ puts " #{Game.count} games"
62
+ end
63
+
64
+ def dump_props
65
+ # todo: use %5 or similar to format string
66
+ puts "Props:"
67
+ Prop.order( 'created_at asc' ).all.each do |prop|
68
+ puts " #{prop.key} / #{prop.value} || #{prop.created_at}"
69
+ end
70
+ end
71
+
72
+ end # class Loader
73
+ end # module SportDB
@@ -1,4 +1,4 @@
1
1
 
2
2
  module SportDB
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gerald Bauer
@@ -61,9 +61,17 @@ files:
61
61
  - README.markdown
62
62
  - Rakefile
63
63
  - bin/sportdb
64
+ - db/cl/2011_12/cl.rb
65
+ - db/cl/2011_12/el.rb
66
+ - db/cl/2012_13/cl.rb
67
+ - db/cl/teams.rb
68
+ - db/euro/2012.rb
69
+ - db/euro/teams.rb
70
+ - db/world/quali_2012_13.rb
64
71
  - lib/sportdb.rb
65
72
  - lib/sportdb/cli/opts.rb
66
73
  - lib/sportdb/cli/runner.rb
74
+ - lib/sportdb/loader.rb
67
75
  - lib/sportdb/models.rb
68
76
  - lib/sportdb/schema.rb
69
77
  - lib/sportdb/utils.rb