sportdb 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +1 -0
- data/db/america/2011.rb +5 -6
- data/db/america/teams.rb +3 -1
- data/db/at/2011_12/bl.rb +5 -7
- data/db/at/2011_12/cup.rb +4 -6
- data/db/at/2012_13/bl.rb +6 -6
- data/db/at/2012_13/cup.rb +4 -6
- data/db/at/badges.rb +2 -2
- data/db/at/teams.rb +2 -1
- data/db/cl/2011_12/cl.rb +4 -6
- data/db/cl/2011_12/el.rb +4 -6
- data/db/cl/2012_13/cl.rb +4 -5
- data/db/cl/badges.rb +2 -2
- data/db/cl/teams.rb +2 -2
- data/db/copa/sud_2012_13.rb +5 -6
- data/db/copa/teams.rb +2 -1
- data/db/de/2012_13/bl.rb +5 -7
- data/db/de/teams.rb +2 -2
- data/db/en/2012_13/pl.rb +5 -7
- data/db/en/teams.rb +2 -2
- data/db/es/teams.rb +2 -1
- data/db/euro/2008.rb +5 -10
- data/db/euro/2012.rb +5 -6
- data/db/euro/teams.rb +2 -1
- data/db/leagues.rb +6 -5
- data/db/mx/apertura_2012.rb +6 -6
- data/db/mx/teams.rb +2 -1
- data/db/nfl/teams.rb +2 -1
- data/db/nhl/teams.rb +2 -1
- data/db/ro/l1_2012_13.rb +5 -6
- data/db/ro/teams.rb +2 -1
- data/db/seasons.rb +2 -1
- data/db/world/2010.rb +5 -6
- data/db/world/quali_2012_13_america.rb +5 -7
- data/db/world/quali_2012_13_europe.rb +5 -6
- data/db/world/quali_2012_13_europe_c.rb +3 -3
- data/db/world/quali_2012_13_europe_i.rb +3 -3
- data/db/world/teams.rb +2 -2
- data/lib/sportdb.rb +98 -49
- data/lib/sportdb/keys.rb +29 -0
- data/lib/sportdb/loader.rb +27 -7
- data/lib/sportdb/models/event.rb +108 -4
- data/lib/sportdb/models/forward.rb +3 -2
- data/lib/sportdb/reader.rb +33 -33
- data/lib/sportdb/schema.rb +0 -1
- data/lib/sportdb/version.rb +1 -1
- metadata +6 -5
data/Manifest.txt
CHANGED
data/db/america/2011.rb
CHANGED
@@ -9,11 +9,9 @@
|
|
9
9
|
# more info -> http://en.wikipedia.org/wiki/2011_Copa_América
|
10
10
|
# -> http://de.wikipedia.org/wiki/Copa_América_2011
|
11
11
|
|
12
|
-
copa = Event.create!(
|
13
|
-
|
14
|
-
|
15
|
-
league: League.find_by_key!('america'),
|
16
|
-
season: Season.find_by_key!('2011'))
|
12
|
+
copa = Event.create!( league: League.find_by_key!('america'),
|
13
|
+
season: Season.find_by_key!('2011'),
|
14
|
+
start_at: Time.cet( '2011-07-01 12:00' ) )
|
17
15
|
|
18
16
|
|
19
17
|
##############
|
@@ -47,4 +45,5 @@ copab.add_teams_from_ary!( ['bra', 'par', 'ven', 'ecu' ] )
|
|
47
45
|
copac.add_teams_from_ary!( ['uru', 'chi', 'per', 'mex' ] )
|
48
46
|
|
49
47
|
|
50
|
-
|
48
|
+
## The End
|
49
|
+
#################
|
data/db/america/teams.rb
CHANGED
data/db/at/2011_12/bl.rb
CHANGED
@@ -8,11 +8,9 @@
|
|
8
8
|
##
|
9
9
|
## more info => http://bundesliga.at
|
10
10
|
|
11
|
-
bl = Event.create!(
|
12
|
-
|
13
|
-
start_at: Time.cet('2012-04-07 00:00')
|
14
|
-
league: League.find_by_key!('at'),
|
15
|
-
season: Season.find_by_key!('2011/12'))
|
11
|
+
bl = Event.create!( league: League.find_by_key!('at'),
|
12
|
+
season: Season.find_by_key!('2011/12'),
|
13
|
+
start_at: Time.cet('2012-04-07 00:00'))
|
16
14
|
|
17
15
|
team_keys_bl = [
|
18
16
|
'salzburg',
|
@@ -28,5 +26,5 @@ team_keys_bl = [
|
|
28
26
|
|
29
27
|
bl.add_teams_from_ary!( team_keys_bl )
|
30
28
|
|
31
|
-
|
32
|
-
|
29
|
+
## The End
|
30
|
+
#################
|
data/db/at/2011_12/cup.rb
CHANGED
@@ -6,11 +6,9 @@
|
|
6
6
|
##################################
|
7
7
|
### ÖFB Cup 2011/12
|
8
8
|
|
9
|
-
ofb = Event.create!(
|
10
|
-
title: 'ÖFB Cup 2011/12',
|
11
|
-
start_at: Time.cet( '2011-10-10 17:00' ),
|
12
|
-
league: League.find_by_key!('at.cup'),
|
9
|
+
ofb = Event.create!( league: League.find_by_key!('at.cup'),
|
13
10
|
season: Season.find_by_key!('2011/12'),
|
11
|
+
start_at: Time.cet( '2011-10-10 17:00' ),
|
14
12
|
team3: false ) # no game for 3rd/4th place
|
15
13
|
|
16
14
|
|
@@ -64,5 +62,5 @@ Game.create_knockouts_from_ary!( games_ofb8, ofb8 )
|
|
64
62
|
Game.create_knockouts_from_ary!( games_ofb4, ofb4 )
|
65
63
|
Game.create_knockouts_from_ary!( games_ofb1, ofb1 )
|
66
64
|
|
67
|
-
|
68
|
-
|
65
|
+
## The End
|
66
|
+
#################
|
data/db/at/2012_13/bl.rb
CHANGED
@@ -8,11 +8,9 @@
|
|
8
8
|
## more info => http://bundesliga.at
|
9
9
|
|
10
10
|
|
11
|
-
bl = Event.create!(
|
12
|
-
|
13
|
-
start_at: Time.cet('2012-07-21 00:00')
|
14
|
-
league: League.find_by_key!('at'),
|
15
|
-
season: Season.find_by_key!('2012/13'))
|
11
|
+
bl = Event.create!( league: League.find_by_key!('at'),
|
12
|
+
season: Season.find_by_key!('2012/13'),
|
13
|
+
start_at: Time.cet('2012-07-21 00:00'))
|
16
14
|
|
17
15
|
## 10 Bundeliga Teams
|
18
16
|
|
@@ -30,4 +28,6 @@ team_keys_bl = [
|
|
30
28
|
|
31
29
|
bl.add_teams_from_ary!( team_keys_bl )
|
32
30
|
|
33
|
-
|
31
|
+
|
32
|
+
## The End
|
33
|
+
#################
|
data/db/at/2012_13/cup.rb
CHANGED
@@ -3,11 +3,9 @@
|
|
3
3
|
##################################
|
4
4
|
### ÖFB Cup 2012/13
|
5
5
|
|
6
|
-
cup = Event.create!(
|
7
|
-
title: 'ÖFB Cup 2012/13',
|
8
|
-
start_at: Time.cet( '2012-07-13 00:00' ),
|
9
|
-
league: League.find_by_key!('at.cup'),
|
6
|
+
cup = Event.create!( league: League.find_by_key!('at.cup'),
|
10
7
|
season: Season.find_by_key!('2012/13'),
|
8
|
+
start_at: Time.cet( '2012-07-13 00:00' ),
|
11
9
|
team3: false ) # no game for 3rd/4th place)
|
12
10
|
|
13
11
|
|
@@ -109,5 +107,5 @@ cup.add_teams_from_ary!(
|
|
109
107
|
team_keys_rlo +
|
110
108
|
team_keys_misc )
|
111
109
|
|
112
|
-
|
113
|
-
|
110
|
+
## The End
|
111
|
+
#################
|
data/db/at/badges.rb
CHANGED
data/db/at/teams.rb
CHANGED
data/db/cl/2011_12/cl.rb
CHANGED
@@ -5,11 +5,9 @@
|
|
5
5
|
#################################
|
6
6
|
## Champions League 2011/12
|
7
7
|
|
8
|
-
cl = Event.create!(
|
9
|
-
title: 'Champions League 2011/12',
|
10
|
-
start_at: Time.cet( '2011-10-10 17:00' ),
|
11
|
-
league: League.find_by_key!('cl'),
|
8
|
+
cl = Event.create!( league: League.find_by_key!('cl'),
|
12
9
|
season: Season.find_by_key!('2011/12'),
|
10
|
+
start_at: Time.cet( '2011-10-10 17:00' ),
|
13
11
|
team3: false )
|
14
12
|
|
15
13
|
|
@@ -86,5 +84,5 @@ Game.create_knockout_pairs_from_ary!( games_cl8, cl8, cl8_2 )
|
|
86
84
|
Game.create_knockout_pairs_from_ary!( games_cl4, cl4, cl4_2 )
|
87
85
|
Game.create_knockouts_from_ary!( games_cl1, cl1 )
|
88
86
|
|
89
|
-
|
90
|
-
|
87
|
+
## The End
|
88
|
+
#################
|
data/db/cl/2011_12/el.rb
CHANGED
@@ -5,11 +5,9 @@
|
|
5
5
|
#################################
|
6
6
|
## Europa League 2012
|
7
7
|
|
8
|
-
el = Event.create!(
|
9
|
-
title: 'Europa League 2011/12',
|
10
|
-
start_at: Time.cet( '2011-10-10 17:00' ),
|
11
|
-
league: League.find_by_key!('el'),
|
8
|
+
el = Event.create!( league: League.find_by_key!('el'),
|
12
9
|
season: Season.find_by_key!('2011/12'),
|
10
|
+
start_at: Time.cet( '2011-10-10 17:00' ),
|
13
11
|
team3: false )
|
14
12
|
|
15
13
|
az = Team.find_by_key!( 'az' )
|
@@ -63,5 +61,5 @@ Game.create_knockout_pairs_from_ary!( games_el8, el8, el8_2 )
|
|
63
61
|
Game.create_knockout_pairs_from_ary!( games_el4, el4, el4_2 )
|
64
62
|
Game.create_knockouts_from_ary!( games_el1, el1 )
|
65
63
|
|
66
|
-
|
67
|
-
|
64
|
+
## The End
|
65
|
+
#################
|
data/db/cl/2012_13/cl.rb
CHANGED
@@ -5,11 +5,9 @@
|
|
5
5
|
#################################
|
6
6
|
## Champions League 2012/13
|
7
7
|
|
8
|
-
cl = Event.create!(
|
9
|
-
title: 'Champions League 2012/13',
|
10
|
-
start_at: Time.cet( '2012-09-18 18:30' ),
|
11
|
-
league: League.find_by_key!('cl'),
|
8
|
+
cl = Event.create!( league: League.find_by_key!('cl'),
|
12
9
|
season: Season.find_by_key!('2012/13'),
|
10
|
+
start_at: Time.cet( '2012-09-18 18:30' ),
|
13
11
|
team3: false )
|
14
12
|
|
15
13
|
porto = Team.find_by_key!( 'porto' )
|
@@ -322,4 +320,5 @@ Game.create_pairs_from_ary_for_group!( games_clg, clg )
|
|
322
320
|
Game.create_pairs_from_ary_for_group!( games_clh, clh )
|
323
321
|
|
324
322
|
|
325
|
-
|
323
|
+
## The End
|
324
|
+
#################
|
data/db/cl/badges.rb
CHANGED
data/db/cl/teams.rb
CHANGED
data/db/copa/sud_2012_13.rb
CHANGED
@@ -7,11 +7,9 @@
|
|
7
7
|
## fix: time zone and times??
|
8
8
|
|
9
9
|
|
10
|
-
sud = Event.create!(
|
11
|
-
|
12
|
-
|
13
|
-
league: League.find_by_key!('copa.sud'),
|
14
|
-
season: Season.find_by_key!('2012/13'))
|
10
|
+
sud = Event.create!( league: League.find_by_key!('copa.sud'),
|
11
|
+
season: Season.find_by_key!('2012/13'),
|
12
|
+
start_at: Time.cet( '2012-08-03 12:00' ))
|
15
13
|
|
16
14
|
|
17
15
|
team_keys_sud = [
|
@@ -36,4 +34,5 @@ team_keys_sud = [
|
|
36
34
|
|
37
35
|
sud.add_teams_from_ary!( team_keys_sud )
|
38
36
|
|
39
|
-
|
37
|
+
## The End
|
38
|
+
#################
|
data/db/copa/teams.rb
CHANGED
data/db/de/2012_13/bl.rb
CHANGED
@@ -8,11 +8,9 @@
|
|
8
8
|
## more info => http://bundesliga.de
|
9
9
|
|
10
10
|
|
11
|
-
bl = Event.create!(
|
12
|
-
|
13
|
-
start_at: Time.cet('2012-07-21 00:00')
|
14
|
-
league: League.find_by_key!('de'),
|
15
|
-
season: Season.find_by_key!('2012/13') )
|
11
|
+
bl = Event.create!( league: League.find_by_key!('de'),
|
12
|
+
season: Season.find_by_key!('2012/13'),
|
13
|
+
start_at: Time.cet('2012-07-21 00:00'))
|
16
14
|
|
17
15
|
team_keys_bl = [
|
18
16
|
'bayern',
|
@@ -36,5 +34,5 @@ team_keys_bl = [
|
|
36
34
|
|
37
35
|
bl.add_teams_from_ary!( team_keys_bl )
|
38
36
|
|
39
|
-
|
40
|
-
|
37
|
+
## The End
|
38
|
+
#################
|
data/db/de/teams.rb
CHANGED
data/db/en/2012_13/pl.rb
CHANGED
@@ -7,11 +7,9 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
|
10
|
-
pl = Event.create!(
|
11
|
-
|
12
|
-
start_at: Time.utc('2012-08-18 12:00')
|
13
|
-
league: League.find_by_key!('en'),
|
14
|
-
season: Season.find_by_key!('2012/13'))
|
10
|
+
pl = Event.create!( league: League.find_by_key!('en'),
|
11
|
+
season: Season.find_by_key!('2012/13'),
|
12
|
+
start_at: Time.utc('2012-08-18 12:00'))
|
15
13
|
|
16
14
|
team_keys_pl = [
|
17
15
|
'chelsea',
|
@@ -37,5 +35,5 @@ team_keys_pl = [
|
|
37
35
|
|
38
36
|
pl.add_teams_from_ary!( team_keys_pl )
|
39
37
|
|
40
|
-
|
41
|
-
|
38
|
+
## The End
|
39
|
+
#################
|
data/db/en/teams.rb
CHANGED
data/db/es/teams.rb
CHANGED
data/db/euro/2008.rb
CHANGED
@@ -13,11 +13,10 @@
|
|
13
13
|
## 31 games
|
14
14
|
## 22 days
|
15
15
|
|
16
|
-
euro = Event.create!(
|
17
|
-
|
16
|
+
euro = Event.create!( league: League.find_by_key!('euro'),
|
17
|
+
season: Season.find_by_key!('2008'),
|
18
18
|
start_at: Time.cet( '2008-06-07 18:00' ),
|
19
|
-
|
20
|
-
season: Season.find_by_key!('2008'))
|
19
|
+
team3: false )
|
21
20
|
|
22
21
|
|
23
22
|
euro.add_teams_from_ary!([
|
@@ -52,9 +51,5 @@ euroc.add_teams_from_ary!(['ned', 'ita', 'rou', 'fra'])
|
|
52
51
|
|
53
52
|
eurod.add_teams_from_ary!(['gre', 'swe', 'esp', 'rus'])
|
54
53
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
54
|
+
## The End
|
55
|
+
#################
|
data/db/euro/2012.rb
CHANGED
@@ -9,11 +9,10 @@
|
|
9
9
|
# or http://de.wikipedia.org/wiki/Fu%C3%9Fball-Europameisterschaft_2012
|
10
10
|
|
11
11
|
|
12
|
-
euro = Event.create!(
|
13
|
-
|
12
|
+
euro = Event.create!( league: League.find_by_key!('euro'),
|
13
|
+
season: Season.find_by_key!('2012'),
|
14
14
|
start_at: Time.cet( '2012-06-07 17:00' ),
|
15
|
-
|
16
|
-
season: Season.find_by_key!('2012'))
|
15
|
+
team3: false )
|
17
16
|
|
18
17
|
pol = Team.find_by_key!( 'pol' )
|
19
18
|
gre = Team.find_by_key!( 'gre' )
|
@@ -163,5 +162,5 @@ Game.create_knockouts_from_ary!( games_euro8, euro8 )
|
|
163
162
|
Game.create_knockouts_from_ary!( games_euro4, euro4 )
|
164
163
|
Game.create_knockouts_from_ary!( games_euro1, euro1 )
|
165
164
|
|
166
|
-
|
167
|
-
|
165
|
+
## The End
|
166
|
+
#################
|
data/db/euro/teams.rb
CHANGED
data/db/leagues.rb
CHANGED
@@ -29,6 +29,7 @@ leagues_club = [
|
|
29
29
|
[ 'pt', 'SuperLiga', pt ],
|
30
30
|
[ 'ru', 'Premier Liga', ru ],
|
31
31
|
[ 'ro', 'Romania Liga 1', ro ],
|
32
|
+
## todo: make apertura into season?? remove from league? why? why not?
|
32
33
|
[ 'mx.apertura', 'México Primera División Apertura', mx ],
|
33
34
|
[ 'br', 'Campeonato Brasileiro Série A', br ]
|
34
35
|
]
|
@@ -55,13 +56,13 @@ League.create_from_ary!( leagues_club_intl, club: true )
|
|
55
56
|
leagues_intl = [
|
56
57
|
[ 'euro', 'Euro' ],
|
57
58
|
[ 'america', 'Copa América' ],
|
58
|
-
[ '
|
59
|
-
[ '
|
60
|
-
[ '
|
59
|
+
[ 'world', 'World Cup' ], ## change key to world??
|
60
|
+
[ 'world.quali.euro', 'World Cup Quali Europe' ],
|
61
|
+
[ 'world.quali.america', 'World Cup Quali North/Central America and Caribbean' ]
|
61
62
|
]
|
62
63
|
|
63
64
|
League.create_from_ary!( leagues_intl, club: false )
|
64
65
|
|
65
66
|
|
66
|
-
|
67
|
-
|
67
|
+
## The End
|
68
|
+
#################
|
data/db/mx/apertura_2012.rb
CHANGED
@@ -3,11 +3,9 @@
|
|
3
3
|
# note: timezone for games (play_at) is *always* CST (central standard time / -6 hours ??)
|
4
4
|
|
5
5
|
|
6
|
-
mx = Event.create!(
|
7
|
-
|
8
|
-
start_at: Time.cst('2012-07-20 00:00')
|
9
|
-
league: League.find_by_key!( 'mx.apertura'),
|
10
|
-
season: Season.find_by_key!( '2012'))
|
6
|
+
mx = Event.create!( league: League.find_by_key!( 'mx.apertura' ),
|
7
|
+
season: Season.find_by_key!( '2012'),
|
8
|
+
start_at: Time.cst('2012-07-20 00:00') )
|
11
9
|
|
12
10
|
team_keys_mx = [
|
13
11
|
'america',
|
@@ -32,4 +30,6 @@ team_keys_mx = [
|
|
32
30
|
|
33
31
|
mx.add_teams_from_ary!( team_keys_mx )
|
34
32
|
|
35
|
-
|
33
|
+
|
34
|
+
## The End
|
35
|
+
#################
|
data/db/mx/teams.rb
CHANGED
data/db/nfl/teams.rb
CHANGED
data/db/nhl/teams.rb
CHANGED
data/db/ro/l1_2012_13.rb
CHANGED
@@ -12,11 +12,9 @@
|
|
12
12
|
## todo: check key dinamo or rapid may be already taken!!
|
13
13
|
|
14
14
|
|
15
|
-
l1 = Event.create!(
|
16
|
-
|
17
|
-
start_at: Time.eet('2012-07-01 00:00')
|
18
|
-
league: League.find_by_key!('ro'),
|
19
|
-
season: Season.find_by_key!('2012/13') )
|
15
|
+
l1 = Event.create!( league: League.find_by_key!('ro'),
|
16
|
+
season: Season.find_by_key!('2012/13'),
|
17
|
+
start_at: Time.eet('2012-07-01 00:00') )
|
20
18
|
|
21
19
|
astra = Team.find_by_key!( 'astra' )
|
22
20
|
ceahlau = Team.find_by_key!( 'ceahlau' )
|
@@ -135,4 +133,5 @@ Game.create_from_ary!( games_l104, l104 )
|
|
135
133
|
Game.create_from_ary!( games_l105, l105 )
|
136
134
|
|
137
135
|
|
138
|
-
|
136
|
+
## The End
|
137
|
+
#################
|
data/db/ro/teams.rb
CHANGED
data/db/seasons.rb
CHANGED
data/db/world/2010.rb
CHANGED
@@ -13,11 +13,9 @@
|
|
13
13
|
## 64 games
|
14
14
|
## 31 days (11 June - 11 July)
|
15
15
|
|
16
|
-
wm = Event.create!(
|
17
|
-
|
18
|
-
start_at: Time.cet( '2010-06-11 12:00' )
|
19
|
-
league: League.find_by_key!('wm'),
|
20
|
-
season: Season.find_by_key!('2010'))
|
16
|
+
wm = Event.create!( league: League.find_by_key!('world'),
|
17
|
+
season: Season.find_by_key!('2010'),
|
18
|
+
start_at: Time.cet( '2010-06-11 12:00' ) )
|
21
19
|
|
22
20
|
##############
|
23
21
|
# 13 aus Europa
|
@@ -186,4 +184,5 @@ wmg.add_teams_from_ary!( ['bra', 'prk', 'civ', 'por'] )
|
|
186
184
|
wmh.add_teams_from_ary!( ['esp', 'sui', 'hon', 'chi'] )
|
187
185
|
|
188
186
|
|
189
|
-
|
187
|
+
## The End
|
188
|
+
#################
|
@@ -8,11 +8,9 @@
|
|
8
8
|
## WM 2014 - Qualification North/Central America & Caribbean Islands
|
9
9
|
|
10
10
|
|
11
|
-
world = Event.create!(
|
12
|
-
|
13
|
-
start_at: Time.cet( '2012-09-06 12:00' )
|
14
|
-
league: League.find_by_key!('wmq.america'),
|
15
|
-
season: Season.find_by_key!('2012/13'))
|
11
|
+
world = Event.create!( league: League.find_by_key!('world.quali.america'),
|
12
|
+
season: Season.find_by_key!('2012/13'),
|
13
|
+
start_at: Time.cet( '2012-09-06 12:00' ) )
|
16
14
|
|
17
15
|
team_keys_world2 = [
|
18
16
|
'mex',
|
@@ -29,5 +27,5 @@ world2 = Group.create!( event: world, pos: 2, title: 'Gruppe 2' )
|
|
29
27
|
world2.add_teams_from_ary!( team_keys_world2 )
|
30
28
|
|
31
29
|
|
32
|
-
|
33
|
-
|
30
|
+
## The End
|
31
|
+
#################
|
@@ -6,10 +6,9 @@
|
|
6
6
|
## WM 2014 - Qualification Europe
|
7
7
|
|
8
8
|
|
9
|
-
world = Event.create!(
|
10
|
-
|
11
|
-
start_at: Time.cet( '2012-09-07 00:00' )
|
12
|
-
league: League.find_by_key!('wmq.euro'),
|
13
|
-
season: Season.find_by_key!('2012/13'))
|
9
|
+
world = Event.create!( league: League.find_by_key!('world.quali.euro'),
|
10
|
+
season: Season.find_by_key!('2012/13'),
|
11
|
+
start_at: Time.cet( '2012-09-07 00:00' ) )
|
14
12
|
|
15
|
-
|
13
|
+
## The End
|
14
|
+
#################
|
@@ -5,7 +5,7 @@
|
|
5
5
|
#
|
6
6
|
# note: for teams see seeds/euro/teams.rb
|
7
7
|
|
8
|
-
world = Event.
|
8
|
+
world = Event.find_world_quali_euro_2012_13!
|
9
9
|
|
10
10
|
team_keys_worldc = [
|
11
11
|
'ger',
|
@@ -22,5 +22,5 @@ worldc = Group.create!( event: world, pos: 3, title: 'Gruppe C' )
|
|
22
22
|
|
23
23
|
worldc.add_teams_from_ary!( team_keys_worldc )
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
## The End
|
26
|
+
#################
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
# note: for teams see seeds/euro/teams.rb
|
7
7
|
|
8
|
-
world = Event.
|
8
|
+
world = Event.find_world_quali_euro_2012_13!
|
9
9
|
|
10
10
|
team_keys_worldi = [
|
11
11
|
'fra',
|
@@ -22,5 +22,5 @@ worldi = Group.create!( event: world, pos: 9, title: 'Gruppe I' )
|
|
22
22
|
worldi.add_teams_from_ary!( team_keys_worldi )
|
23
23
|
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
## The End
|
26
|
+
#################
|
data/db/world/teams.rb
CHANGED
data/lib/sportdb.rb
CHANGED
@@ -20,6 +20,7 @@ require 'worlddb'
|
|
20
20
|
|
21
21
|
# our own code
|
22
22
|
|
23
|
+
require 'sportdb/keys' # let keys go first; just string constants (get included in models)
|
23
24
|
require 'sportdb/models/forward'
|
24
25
|
require 'sportdb/models/badge'
|
25
26
|
require 'sportdb/models/city'
|
@@ -44,6 +45,7 @@ require 'sportdb/version'
|
|
44
45
|
require 'sportdb/cli/opts'
|
45
46
|
require 'sportdb/cli/runner'
|
46
47
|
|
48
|
+
|
47
49
|
module SportDB
|
48
50
|
|
49
51
|
def self.banner
|
@@ -62,61 +64,102 @@ module SportDB
|
|
62
64
|
CreateDB.up
|
63
65
|
end
|
64
66
|
|
67
|
+
class Fixtures
|
68
|
+
## todo: move into its own file???
|
69
|
+
|
70
|
+
## make constants in Keys availabe (get include in Models) - do NOT pollute/include in SportDB
|
71
|
+
## make models available in sportdb module by default with namespace
|
72
|
+
# e.g. lets you use Team instead of Models::Team
|
73
|
+
include SportDB::Models
|
74
|
+
|
75
|
+
def self.fixtures_rb_test
|
76
|
+
['leagues',
|
77
|
+
'seasons',
|
78
|
+
'at/teams',
|
79
|
+
# 'at/2011_12/bl',
|
80
|
+
# 'at/2011_12/cup',
|
81
|
+
'at/2012_13/bl',
|
82
|
+
# 'at/2012_13/cup',
|
83
|
+
'copa/teams',
|
84
|
+
'copa/sud_2012_13'
|
85
|
+
]
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.fixtures_txt_test
|
89
|
+
[
|
90
|
+
# [ AT_2011_12, 'at/2011_12/bl'],
|
91
|
+
[ AT_2012_13, 'at/2012_13/bl'],
|
92
|
+
# [ AT_CUP_2012_13, 'at/2012_13/cup'],
|
93
|
+
['copa.sud.2012/13', 'copa/sud_2012_13']
|
94
|
+
]
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
def self.fixtures_rb # all builtin ruby fixtures; helper for covenience
|
99
|
+
['leagues',
|
100
|
+
'seasons',
|
101
|
+
'at/teams',
|
102
|
+
'at/badges',
|
103
|
+
'at/2011_12/bl',
|
104
|
+
'at/2011_12/cup',
|
105
|
+
'at/2012_13/bl',
|
106
|
+
'at/2012_13/cup',
|
107
|
+
'de/teams',
|
108
|
+
'en/teams',
|
109
|
+
'es/teams',
|
110
|
+
'cl/teams',
|
111
|
+
'cl/badges',
|
112
|
+
'cl/2011_12/cl',
|
113
|
+
'cl/2011_12/el',
|
114
|
+
'cl/2012_13/cl',
|
115
|
+
'de/2012_13/bl',
|
116
|
+
'en/2012_13/pl',
|
117
|
+
'euro/teams',
|
118
|
+
'euro/2008',
|
119
|
+
'euro/2012',
|
120
|
+
'america/teams',
|
121
|
+
'america/2011',
|
122
|
+
'copa/teams',
|
123
|
+
'copa/sud_2012_13',
|
124
|
+
'mx/teams',
|
125
|
+
'mx/apertura_2012',
|
126
|
+
'world/teams',
|
127
|
+
'world/2010',
|
128
|
+
'world/quali_2012_13_europe',
|
129
|
+
'world/quali_2012_13_europe_c',
|
130
|
+
'world/quali_2012_13_europe_i',
|
131
|
+
'world/quali_2012_13_america',
|
132
|
+
'nhl/teams']
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.fixtures_txt
|
136
|
+
[[ AT_2011_12, 'at/2011_12/bl'],
|
137
|
+
[ AT_2012_13, 'at/2012_13/bl'],
|
138
|
+
[ AT_CUP_2012_13, 'at/2012_13/cup'],
|
139
|
+
['de.2012/13', 'de/2012_13/bl'],
|
140
|
+
['en.2012/13', 'en/2012_13/pl'],
|
141
|
+
['america.2011', 'america/2011'],
|
142
|
+
['mx.apertura.2012', 'mx/apertura_2012'],
|
143
|
+
['copa.sud.2012/13', 'copa/sud_2012_13'],
|
144
|
+
[ EURO_2008, 'euro/2008'],
|
145
|
+
[ WORLD_2010, 'world/2010'],
|
146
|
+
[ WORLD_QUALI_EURO_2012_13, 'world/quali_2012_13_europe_c'],
|
147
|
+
[ WORLD_QUALI_AMERICA_2012_13, 'world/quali_2012_13_america']]
|
148
|
+
end
|
149
|
+
end # class Fixtures
|
150
|
+
|
65
151
|
def self.fixtures_rb # all builtin ruby fixtures; helper for covenience
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
'at/2011_12/cup',
|
72
|
-
'at/2012_13/bl',
|
73
|
-
'at/2012_13/cup',
|
74
|
-
'de/teams',
|
75
|
-
'en/teams',
|
76
|
-
'es/teams',
|
77
|
-
'cl/teams',
|
78
|
-
'cl/badges',
|
79
|
-
'cl/2011_12/cl',
|
80
|
-
'cl/2011_12/el',
|
81
|
-
'cl/2012_13/cl',
|
82
|
-
'de/2012_13/bl',
|
83
|
-
'en/2012_13/pl',
|
84
|
-
'euro/teams',
|
85
|
-
'euro/2008',
|
86
|
-
'euro/2012',
|
87
|
-
'america/teams',
|
88
|
-
'america/2011',
|
89
|
-
'copa/teams',
|
90
|
-
'copa/sud_2012_13',
|
91
|
-
'mx/teams',
|
92
|
-
'mx/apertura_2012',
|
93
|
-
'world/teams',
|
94
|
-
'world/2010',
|
95
|
-
'world/quali_2012_13_europe',
|
96
|
-
'world/quali_2012_13_europe_c',
|
97
|
-
'world/quali_2012_13_europe_i',
|
98
|
-
'world/quali_2012_13_america',
|
99
|
-
'nhl/teams']
|
152
|
+
Fixtures.fixtures_rb
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.fixtures_txt
|
156
|
+
Fixtures.fixtures_txt
|
100
157
|
end
|
101
158
|
|
102
159
|
def self.load_all
|
103
160
|
load( fixtures_rb )
|
104
161
|
end
|
105
162
|
|
106
|
-
def self.fixtures_txt
|
107
|
-
[['at.2011/12', 'at/2011_12/bl'],
|
108
|
-
['at.2012/13', 'at/2012_13/bl'],
|
109
|
-
['at.cup.2012/13', 'at/2012_13/cup'],
|
110
|
-
['de.2012/13', 'de/2012_13/bl'],
|
111
|
-
['en.2012/13', 'en/2012_13/pl'],
|
112
|
-
['america.2011', 'america/2011'],
|
113
|
-
['mx.apertura.2012', 'mx/apertura_2012'],
|
114
|
-
['copa.sud.2012/13', 'copa/sud_2012_13'],
|
115
|
-
['euro.2008', 'euro/2008'],
|
116
|
-
['wm.2010', 'world/2010'],
|
117
|
-
['wmq.euro', 'world/quali_2012_13_europe_c'],
|
118
|
-
['wmq.america', 'world/quali_2012_13_america']]
|
119
|
-
end
|
120
163
|
|
121
164
|
def self.read_all
|
122
165
|
read( fixtures_txt )
|
@@ -252,4 +295,10 @@ end # module SportDB
|
|
252
295
|
|
253
296
|
## SportDB::load_plugins
|
254
297
|
|
255
|
-
|
298
|
+
|
299
|
+
if __FILE__ == $0
|
300
|
+
SportDB.main
|
301
|
+
else
|
302
|
+
## say hello
|
303
|
+
puts SportDB.banner
|
304
|
+
end
|
data/lib/sportdb/keys.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
module SportDB
|
3
|
+
module Keys
|
4
|
+
|
5
|
+
module EventKeys
|
6
|
+
# use constants for known keys; lets us define aliases (if things change)
|
7
|
+
|
8
|
+
AT_2011_12 = 'at.2011/12'
|
9
|
+
AT_2012_13 = 'at.2012/13'
|
10
|
+
AT_CUP_2012_13 = 'at.cup.2012/13'
|
11
|
+
|
12
|
+
CL_2012_13 = 'cl.2012/13'
|
13
|
+
|
14
|
+
EURO_2008 = 'euro.2008'
|
15
|
+
EURO_2012 = 'euro.2012'
|
16
|
+
|
17
|
+
WORLD_2010 = 'world.2010'
|
18
|
+
|
19
|
+
WORLD_QUALI_EURO_2012_13 = 'world.quali.euro.2012/13'
|
20
|
+
WORLD_QUALI_AMERICA_2012_13 = 'world.quali.america.2012/13'
|
21
|
+
|
22
|
+
############################
|
23
|
+
## NB: see db/leagues.rb for keys in use
|
24
|
+
end
|
25
|
+
|
26
|
+
include SportDB::Keys::EventKeys
|
27
|
+
|
28
|
+
end # module Keys
|
29
|
+
end # module SportDB
|
data/lib/sportdb/loader.rb
CHANGED
@@ -42,6 +42,11 @@ class Loader
|
|
42
42
|
code = File.read( path )
|
43
43
|
|
44
44
|
load_fixtures_worker( code )
|
45
|
+
|
46
|
+
### fix:
|
47
|
+
## for loaded from fs use filestat? for version - why? why not?
|
48
|
+
|
49
|
+
Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "rb.1" )
|
45
50
|
end
|
46
51
|
|
47
52
|
def load_fixtures_builtin( name ) # load from gem (built-in)
|
@@ -52,10 +57,32 @@ class Loader
|
|
52
57
|
code = File.read( path )
|
53
58
|
|
54
59
|
load_fixtures_worker( code )
|
60
|
+
|
61
|
+
## for builtin fixtures use VERSION of gem
|
62
|
+
|
63
|
+
Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "sport.rb.#{SportDB::VERSION}" )
|
55
64
|
end
|
56
65
|
|
57
66
|
|
58
67
|
private
|
68
|
+
|
69
|
+
##
|
70
|
+
# fix/todo: share helper w/ other readers
|
71
|
+
|
72
|
+
# helper
|
73
|
+
# change at/2012_13/bl to at.2012/13.bl
|
74
|
+
# or quali_2012_13_europe_c to quali.2012/13.europe.c
|
75
|
+
|
76
|
+
def fixture_name_to_prop_key( name )
|
77
|
+
prop_key = name.gsub( '/', '.' )
|
78
|
+
prop_key = prop_key.gsub( /(\d{4})_(\d{2})/, '\1/\2' ) # 2012_13 => 2012/13
|
79
|
+
prop_key = prop_key.gsub( '_', '.' )
|
80
|
+
prop_key
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
59
86
|
def load_fixtures_worker( code )
|
60
87
|
|
61
88
|
self.class_eval( code )
|
@@ -66,13 +93,6 @@ private
|
|
66
93
|
# include SportDB::Models
|
67
94
|
# <code here>
|
68
95
|
# end
|
69
|
-
|
70
|
-
|
71
|
-
# require path
|
72
|
-
# require "#{Dir.pwd}/db/#{seed}.rb"
|
73
|
-
|
74
|
-
# Prop.create!( :key => "db.#{name}.version", :value => SportDB::VERSION )
|
75
|
-
|
76
96
|
end
|
77
97
|
|
78
98
|
end # class Loader
|
data/lib/sportdb/models/event.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module SportDB::Models
|
2
4
|
|
3
5
|
class Event < ActiveRecord::Base
|
@@ -13,32 +15,134 @@ class Event < ActiveRecord::Base
|
|
13
15
|
has_many :event_teams, :class_name => 'EventTeam'
|
14
16
|
has_many :teams, :through => :event_teams
|
15
17
|
|
18
|
+
before_save :on_before_save
|
19
|
+
|
16
20
|
def add_teams_from_ary!( team_keys )
|
17
21
|
team_keys.each do |team_key|
|
18
22
|
team = Team.find_by_key!( team_key )
|
19
23
|
self.teams << team
|
20
24
|
end
|
21
25
|
end
|
26
|
+
|
27
|
+
def on_before_save
|
28
|
+
# event key is composite of league + season (e.g. at.2012/13) etc.
|
29
|
+
self.key = "#{league.key}.#{season.key}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def title
|
33
|
+
league.title
|
34
|
+
end
|
35
|
+
|
36
|
+
def full_title # includes season (e.g. year)
|
37
|
+
"#{league.title} #{season.title}"
|
38
|
+
end
|
39
|
+
|
40
|
+
#####################
|
41
|
+
## convenience helper for text parser/reader
|
42
|
+
|
43
|
+
############
|
44
|
+
### fix/todo: share helper for all text readers/parsers- where to put it?
|
45
|
+
###
|
46
|
+
|
47
|
+
def title_esc_regex( title )
|
48
|
+
## todo: how to mark value as regex?
|
49
|
+
## for now escape regex special chars e.g. . to \.
|
50
|
+
title_for_regex = title.gsub( '.', '\.' ) # e.g. Benfica Lis.
|
51
|
+
title_for_regex = title_for_regex.gsub( '(', '\(' ) # e.g. Club Atlético Colón (Santa Fe)
|
52
|
+
title_for_regex = title_for_regex.gsub( ')', '\)' )
|
53
|
+
|
54
|
+
## fix: todo: match accented char with or without accents
|
55
|
+
## add (ü|ue) etc.
|
56
|
+
## also make - optional change to (-| ) e.g. Blau-Weiss == Blau Weiss
|
57
|
+
## reuse for all readers!
|
58
|
+
title_for_regex = title_for_regex.gsub( '-', '(-| )' )
|
59
|
+
title_for_regex = title_for_regex.gsub( 'ß', '(ß|ss)' )
|
60
|
+
title_for_regex = title_for_regex.gsub( 'æ', '(æ|ae)' )
|
61
|
+
title_for_regex = title_for_regex.gsub( 'á', '(á|a)' ) ## e.g. Bogotá
|
62
|
+
title_for_regex = title_for_regex.gsub( 'ã', '(ã|a)' ) ## e.g São Paulo
|
63
|
+
title_for_regex = title_for_regex.gsub( 'ä', '(ä|ae)' ) ## add a ?
|
64
|
+
title_for_regex = title_for_regex.gsub( 'ö', '(ö|oe)' ) ## add o ?
|
65
|
+
title_for_regex = title_for_regex.gsub( 'ó', '(ó|o)' ) ## e.g. Colón
|
66
|
+
title_for_regex = title_for_regex.gsub( 'ü', '(ü|ue)' ) ## add u ?
|
67
|
+
title_for_regex = title_for_regex.gsub( 'é', '(é|e)' ) ## e.g. Vélez
|
68
|
+
title_for_regex = title_for_regex.gsub( 'ê', '(ê|e)' ) ## e.g. Grêmio
|
69
|
+
title_for_regex = title_for_regex.gsub( 'ñ', '(ñ|n)' ) ## e.g. Porteño
|
70
|
+
title_for_regex = title_for_regex.gsub( 'ú', '(ú|u)' ) ## e.g. Fútbol
|
71
|
+
|
72
|
+
## todo: add some more; use array for config?
|
73
|
+
## see http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references for more
|
74
|
+
|
75
|
+
title_for_regex
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
def known_teams_table
|
81
|
+
|
82
|
+
## build known teams table w/ synonyms e.g.
|
83
|
+
#
|
84
|
+
# [[ 'wolfsbrug', [ 'VfL Wolfsburg' ]],
|
85
|
+
# [ 'augsburg', [ 'FC Augsburg', 'Augi2', 'Augi3' ]],
|
86
|
+
# [ 'stuttgart', [ 'VfB Stuttgart' ]] ]
|
87
|
+
|
88
|
+
known_teams = []
|
89
|
+
|
90
|
+
teams.each_with_index do |team,index|
|
91
|
+
|
92
|
+
titles = []
|
93
|
+
titles << team.title
|
94
|
+
titles += team.synonyms.split('|') if team.synonyms.present?
|
95
|
+
|
96
|
+
## NB: sort here by length (largest goes first - best match)
|
97
|
+
# exclude code and key (key should always go last)
|
98
|
+
titles = titles.sort { |left,right| right.length <=> left.length }
|
99
|
+
|
100
|
+
## escape for regex plus allow subs for special chars/accents
|
101
|
+
titles = titles.map { |title| title_esc_regex( title ) }
|
102
|
+
|
103
|
+
titles << team.code if team.code.present?
|
104
|
+
titles << team.key
|
105
|
+
|
106
|
+
known_teams << [ team.key, titles ]
|
107
|
+
|
108
|
+
puts " Team[#{index+1}] #{team.key} >#{titles.join('|')}<"
|
109
|
+
end
|
110
|
+
|
111
|
+
known_teams
|
112
|
+
end # method known_teams_table
|
22
113
|
|
23
114
|
###########################
|
24
115
|
## convenience helpers
|
25
116
|
|
117
|
+
include SportDB::Keys::EventKeys
|
118
|
+
|
26
119
|
def self.find_at_2012_13!
|
27
|
-
self.find_by_key!(
|
120
|
+
self.find_by_key!( AT_2012_13 )
|
28
121
|
end
|
29
122
|
|
30
123
|
def self.find_at_cup_2012_13!
|
31
|
-
self.find_by_key!(
|
124
|
+
self.find_by_key!( AT_CUP_2012_13 )
|
32
125
|
end
|
33
126
|
|
34
127
|
def self.find_cl_2012_13!
|
35
|
-
self.find_by_key!(
|
128
|
+
self.find_by_key!( CL_2012_13 )
|
36
129
|
end
|
37
130
|
|
38
131
|
def self.find_euro_2012!
|
39
|
-
self.find_by_key!(
|
132
|
+
self.find_by_key!( EURO_2012 )
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.find_world_2010!
|
136
|
+
self.find_by_key!( WORLD_2010 )
|
40
137
|
end
|
41
138
|
|
139
|
+
def self.find_world_quali_euro_2012_13!
|
140
|
+
self.find_by_key!( WORLD_QUALI_EURO_2012_13 )
|
141
|
+
end
|
142
|
+
|
143
|
+
def self.find_world_quali_america_2012_13!
|
144
|
+
self.find_by_key!( WORLD_QUALI_AMERICA_2012_13 )
|
145
|
+
end
|
42
146
|
|
43
147
|
|
44
148
|
end # class Event
|
@@ -2,8 +2,6 @@
|
|
2
2
|
### forward references
|
3
3
|
## require first to resolve circular references
|
4
4
|
|
5
|
-
module SportDB ; end
|
6
|
-
|
7
5
|
module SportDB::Models
|
8
6
|
|
9
7
|
## todo: why? why not use include WorldDB::Models here???
|
@@ -18,6 +16,9 @@ module SportDB::Models
|
|
18
16
|
|
19
17
|
class Team < ActiveRecord::Base ; end
|
20
18
|
class League < ActiveRecord::Base ; end
|
19
|
+
|
20
|
+
#### make constanst such as AT_2012_13, WORLD_2010, etc. available
|
21
|
+
include SportDB::Keys
|
21
22
|
|
22
23
|
end
|
23
24
|
|
data/lib/sportdb/reader.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module SportDB
|
2
4
|
|
3
5
|
class Reader
|
@@ -41,6 +43,11 @@ class Reader
|
|
41
43
|
code = File.read( path )
|
42
44
|
|
43
45
|
load_fixtures_worker( event_key, code )
|
46
|
+
|
47
|
+
### fix:
|
48
|
+
## for loaded from fs use filestat? for version - why? why not?
|
49
|
+
|
50
|
+
Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "txt.1" )
|
44
51
|
end
|
45
52
|
|
46
53
|
def load_fixtures_builtin( event_key, name ) # load from gem (built-in)
|
@@ -51,10 +58,27 @@ class Reader
|
|
51
58
|
code = File.read( path )
|
52
59
|
|
53
60
|
load_fixtures_worker( event_key, code )
|
61
|
+
|
62
|
+
Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "sport.txt.#{SportDB::VERSION}" )
|
54
63
|
end
|
55
64
|
|
56
65
|
|
57
66
|
private
|
67
|
+
|
68
|
+
##
|
69
|
+
# fix/todo: share helper w/ other readers
|
70
|
+
|
71
|
+
# helper
|
72
|
+
# change at/2012_13/bl to at.2012/13.bl
|
73
|
+
# or quali_2012_13_europe_c to quali.2012/13.europe.c
|
74
|
+
|
75
|
+
def fixture_name_to_prop_key( name )
|
76
|
+
prop_key = name.gsub( '/', '.' )
|
77
|
+
prop_key = prop_key.gsub( /(\d{4})_(\d{2})/, '\1/\2' ) # 2012_13 => 2012/13
|
78
|
+
prop_key = prop_key.gsub( '_', '.' )
|
79
|
+
prop_key
|
80
|
+
end
|
81
|
+
|
58
82
|
def load_fixtures_worker( event_key, data )
|
59
83
|
|
60
84
|
## assume active activerecord connection
|
@@ -63,37 +87,9 @@ private
|
|
63
87
|
@event = Event.find_by_key!( event_key )
|
64
88
|
|
65
89
|
puts "Event #{@event.key} >#{@event.title}<"
|
66
|
-
|
67
|
-
|
68
|
-
## build known teams table w/ synonyms e.g.
|
69
|
-
#
|
70
|
-
# nb: synonyms can be a regex not just a literal string
|
71
|
-
# [[ 'wolfsbrug', [ 'VfL Wolfsburg' ]],
|
72
|
-
# [ 'augsburg', [ 'FC Augsburg', 'Augi2', 'Augi3' ]],
|
73
|
-
# [ 'stuttgart', [ 'VfB Stuttgart' ]] ]
|
74
90
|
|
75
|
-
@known_teams =
|
91
|
+
@known_teams = @event.known_teams_table
|
76
92
|
|
77
|
-
## todo/fix: move calc known_teams to model!!! (for reuse)
|
78
|
-
|
79
|
-
@event.teams.each_with_index do |team,index|
|
80
|
-
|
81
|
-
titles = []
|
82
|
-
titles << team.title
|
83
|
-
titles += team.synonyms.split('|') if team.synonyms.present?
|
84
|
-
|
85
|
-
## NB: sort here by length (largest goes first - best match)
|
86
|
-
# exclude code and key (key should always go last)
|
87
|
-
titles = titles.sort { |left,right| right.length <=> left.length }
|
88
|
-
|
89
|
-
titles << team.code if team.code.present?
|
90
|
-
titles << team.key
|
91
|
-
|
92
|
-
@known_teams << [ team.key, titles ]
|
93
|
-
|
94
|
-
puts " Team[#{index+1}] #{team.key} >#{titles.join('|')}<"
|
95
|
-
end
|
96
|
-
|
97
93
|
parse_fixtures( data )
|
98
94
|
|
99
95
|
end # method load_fixtures
|
@@ -253,15 +249,19 @@ private
|
|
253
249
|
def find_team2!( line )
|
254
250
|
find_team_worker!( line, 2 )
|
255
251
|
end
|
256
|
-
|
257
|
-
|
252
|
+
|
253
|
+
|
258
254
|
def match_team_worker!( line, key, values )
|
259
255
|
values.each do |value|
|
260
|
-
|
256
|
+
## nb: \b does NOT include space or newline for word boundry (only alphanums e.g. a-z0-9)
|
257
|
+
## (thus add it, allows match for Benfica Lis. for example - note . at the end)
|
258
|
+
|
259
|
+
## check add $ e.g. (\b| |\t|$) does this work? - check w/ Benfica Lis.$
|
260
|
+
regex = /\b#{value}(\b| |\t)/ # wrap with world boundry (e.g. match only whole words e.g. not wac in wacker)
|
261
261
|
if line =~ regex
|
262
262
|
puts " match for team >#{key}< >#{value}<"
|
263
263
|
# make sure @@oo{key}oo@@ doesn't match itself with other key e.g. wacker, wac, etc.
|
264
|
-
line.sub!( regex, "@@oo#{key}oo@@" )
|
264
|
+
line.sub!( regex, "@@oo#{key}oo@@ " ) # NB: add one space char at end
|
265
265
|
return true # break out after first match (do NOT continue)
|
266
266
|
end
|
267
267
|
end
|
data/lib/sportdb/schema.rb
CHANGED
data/lib/sportdb/version.rb
CHANGED
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:
|
4
|
+
hash: 59
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 9
|
9
|
+
- 0
|
10
|
+
version: 0.9.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Gerald Bauer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-11-
|
18
|
+
date: 2012-11-18 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activerecord
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- lib/sportdb.rb
|
159
159
|
- lib/sportdb/cli/opts.rb
|
160
160
|
- lib/sportdb/cli/runner.rb
|
161
|
+
- lib/sportdb/keys.rb
|
161
162
|
- lib/sportdb/loader.rb
|
162
163
|
- lib/sportdb/models/badge.rb
|
163
164
|
- lib/sportdb/models/city.rb
|