sportdb-models 1.18.5 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +27 -145
- data/Rakefile +4 -5
- data/lib/sportdb/models.rb +93 -160
- data/lib/sportdb/{deleter.rb → models/deleter.rb} +4 -10
- data/lib/sportdb/models/formats.rb +23 -0
- data/lib/sportdb/models/models/assoc.rb +38 -0
- data/lib/sportdb/models/{badge.rb → models/badge.rb} +1 -1
- data/lib/sportdb/models/models/event.rb +55 -0
- data/lib/sportdb/models/{forward.rb → models/forward.rb} +3 -3
- data/lib/sportdb/models/{goal.rb → models/goal.rb} +1 -1
- data/lib/sportdb/models/models/ground.rb +16 -0
- data/lib/sportdb/models/{group.rb → models/group.rb} +10 -7
- data/lib/sportdb/models/models/league.rb +20 -0
- data/lib/sportdb/models/{roster.rb → models/lineup.rb} +3 -4
- data/lib/sportdb/models/{game.rb → models/match.rb} +18 -61
- data/lib/sportdb/models/{person.rb → models/person.rb} +0 -0
- data/lib/sportdb/models/{round.rb → models/round.rb} +1 -6
- data/lib/sportdb/models/{season.rb → models/season.rb} +2 -1
- data/lib/sportdb/models/{stage.rb → models/stage.rb} +9 -5
- data/lib/sportdb/models/{stats/alltime_standing_entry.rb → models/stats/alltime_standing.rb} +9 -1
- data/lib/sportdb/models/{stats/event_standing_entry.rb → models/stats/event_standing.rb} +11 -1
- data/lib/sportdb/models/{stats/group_standing_entry.rb → models/stats/group_standing.rb} +10 -1
- data/lib/sportdb/models/models/team.rb +56 -0
- data/lib/sportdb/models/{world → models/world}/city.rb +2 -2
- data/lib/sportdb/models/{world → models/world}/continent.rb +0 -0
- data/lib/sportdb/models/{world → models/world}/country.rb +0 -0
- data/lib/sportdb/models/{world → models/world}/state.rb +0 -0
- data/lib/sportdb/{schema.rb → models/schema.rb} +165 -100
- data/lib/sportdb/models/stats.rb +23 -0
- data/lib/sportdb/models/utils.rb +24 -24
- data/lib/sportdb/{version.rb → models/version.rb} +12 -5
- data/test/helper.rb +10 -114
- data/test/test_changes.rb +38 -38
- data/test/test_cursor.rb +15 -15
- data/test/test_winner.rb +75 -70
- metadata +29 -161
- data/lib/sportdb/calc.rb +0 -279
- data/lib/sportdb/indexers/team.rb +0 -87
- data/lib/sportdb/mapper_teams.rb +0 -24
- data/lib/sportdb/matcher.rb +0 -31
- data/lib/sportdb/models/assoc.rb +0 -106
- data/lib/sportdb/models/assoc_assoc.rb +0 -15
- data/lib/sportdb/models/event.rb +0 -66
- data/lib/sportdb/models/event_ground.rb +0 -15
- data/lib/sportdb/models/event_team.rb +0 -16
- data/lib/sportdb/models/ground.rb +0 -100
- data/lib/sportdb/models/group_team.rb +0 -14
- data/lib/sportdb/models/league.rb +0 -83
- data/lib/sportdb/models/stage_team.rb +0 -14
- data/lib/sportdb/models/stats/alltime_standing.rb +0 -44
- data/lib/sportdb/models/stats/event_standing.rb +0 -55
- data/lib/sportdb/models/stats/group_standing.rb +0 -50
- data/lib/sportdb/models/team.rb +0 -119
- data/lib/sportdb/models/team_compat.rb +0 -64
- data/lib/sportdb/patterns.rb +0 -37
- data/lib/sportdb/pretty_printer.rb +0 -175
- data/lib/sportdb/reader.rb +0 -132
- data/lib/sportdb/reader_file.rb +0 -131
- data/lib/sportdb/reader_zip.rb +0 -172
- data/lib/sportdb/readers/assoc.rb +0 -54
- data/lib/sportdb/readers/event.rb +0 -253
- data/lib/sportdb/readers/event_meta.rb +0 -133
- data/lib/sportdb/readers/event_table.rb +0 -196
- data/lib/sportdb/readers/game.rb +0 -912
- data/lib/sportdb/readers/ground.rb +0 -53
- data/lib/sportdb/readers/league.rb +0 -54
- data/lib/sportdb/readers/season.rb +0 -83
- data/lib/sportdb/readers/squad_club.rb +0 -201
- data/lib/sportdb/readers/squad_national_team.rb +0 -173
- data/lib/sportdb/readers/team.rb +0 -53
- data/lib/sportdb/rsssf_reader.rb +0 -367
- data/lib/sportdb/standings.rb +0 -178
- data/lib/sportdb/stats.rb +0 -27
- data/lib/sportdb/utils.rb +0 -89
- data/lib/sportdb/utils_date.rb +0 -26
- data/lib/sportdb/utils_goals.rb +0 -20
- data/lib/sportdb/utils_group.rb +0 -63
- data/lib/sportdb/utils_map.rb +0 -44
- data/lib/sportdb/utils_round.rb +0 -165
- data/lib/sportdb/utils_scores.rb +0 -17
- data/lib/sportdb/utils_teams.rb +0 -48
- data/test/data/at-austria/2013_14/bl.txt +0 -227
- data/test/data/at-austria/2013_14/bl.yml +0 -30
- data/test/data/at-austria/2013_14/bl_ii.txt +0 -154
- data/test/data/at-austria/2013_14/el.txt +0 -4
- data/test/data/at-austria/2013_14/el.yml +0 -25
- data/test/data/at-austria/2013_14/squads/austria.txt +0 -40
- data/test/data/at-austria/2013_14/squads/salzburg.txt +0 -35
- data/test/data/at-austria/2014_15/1-bundesliga-ii.txt +0 -158
- data/test/data/at-austria/2014_15/1-bundesliga.yml +0 -18
- data/test/data/at-austria/2015_16/1-bundesliga-v2.conf.txt +0 -20
- data/test/data/at-austria/2015_16/1-bundesliga-v2.yml +0 -20
- data/test/data/at-austria/2015_16/1-bundesliga.conf.txt +0 -20
- data/test/data/at-austria/2015_16/1-bundesliga.yml +0 -24
- data/test/data/at-austria/2015_16/cup.yml +0 -77
- data/test/data/at-austria/leagues.txt +0 -11
- data/test/data/at-austria/teams.txt +0 -68
- data/test/data/at-austria/teams_2.txt +0 -21
- data/test/data/csv/de-2013-14--1-bundesliga.txt +0 -307
- data/test/data/de-deutschland/2013-14/1-bundesliga.yml +0 -26
- data/test/data/de-deutschland/leagues.txt +0 -4
- data/test/data/de-deutschland/teams.txt +0 -53
- data/test/data/eng-england/2015-16/1-premierleague-v2.yml +0 -2
- data/test/data/eng-england/2015-16/1-premierleague.yml +0 -5
- data/test/data/national-teams/assocs.txt +0 -231
- data/test/data/national-teams/europe/assocs.txt +0 -13
- data/test/data/national-teams/europe/teams.txt +0 -13
- data/test/data/national-teams/north-america/assocs.txt +0 -10
- data/test/data/national-teams/north-america/teams.txt +0 -7
- data/test/data/national-teams/teams.txt +0 -19
- data/test/data/players/europe/at-austria/players.txt +0 -45
- data/test/data/players/europe/de-deutschland/players.txt +0 -41
- data/test/data/players/south-america/br-brazil/players.txt +0 -51
- data/test/data/rsssf/at-2014-15--1-bundesliga.txt +0 -339
- data/test/data/rsssf/at-2015-16--1-bundesliga.txt +0 -18
- data/test/data/world-cup/1930/cup.txt +0 -71
- data/test/data/world-cup/1930/cup.yml +0 -23
- data/test/data/world-cup/1930/cup_goals.txt +0 -47
- data/test/data/world-cup/1930/cup_goals.yml +0 -23
- data/test/data/world-cup/1954/cup.txt +0 -90
- data/test/data/world-cup/1954/cup.yml +0 -30
- data/test/data/world-cup/1962/cup.txt +0 -86
- data/test/data/world-cup/1962/cup.yml +0 -32
- data/test/data/world-cup/1974/cup.yml +0 -35
- data/test/data/world-cup/1974/cup_finals.txt +0 -14
- data/test/data/world-cup/1974/cup_i.txt +0 -55
- data/test/data/world-cup/1974/cup_ii.txt +0 -34
- data/test/data/world-cup/2014/cup.txt +0 -5
- data/test/data/world-cup/2014/cup.yml +0 -54
- data/test/data/world-cup/2014/squads/br-brazil.txt +0 -46
- data/test/data/world-cup/2014/squads/de-deutschland.txt +0 -8
- data/test/data/world-cup/2014/squads/jp-japan.txt +0 -30
- data/test/data/world-cup/2014/squads/uy-uruguay.txt +0 -32
- data/test/data/world-cup/leagues.txt +0 -5
- data/test/data/world-cup/seasons_1930.txt +0 -4
- data/test/data/world-cup/seasons_1954.txt +0 -4
- data/test/data/world-cup/seasons_1962.txt +0 -4
- data/test/data/world-cup/seasons_1974.txt +0 -5
- data/test/data/world-cup/teams_1930.txt +0 -26
- data/test/data/world-cup/teams_1954.txt +0 -30
- data/test/data/world-cup/teams_1962.txt +0 -29
- data/test/data/world-cup/teams_1974.txt +0 -29
- data/test/test_assoc_reader.rb +0 -199
- data/test/test_event_meta_reader.rb +0 -47
- data/test/test_event_reader.rb +0 -64
- data/test/test_event_table_reader.rb +0 -57
- data/test/test_goals.rb +0 -107
- data/test/test_indexer_team.rb +0 -34
- data/test/test_load.rb +0 -61
- data/test/test_pp.rb +0 -35
- data/test/test_reader.rb +0 -88
- data/test/test_reader_from_string.rb +0 -63
- data/test/test_round_auto.rb +0 -370
- data/test/test_round_def.rb +0 -109
- data/test/test_round_header.rb +0 -183
- data/test/test_rsssf_reader.rb +0 -76
- data/test/test_squad_club_reader.rb +0 -76
- data/test/test_squad_national_team_reader.rb +0 -116
- data/test/test_standings.rb +0 -279
- data/test/test_standings_ii.rb +0 -46
- data/test/test_utils.rb +0 -124
@@ -1,47 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_event_meta_reader.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
class TestEventMetaReaderXX < MiniTest::Test # note: TestEventMetaReader alreay defined, thus, add xx
|
11
|
-
|
12
|
-
def setup
|
13
|
-
WorldDb.delete!
|
14
|
-
SportDb.delete!
|
15
|
-
PersonDb.delete!
|
16
|
-
|
17
|
-
## setup premier league
|
18
|
-
eng = Country.create!( key: 'eng', name: 'England', code: 'ENG', pop: 1, area: 1)
|
19
|
-
season = Season.create!( key: '2015/16', title: '2015/16' )
|
20
|
-
league = League.create!( key: 'en', title: 'English Premier League', club: true, country_id: eng.id )
|
21
|
-
pl = Event.create!( season_id: season.id, league_id: league.id,
|
22
|
-
start_at: Date.new( 2015, 7, 1 ) )
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_pl
|
26
|
-
r = TestEventMetaReader.from_file( 'eng-england/2015-16/1-premierleague' )
|
27
|
-
r.read
|
28
|
-
|
29
|
-
pp r.event
|
30
|
-
pp r.fixtures
|
31
|
-
|
32
|
-
assert_equal ['1-premierleague-i','1-premierleague-ii'], r.fixtures
|
33
|
-
assert true ## if we get here; assume everything ok
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_pl_v2
|
37
|
-
r = TestEventMetaReader.from_file( 'eng-england/2015-16/1-premierleague-v2' )
|
38
|
-
r.read
|
39
|
-
|
40
|
-
pp r.event
|
41
|
-
pp r.fixtures
|
42
|
-
|
43
|
-
assert_equal ['1-premierleague-v2'], r.fixtures
|
44
|
-
assert true ## if we get here; assume everything ok
|
45
|
-
end
|
46
|
-
|
47
|
-
end # class TestEventMetaReader
|
data/test/test_event_reader.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_event_reader.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
class TestEventReaderXX < MiniTest::Test # note: TestEventReader alreay defined, thus, add xx
|
11
|
-
|
12
|
-
def setup
|
13
|
-
WorldDb.delete!
|
14
|
-
SportDb.delete!
|
15
|
-
PersonDb.delete!
|
16
|
-
|
17
|
-
## setup österr. bundesliga
|
18
|
-
at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
|
19
|
-
season = Season.create!( key: '2015/16', title: '2015/16' )
|
20
|
-
bl = League.create!( key: 'at', title: 'Österr. Bundesliga', club: true, country_id: at.id )
|
21
|
-
|
22
|
-
## read teams (required for db key lookup)
|
23
|
-
teamreader = TestTeamReader.from_file( 'at-austria/teams', country_id: at.id )
|
24
|
-
teamreader.read
|
25
|
-
teamreader = TestTeamReader.from_file( 'at-austria/teams_2', country_id: at.id )
|
26
|
-
teamreader.read
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_bl
|
30
|
-
r = TestEventReader.from_file( 'at-austria/2015_16/1-bundesliga' )
|
31
|
-
r.read
|
32
|
-
|
33
|
-
pp r.fixtures
|
34
|
-
|
35
|
-
assert_equal ['1-bundesliga-i', '1-bundesliga-ii'], r.fixtures
|
36
|
-
assert true ## if we get here; assume everything ok
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_bl_v2
|
40
|
-
r = TestEventReader.from_file( 'at-austria/2015_16/1-bundesliga-v2' )
|
41
|
-
r.read
|
42
|
-
|
43
|
-
pp r.fixtures
|
44
|
-
|
45
|
-
assert_equal ['1-bundesliga-v2'], r.fixtures
|
46
|
-
assert true ## if we get here; assume everything ok
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
### fix/todo:
|
52
|
-
## to be done - add support for Wiener Sportklub (RL Ost) => Wiener Sportklub lookups
|
53
|
-
def xxxx_test_cup
|
54
|
-
at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
|
55
|
-
season = Season.create!( key: '2015/16', title: '2015/16' )
|
56
|
-
cup = League.create!( key: 'at.cup', title: 'Cup', club: true, country_id: at.id )
|
57
|
-
|
58
|
-
r = TestEventReader.from_file( 'at-austria/2015_16/cup' )
|
59
|
-
r.read
|
60
|
-
|
61
|
-
assert true ## if we get here; assume everything ok
|
62
|
-
end
|
63
|
-
|
64
|
-
end # class TestEventReader
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_event_table_reader.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
class TestEventTableReaderXX < MiniTest::Test # note: TestEventTableReader alreay defined, thus, add xx
|
11
|
-
|
12
|
-
def setup
|
13
|
-
WorldDb.delete!
|
14
|
-
SportDb.delete!
|
15
|
-
PersonDb.delete!
|
16
|
-
|
17
|
-
## setup österr. bundesliga
|
18
|
-
at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
|
19
|
-
season = Season.create!( key: '2015/16', title: '2015/16' )
|
20
|
-
bl = League.create!( key: 'at', title: 'Österr. Bundesliga', club: true, country_id: at.id )
|
21
|
-
|
22
|
-
## read teams (required for db key lookup)
|
23
|
-
teamreader = TestTeamReader.from_file( 'at-austria/teams', country_id: at.id )
|
24
|
-
teamreader.read
|
25
|
-
teamreader = TestTeamReader.from_file( 'at-austria/teams_2', country_id: at.id )
|
26
|
-
teamreader.read
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_bl
|
30
|
-
r = TestEventTableReader.from_file( 'at-austria/2015_16/1-bundesliga.conf' )
|
31
|
-
r.read
|
32
|
-
|
33
|
-
assert true ## if we get here; assume everything ok
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_bl_v2
|
37
|
-
r = TestEventTableReader.from_file( 'at-austria/2015_16/1-bundesliga-v2.conf' )
|
38
|
-
r.read
|
39
|
-
|
40
|
-
assert true ## if we get here; assume everything ok
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
### fix/todo:
|
45
|
-
## to be done - add support for Wiener Sportklub (RL Ost) => Wiener Sportklub lookups
|
46
|
-
def xxxx_test_cup
|
47
|
-
at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
|
48
|
-
season = Season.create!( key: '2015/16', title: '2015/16' )
|
49
|
-
cup = League.create!( key: 'at.cup', title: 'Cup', club: true, country_id: at.id )
|
50
|
-
|
51
|
-
r = TestEventReader.from_file( 'at-austria/2015_16/cup' )
|
52
|
-
r.read
|
53
|
-
|
54
|
-
assert true ## if we get here; assume everything ok
|
55
|
-
end
|
56
|
-
|
57
|
-
end # class TestEventReader
|
data/test/test_goals.rb
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_goals.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
class TestGoals < MiniTest::Test
|
11
|
-
|
12
|
-
def setup
|
13
|
-
WorldDb.delete!
|
14
|
-
SportDb.delete!
|
15
|
-
## SportDb.read_builtin
|
16
|
-
|
17
|
-
add_countries
|
18
|
-
end
|
19
|
-
|
20
|
-
def add_countries
|
21
|
-
countries = [
|
22
|
-
['cd', 'Congo DR', 'COD' ],
|
23
|
-
['kr', 'South Korea', 'KOR' ],
|
24
|
-
['au', 'Australia', 'AUS' ],
|
25
|
-
|
26
|
-
['ar', 'Argentina', 'ARG' ],
|
27
|
-
['br', 'Brazil', 'BRA' ],
|
28
|
-
['bo', 'Bolivia', 'BOL' ],
|
29
|
-
['cl', 'Chile', 'CHI' ],
|
30
|
-
['co', 'Colombia', 'COL' ],
|
31
|
-
['uy', 'Uruguay', 'URU' ],
|
32
|
-
['pe', 'Peru', 'PER' ],
|
33
|
-
['py', 'Paraguay', 'PAR' ],
|
34
|
-
|
35
|
-
['mx', 'Mexico', 'MEX' ],
|
36
|
-
['us', 'United States', 'USA' ],
|
37
|
-
['ht', 'Haiti', 'HAI' ],
|
38
|
-
|
39
|
-
['at', 'Austria', 'AUT' ],
|
40
|
-
['be', 'Belgium', 'BEL' ],
|
41
|
-
['fr', 'France', 'FRA' ],
|
42
|
-
['rs', 'Serbia', 'SRB' ],
|
43
|
-
['ro', 'Romania', 'ROU' ],
|
44
|
-
['bg', 'Bulgaria', 'BUL' ],
|
45
|
-
['cz', 'Czech Republic', 'CZE' ],
|
46
|
-
['en', 'England', 'ENG' ],
|
47
|
-
['de', 'Germany', 'GER' ],
|
48
|
-
['hu', 'Hungary', 'HUN' ],
|
49
|
-
['it', 'Italy', 'ITA' ],
|
50
|
-
['ru', 'Russia', 'RUS' ],
|
51
|
-
['es', 'Spain', 'ESP' ],
|
52
|
-
['ch', 'Switzerland', 'SUI' ],
|
53
|
-
['sc', 'Scotland', 'SCO' ],
|
54
|
-
['tr', 'Turkey', 'TUR' ],
|
55
|
-
['nl', 'Netherlands', 'NED' ],
|
56
|
-
['pl', 'Poland', 'POL' ],
|
57
|
-
['se', 'Sweden', 'SWE' ],
|
58
|
-
]
|
59
|
-
|
60
|
-
countries.each do |country|
|
61
|
-
key = country[0]
|
62
|
-
name = country[1]
|
63
|
-
code = country[2]
|
64
|
-
Country.create!( key: key, name: name, code: code, pop: 1, area: 1)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
def test_world_cup_1930
|
70
|
-
teamreader = TestTeamReader.from_file( 'world-cup/teams_1930' )
|
71
|
-
teamreader.read()
|
72
|
-
|
73
|
-
assert_equal 13, Team.count
|
74
|
-
|
75
|
-
seasonreader = TestSeasonReader.from_file( 'world-cup/seasons_1930' )
|
76
|
-
seasonreader.read()
|
77
|
-
|
78
|
-
assert_equal 1, Season.count
|
79
|
-
|
80
|
-
y = Season.find_by_key!( '1930' )
|
81
|
-
assert_equal '1930', y.title
|
82
|
-
|
83
|
-
|
84
|
-
leaguereader = TestLeagueReader.from_file( 'world-cup/leagues' )
|
85
|
-
leaguereader.read()
|
86
|
-
|
87
|
-
assert_equal 1, League.count
|
88
|
-
|
89
|
-
l = League.find_by_key!( 'world' )
|
90
|
-
assert_equal 'World Cup', l.title
|
91
|
-
|
92
|
-
|
93
|
-
gamereader = TestGameReader.from_file( 'world-cup/1930/cup_goals' )
|
94
|
-
gamereader.read()
|
95
|
-
|
96
|
-
assert_equal 1, Event.count
|
97
|
-
|
98
|
-
w = Event.find_by_key!( 'world.1930' )
|
99
|
-
|
100
|
-
assert_equal 13, w.teams.count
|
101
|
-
## assert_equal 18, w.games.count
|
102
|
-
## assert_equal 12, w.rounds.count
|
103
|
-
|
104
|
-
end # method test_world_cup_1930
|
105
|
-
|
106
|
-
|
107
|
-
end # class TestGoals
|
data/test/test_indexer_team.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_indexer_team.rb
|
6
|
-
# or better
|
7
|
-
# rake -I ./lib test
|
8
|
-
|
9
|
-
|
10
|
-
require 'helper'
|
11
|
-
|
12
|
-
class TestTeamIndexerXX < MiniTest::Test ## note: TestTeamIndexer already exists
|
13
|
-
|
14
|
-
def setup
|
15
|
-
WorldDb.delete!
|
16
|
-
SportDb.delete!
|
17
|
-
SportDb.read_builtin
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_bl
|
21
|
-
at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
|
22
|
-
|
23
|
-
indexer = TestTeamIndexer.from_file( 'at-austria/teams', country_id: at.id )
|
24
|
-
h = indexer.read()
|
25
|
-
|
26
|
-
pp h
|
27
|
-
|
28
|
-
## indexer = TestTeamIndexer.from_file( 'at-austria/teams_2', country_id: at.id )
|
29
|
-
## indexer.read()
|
30
|
-
|
31
|
-
assert true ## assume everthing ok
|
32
|
-
end
|
33
|
-
|
34
|
-
end # class TestTeamIndexerXX
|
data/test/test_load.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_load.rb
|
6
|
-
# or better
|
7
|
-
# rake -I ./lib test
|
8
|
-
|
9
|
-
|
10
|
-
require 'helper'
|
11
|
-
|
12
|
-
class TestLoad < MiniTest::Test
|
13
|
-
|
14
|
-
def setup
|
15
|
-
WorldDb.delete!
|
16
|
-
SportDb.delete!
|
17
|
-
PersonDb.delete!
|
18
|
-
SportDb.read_builtin # add 2014 season
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
def test_br
|
23
|
-
br = Country.create!( key: 'br', title: 'Brazil', code: 'BRA', pop: 1, area: 1)
|
24
|
-
bra = Team.create!( key: 'bra', title: 'Brazil', code: 'BRA', country_id: br.id )
|
25
|
-
|
26
|
-
reader = Reader.new( SportDb.test_data_path )
|
27
|
-
|
28
|
-
## fix: add to country_matcher - allow players/br-brazil.txt e.g. country encode in file
|
29
|
-
## reader.load( 'players/south-america/br-brazil/players' )
|
30
|
-
## assert_equal 30, Person.count
|
31
|
-
|
32
|
-
reader.load( 'world-cup/leagues' )
|
33
|
-
assert_equal 1, League.count
|
34
|
-
reader.load( 'world-cup/2014/cup' )
|
35
|
-
assert_equal 1, Event.count
|
36
|
-
|
37
|
-
reader.load( 'world-cup/2014/squads/br-brazil' )
|
38
|
-
assert_equal 23, Roster.count
|
39
|
-
end # method test_br
|
40
|
-
|
41
|
-
|
42
|
-
def test_de
|
43
|
-
de = Country.create!( key: 'de', title: 'Germany', code: 'GER', pop: 1, area: 1)
|
44
|
-
ger = Team.create!( key: 'ger', title: 'Germany', code: 'GER', country_id: de.id )
|
45
|
-
|
46
|
-
reader = Reader.new( SportDb.test_data_path )
|
47
|
-
|
48
|
-
## reader.load( 'players/europe/de-deutschland/players' )
|
49
|
-
## assert_equal 27, Person.count
|
50
|
-
|
51
|
-
reader.load( 'world-cup/leagues' )
|
52
|
-
assert_equal 1, League.count
|
53
|
-
reader.load( 'world-cup/2014/cup' )
|
54
|
-
assert_equal 1, Event.count
|
55
|
-
|
56
|
-
reader.load( 'world-cup/2014/squads/de-deutschland' )
|
57
|
-
assert_equal 3, Roster.count
|
58
|
-
end # method test_de
|
59
|
-
|
60
|
-
|
61
|
-
end # class TestLoad
|
data/test/test_pp.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_pp.rb
|
6
|
-
# or better
|
7
|
-
# rake -I ./lib test
|
8
|
-
|
9
|
-
|
10
|
-
require 'helper'
|
11
|
-
|
12
|
-
class TestPp < MiniTest::Test
|
13
|
-
|
14
|
-
def test_patch
|
15
|
-
|
16
|
-
r = TestPrettyPrinter.from_file( 'at-austria/2014_15/1-bundesliga-ii' )
|
17
|
-
new_text, change_log = r.patch
|
18
|
-
|
19
|
-
puts new_text
|
20
|
-
|
21
|
-
pp change_log
|
22
|
-
|
23
|
-
|
24
|
-
p = SportDb::Patcher.new( "#{SportDb.test_data_path}/at-austria",
|
25
|
-
path: '/\d{4}_\d{2}/$',
|
26
|
-
names: 'bundesliga|el'
|
27
|
-
)
|
28
|
-
change_logs = p.patch # note: defaults to save=false (for now)
|
29
|
-
|
30
|
-
pp change_logs
|
31
|
-
|
32
|
-
assert true ## assume ok if we get here
|
33
|
-
end # method test_patch
|
34
|
-
|
35
|
-
end # class TestPp
|
data/test/test_reader.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_reader.rb
|
6
|
-
# or better
|
7
|
-
# rake -I ./lib test
|
8
|
-
|
9
|
-
|
10
|
-
require 'helper'
|
11
|
-
|
12
|
-
class TestReader < MiniTest::Test
|
13
|
-
|
14
|
-
def setup
|
15
|
-
WorldDb.delete!
|
16
|
-
SportDb.delete!
|
17
|
-
SportDb.read_builtin
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_bl
|
21
|
-
at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
|
22
|
-
|
23
|
-
teamreader = TestTeamReader.from_file( 'at-austria/teams', country_id: at.id )
|
24
|
-
teamreader.read()
|
25
|
-
|
26
|
-
leaguereader = TestLeagueReader.from_file( 'at-austria/leagues', country_id: at.id )
|
27
|
-
leaguereader.read()
|
28
|
-
|
29
|
-
## check/fix: is country_id more_attribs needed? why? why not?
|
30
|
-
gamereader = TestGameReader.from_file( 'at-austria/2013_14/bl', country_id: at.id )
|
31
|
-
gamereader.read()
|
32
|
-
|
33
|
-
bl = Event.find_by_key!( 'at.2013/14' )
|
34
|
-
|
35
|
-
assert_equal 10, bl.teams.count
|
36
|
-
assert_equal 36, bl.rounds.count
|
37
|
-
assert_equal 180, bl.games.count # 36x5 = 180
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
def test_game_reader
|
42
|
-
at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
|
43
|
-
|
44
|
-
teamreader = TestTeamReader.from_file( 'at-austria/teams', country_id: at.id )
|
45
|
-
teamreader.read()
|
46
|
-
teamreader = TestTeamReader.from_file( 'at-austria/teams_2', country_id: at.id )
|
47
|
-
teamreader.read()
|
48
|
-
|
49
|
-
austria = Team.find_by_key!( 'austria' )
|
50
|
-
rapid = Team.find_by_key!( 'rapid' )
|
51
|
-
sturm = Team.find_by_key!( 'sturm' )
|
52
|
-
|
53
|
-
assert_equal 'FK Austria Wien', austria.title
|
54
|
-
assert_equal 'SK Rapid Wien', rapid.title
|
55
|
-
assert_equal 'SK Sturm Graz', sturm.title
|
56
|
-
|
57
|
-
assert_equal 'AUS', austria.code
|
58
|
-
assert_equal 'RAP', rapid.code
|
59
|
-
assert_equal 'STU', sturm.code
|
60
|
-
|
61
|
-
leaguereader = TestLeagueReader.from_file( 'at-austria/leagues', country_id: at.id )
|
62
|
-
leaguereader.read()
|
63
|
-
|
64
|
-
at1 = League.find_by_key!( 'at' )
|
65
|
-
at2 = League.find_by_key!( 'at.2' )
|
66
|
-
atcup = League.find_by_key!( 'at.cup' )
|
67
|
-
|
68
|
-
assert_equal 'Österr. Bundesliga', at1.title
|
69
|
-
assert_equal 'Österr. Erste Liga', at2.title
|
70
|
-
assert_equal 'ÖFB Cup', atcup.title
|
71
|
-
|
72
|
-
## check/fix: is country_id more_attribs needed? why? why not?
|
73
|
-
gamereader = TestGameReader.from_file( 'at-austria/2013_14/bl', country_id: at.id )
|
74
|
-
gamereader.read()
|
75
|
-
gamereader = TestGameReader.from_file( 'at-austria/2013_14/el', country_id: at.id )
|
76
|
-
gamereader.read()
|
77
|
-
|
78
|
-
bl = Event.find_by_key!( 'at.2013/14' )
|
79
|
-
el = Event.find_by_key!( 'at.2.2013/14' )
|
80
|
-
|
81
|
-
assert_equal 10, bl.teams.count
|
82
|
-
assert_equal 36, bl.rounds.count
|
83
|
-
assert_equal 180, bl.games.count # 36x5 = 180
|
84
|
-
|
85
|
-
assert_equal 10, el.teams.count
|
86
|
-
end
|
87
|
-
|
88
|
-
end # class TestReader
|