sportdb-formats 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +6 -13
- data/Rakefile +1 -1
- data/lib/sportdb/formats.rb +5 -0
- data/lib/sportdb/formats/country/country_index.rb +2 -2
- data/lib/sportdb/formats/event/event_index.rb +9 -11
- data/lib/sportdb/formats/league/league_index.rb +22 -18
- data/lib/sportdb/formats/league/league_outline_reader.rb +4 -1
- data/lib/sportdb/formats/league/league_reader.rb +7 -1
- data/lib/sportdb/formats/match/match_parser.rb +27 -15
- data/lib/sportdb/formats/match/match_parser_csv.rb +148 -21
- data/lib/sportdb/formats/match/match_status_parser.rb +86 -0
- data/lib/sportdb/formats/name_helper.rb +4 -1
- data/lib/sportdb/formats/package.rb +30 -8
- data/lib/sportdb/formats/score/score_formats.rb +19 -0
- data/lib/sportdb/formats/score/score_parser.rb +4 -2
- data/lib/sportdb/formats/structs/match.rb +2 -0
- data/lib/sportdb/formats/structs/team.rb +7 -0
- data/lib/sportdb/formats/team/club_index.rb +13 -11
- data/lib/sportdb/formats/team/club_index_history.rb +138 -0
- data/lib/sportdb/formats/team/club_reader_history.rb +203 -0
- data/lib/sportdb/formats/team/club_reader_props.rb +2 -3
- data/lib/sportdb/formats/version.rb +1 -1
- data/test/helper.rb +47 -81
- data/test/test_club_index_history.rb +107 -0
- data/test/test_club_reader_history.rb +212 -0
- data/test/test_datafile_package.rb +1 -1
- data/test/test_match_status_parser.rb +49 -0
- data/test/test_scores.rb +2 -0
- metadata +10 -17
- data/test/test_conf.rb +0 -65
- data/test/test_csv_match_parser.rb +0 -114
- data/test/test_csv_match_parser_utils.rb +0 -20
- data/test/test_match_auto.rb +0 -72
- data/test/test_match_auto_champs.rb +0 -45
- data/test/test_match_auto_euro.rb +0 -37
- data/test/test_match_auto_relegation.rb +0 -41
- data/test/test_match_auto_worldcup.rb +0 -61
- data/test/test_match_champs.rb +0 -27
- data/test/test_match_eng.rb +0 -26
- data/test/test_match_euro.rb +0 -27
- data/test/test_match_start_date.rb +0 -44
- data/test/test_match_worldcup.rb +0 -27
@@ -1,20 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_csv_match_parser_utils.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
class TestCsvMatchParserUtils < MiniTest::Test
|
11
|
-
|
12
|
-
def test_find_seasons
|
13
|
-
pp = SportDb::CsvMatchParser.find_seasons( "#{SportDb::Test.data_dir}/dl/AUT.csv" ) ## defaults to col: 'Season', col_sep: ','
|
14
|
-
pp = SportDb::CsvMatchParser.find_seasons( "#{SportDb::Test.data_dir}/dl/Bundesliga_1963_2014.csv", col: 'Saison', sep: ';' )
|
15
|
-
assert true
|
16
|
-
end
|
17
|
-
|
18
|
-
end # class TestCsvMatchParserUtils
|
19
|
-
|
20
|
-
|
data/test/test_match_auto.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_match_auto.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
|
11
|
-
class TestMatchAuto < MiniTest::Test
|
12
|
-
|
13
|
-
def test_pt
|
14
|
-
txt, exp = read_test( 'match_auto/pt/br.txt' )
|
15
|
-
|
16
|
-
teams, rounds = parse_auto_conf( txt, lang: 'pt' )
|
17
|
-
|
18
|
-
assert_equal exp['teams'], teams.deep_stringify_keys
|
19
|
-
assert_equal exp['rounds'], rounds.deep_stringify_keys
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
def test_de
|
24
|
-
txt, exp = read_test( 'match_auto/de/at.txt' )
|
25
|
-
|
26
|
-
teams, rounds = parse_auto_conf( txt, lang: 'de' )
|
27
|
-
|
28
|
-
assert_equal exp['teams'], teams.deep_stringify_keys
|
29
|
-
assert_equal exp['rounds'], rounds.deep_stringify_keys
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_es
|
33
|
-
%w[match_auto/es/es.txt
|
34
|
-
match_auto/es/mx.txt
|
35
|
-
].each do |path|
|
36
|
-
txt, exp = read_test( path )
|
37
|
-
|
38
|
-
puts "testing match auto conf #{path}..."
|
39
|
-
teams, rounds = parse_auto_conf( txt, lang: 'es' )
|
40
|
-
|
41
|
-
assert_equal exp['teams'], teams.deep_stringify_keys
|
42
|
-
assert_equal exp['rounds'], rounds.deep_stringify_keys
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
def test_fr
|
48
|
-
txt, exp = read_test( 'match_auto/fr/fr.txt' )
|
49
|
-
|
50
|
-
teams, rounds = parse_auto_conf( txt, lang: 'fr' )
|
51
|
-
|
52
|
-
assert_equal exp['teams'], teams.deep_stringify_keys
|
53
|
-
assert_equal exp['rounds'], rounds.deep_stringify_keys
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
def test_en
|
58
|
-
%w[match_auto/eng.txt
|
59
|
-
match_auto/eng_ii.txt
|
60
|
-
match_auto/mu.txt
|
61
|
-
].each do |path|
|
62
|
-
txt, exp = read_test( path )
|
63
|
-
|
64
|
-
puts "testing match auto conf #{path}..."
|
65
|
-
teams, rounds = parse_auto_conf( txt )
|
66
|
-
|
67
|
-
assert_equal exp['teams'], teams.deep_stringify_keys
|
68
|
-
assert_equal exp['rounds'], rounds.deep_stringify_keys
|
69
|
-
end
|
70
|
-
end # method test_parse
|
71
|
-
|
72
|
-
end # class TestMatchAuto
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_match_auto_champs.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
|
11
|
-
class TestMatchAutoChamps < MiniTest::Test
|
12
|
-
|
13
|
-
def test_champs_group
|
14
|
-
txt, exp = read_test( 'match_auto/champs_group.txt')
|
15
|
-
|
16
|
-
teams, rounds, groups, round_defs, group_defs = parse_auto_conf( txt, lang: 'en' )
|
17
|
-
|
18
|
-
assert_equal exp['teams'], teams.deep_stringify_keys
|
19
|
-
assert_equal exp['rounds'], rounds.deep_stringify_keys
|
20
|
-
assert_equal exp['groups'], groups.deep_stringify_keys
|
21
|
-
|
22
|
-
puts "teams:"
|
23
|
-
pp teams
|
24
|
-
puts "rounds:"
|
25
|
-
pp rounds
|
26
|
-
puts "groups:"
|
27
|
-
pp groups
|
28
|
-
puts "round defs:"
|
29
|
-
pp round_defs
|
30
|
-
puts "group defs:"
|
31
|
-
pp group_defs
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_champs_finals
|
35
|
-
txt, exp = read_test( 'match_auto/champs_finals.txt')
|
36
|
-
|
37
|
-
teams, rounds = parse_auto_conf( txt, lang: 'en' )
|
38
|
-
|
39
|
-
assert_equal exp['teams'], teams.deep_stringify_keys
|
40
|
-
assert_equal exp['rounds'], rounds.deep_stringify_keys
|
41
|
-
|
42
|
-
pp teams
|
43
|
-
pp rounds
|
44
|
-
end
|
45
|
-
end # class TestMatchAutChamps
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_match_auto_euro.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
|
11
|
-
class TestMatchAutoEuro < MiniTest::Test
|
12
|
-
|
13
|
-
def test_euro_2016
|
14
|
-
txt, exp = read_test( 'match_auto/euro_2016.txt')
|
15
|
-
|
16
|
-
teams, rounds, groups, round_defs, group_defs = parse_auto_conf( txt, lang: 'en' )
|
17
|
-
|
18
|
-
# puts JSON.pretty_generate( { teams: teams,
|
19
|
-
# rounds: rounds,
|
20
|
-
# groups: groups } )
|
21
|
-
|
22
|
-
assert_equal exp['teams'], teams.deep_stringify_keys
|
23
|
-
assert_equal exp['rounds'], rounds.deep_stringify_keys
|
24
|
-
assert_equal exp['groups'], groups.deep_stringify_keys
|
25
|
-
|
26
|
-
puts "teams:"
|
27
|
-
pp teams
|
28
|
-
puts "rounds:"
|
29
|
-
pp rounds
|
30
|
-
puts "groups:"
|
31
|
-
pp groups
|
32
|
-
puts "round defs:"
|
33
|
-
pp round_defs
|
34
|
-
puts "group defs:"
|
35
|
-
pp group_defs
|
36
|
-
end
|
37
|
-
end # class TestMatchAutoEuro
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_match_auto_relegation.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
|
11
|
-
class TestMatchAutoRelegation < MiniTest::Test
|
12
|
-
|
13
|
-
def test_rel
|
14
|
-
txt = <<TXT
|
15
|
-
Hinspiel
|
16
|
-
[31.5.]
|
17
|
-
SC Wiener Neustadt 0-2 SKN St. Pölten
|
18
|
-
|
19
|
-
Rückspiel
|
20
|
-
[3.6.]
|
21
|
-
SKN St. Pölten 1-1 SC Wiener Neustadt
|
22
|
-
TXT
|
23
|
-
|
24
|
-
start = Date.new( 2017, 7, 1 )
|
25
|
-
SportDb::Import.config.lang = 'de'
|
26
|
-
|
27
|
-
teams, rounds, groups, round_defs, group_defs = SportDb::AutoConfParser.parse( txt, start: start )
|
28
|
-
|
29
|
-
puts "teams:"
|
30
|
-
pp teams
|
31
|
-
puts "rounds:"
|
32
|
-
pp rounds
|
33
|
-
puts "groups:"
|
34
|
-
pp groups
|
35
|
-
puts "round defs:"
|
36
|
-
pp round_defs
|
37
|
-
puts "group defs:"
|
38
|
-
pp group_defs
|
39
|
-
end
|
40
|
-
|
41
|
-
end # class TestMatchAutoRelegation
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_match_auto_worldcup.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
|
11
|
-
class TestMatchAutoWorldCup < MiniTest::Test
|
12
|
-
|
13
|
-
def test_2018
|
14
|
-
txt, exp = read_test( 'match_auto/worldcup_2018.txt')
|
15
|
-
|
16
|
-
start = Date.new( 2018, 1, 1 )
|
17
|
-
|
18
|
-
teams, rounds, groups, round_defs, group_defs = parse_auto_conf( txt, lang: 'en', start: start )
|
19
|
-
|
20
|
-
# puts JSON.pretty_generate( { teams: teams,
|
21
|
-
# rounds: rounds,
|
22
|
-
# groups: groups } )
|
23
|
-
|
24
|
-
assert_equal exp['teams'], teams.deep_stringify_keys
|
25
|
-
assert_equal exp['groups'], groups.deep_stringify_keys
|
26
|
-
|
27
|
-
puts "teams:"
|
28
|
-
pp teams
|
29
|
-
puts "rounds:"
|
30
|
-
pp rounds
|
31
|
-
puts "groups:"
|
32
|
-
pp groups
|
33
|
-
puts "round defs:"
|
34
|
-
pp round_defs
|
35
|
-
puts "group defs:"
|
36
|
-
pp group_defs
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_2018_finals
|
40
|
-
txt, exp = read_test( 'match_auto/worldcup_2018_finals.txt')
|
41
|
-
|
42
|
-
start = Date.new( 2018, 1, 1 )
|
43
|
-
|
44
|
-
teams, rounds, groups, round_defs, group_defs = parse_auto_conf( txt, lang: 'en', start: start )
|
45
|
-
|
46
|
-
assert_equal exp['teams'], teams.deep_stringify_keys
|
47
|
-
assert_equal exp['rounds'], rounds.deep_stringify_keys
|
48
|
-
|
49
|
-
puts "teams:"
|
50
|
-
pp teams
|
51
|
-
puts "rounds:"
|
52
|
-
pp rounds
|
53
|
-
puts "groups:"
|
54
|
-
pp groups
|
55
|
-
puts "round defs:"
|
56
|
-
pp round_defs
|
57
|
-
puts "group defs:"
|
58
|
-
pp group_defs
|
59
|
-
end
|
60
|
-
|
61
|
-
end # class TestMatchAutoWorldCup
|
data/test/test_match_champs.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_match_champs.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
|
11
|
-
class TestMatchChamps < MiniTest::Test
|
12
|
-
|
13
|
-
def test_parse
|
14
|
-
txt, exp, teams = read_test( 'match/champs_group.txt' )
|
15
|
-
|
16
|
-
start = Date.new( 2017, 7, 1 )
|
17
|
-
|
18
|
-
SportDb::Import.config.lang = 'en'
|
19
|
-
|
20
|
-
parser = SportDb::MatchParser.new( txt, teams, start )
|
21
|
-
matches, rounds, groups = parser.parse
|
22
|
-
|
23
|
-
pp rounds
|
24
|
-
pp groups
|
25
|
-
pp matches[-1] ## only dump last record for now
|
26
|
-
end # method test_parse
|
27
|
-
end # class TestMatchChamps
|
data/test/test_match_eng.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_match_eng.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
|
11
|
-
class TestMatchEng < MiniTest::Test
|
12
|
-
|
13
|
-
def test_eng
|
14
|
-
txt, exp, teams = read_test( 'match/eng.txt' )
|
15
|
-
|
16
|
-
SportDb::Import.config.lang = 'en'
|
17
|
-
|
18
|
-
start = Date.new( 2017, 7, 1 )
|
19
|
-
|
20
|
-
parser = SportDb::MatchParser.new( txt, teams, start )
|
21
|
-
matches, rounds = parser.parse
|
22
|
-
|
23
|
-
pp rounds
|
24
|
-
pp matches[-1] ## only dump last record for now
|
25
|
-
end # method test_end
|
26
|
-
end # class TestMatchEng
|
data/test/test_match_euro.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_match_euro.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
|
11
|
-
class TestMatchEuro < MiniTest::Test
|
12
|
-
|
13
|
-
def test_parse
|
14
|
-
txt, exp, teams = read_test( 'match/euro_2016.txt' )
|
15
|
-
|
16
|
-
start = Date.new( 2016, 1, 1 )
|
17
|
-
|
18
|
-
SportDb::Import.config.lang = 'en'
|
19
|
-
|
20
|
-
parser = SportDb::MatchParser.new( txt, teams, start )
|
21
|
-
matches, rounds, groups = parser.parse
|
22
|
-
|
23
|
-
pp rounds
|
24
|
-
pp groups
|
25
|
-
pp matches[-1] ## only dump last record for now
|
26
|
-
end # method test_parse
|
27
|
-
end # class TestMatchEuro
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_match_start_date.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
|
11
|
-
class TestMatchStart < MiniTest::Test
|
12
|
-
|
13
|
-
def test_eng
|
14
|
-
txt =<<TXT
|
15
|
-
Matchday 1
|
16
|
-
[Aug 2]
|
17
|
-
A - B
|
18
|
-
Matchday 2
|
19
|
-
[Jan 3]
|
20
|
-
A - B
|
21
|
-
Matchday 3
|
22
|
-
[Aug 4]
|
23
|
-
A - B
|
24
|
-
TXT
|
25
|
-
|
26
|
-
teams =<<TXT
|
27
|
-
A
|
28
|
-
B
|
29
|
-
TXT
|
30
|
-
SportDb::Import.config.lang = 'en'
|
31
|
-
|
32
|
-
start = Date.new( 2017, 7, 1 )
|
33
|
-
|
34
|
-
parser = SportDb::MatchParser.new( txt, teams, start )
|
35
|
-
matches, rounds = parser.parse
|
36
|
-
|
37
|
-
pp rounds
|
38
|
-
pp matches ## only dump last record for now
|
39
|
-
|
40
|
-
assert_equal Date.new( 2017, 8, 2), matches[0].date
|
41
|
-
assert_equal Date.new( 2018, 1, 3), matches[1].date
|
42
|
-
assert_equal Date.new( 2018, 8, 4), matches[2].date
|
43
|
-
end # method test_end
|
44
|
-
end # class TestMatchStart
|
data/test/test_match_worldcup.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_match_worldcup.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
|
11
|
-
class TestMatchWorld < MiniTest::Test
|
12
|
-
|
13
|
-
def test_parse
|
14
|
-
txt, exp, teams = read_test( 'match/worldcup_2018_finals.txt' )
|
15
|
-
|
16
|
-
start = Date.new( 2018, 1, 1 )
|
17
|
-
|
18
|
-
SportDb::Import.config.lang = 'en'
|
19
|
-
|
20
|
-
parser = SportDb::MatchParser.new( txt, teams, start )
|
21
|
-
matches, rounds, groups = parser.parse
|
22
|
-
|
23
|
-
pp rounds
|
24
|
-
pp groups
|
25
|
-
pp matches[-1] ## only dump last record for now
|
26
|
-
end # method test_parse
|
27
|
-
end # class TestMatchWorld
|