sportdb-formats 1.0.6 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/Manifest.txt +6 -33
  3. data/Rakefile +2 -5
  4. data/lib/sportdb/formats.rb +54 -70
  5. data/lib/sportdb/formats/country/country_index.rb +2 -2
  6. data/lib/sportdb/formats/event/event_index.rb +141 -0
  7. data/lib/sportdb/formats/event/event_reader.rb +183 -0
  8. data/lib/sportdb/formats/league/league_index.rb +22 -18
  9. data/lib/sportdb/formats/league/league_outline_reader.rb +45 -13
  10. data/lib/sportdb/formats/league/league_reader.rb +7 -1
  11. data/lib/sportdb/formats/match/match_parser.rb +101 -111
  12. data/lib/sportdb/formats/package.rb +59 -11
  13. data/lib/sportdb/formats/parser_helper.rb +11 -2
  14. data/lib/sportdb/formats/team/club_index.rb +13 -11
  15. data/lib/sportdb/formats/team/club_index_history.rb +134 -0
  16. data/lib/sportdb/formats/team/club_reader_history.rb +203 -0
  17. data/lib/sportdb/formats/team/club_reader_props.rb +20 -5
  18. data/lib/sportdb/formats/version.rb +2 -2
  19. data/test/helper.rb +51 -81
  20. data/test/test_club_index_history.rb +107 -0
  21. data/test/test_club_reader_history.rb +212 -0
  22. data/test/test_datafile_package.rb +1 -1
  23. data/test/test_regex.rb +25 -7
  24. metadata +9 -78
  25. data/lib/sportdb/formats/config.rb +0 -40
  26. data/lib/sportdb/formats/match/match_parser_csv.rb +0 -314
  27. data/lib/sportdb/formats/name_helper.rb +0 -84
  28. data/lib/sportdb/formats/score/score_formats.rb +0 -220
  29. data/lib/sportdb/formats/score/score_parser.rb +0 -202
  30. data/lib/sportdb/formats/season_utils.rb +0 -27
  31. data/lib/sportdb/formats/structs/country.rb +0 -31
  32. data/lib/sportdb/formats/structs/group.rb +0 -18
  33. data/lib/sportdb/formats/structs/league.rb +0 -37
  34. data/lib/sportdb/formats/structs/match.rb +0 -151
  35. data/lib/sportdb/formats/structs/matchlist.rb +0 -220
  36. data/lib/sportdb/formats/structs/round.rb +0 -25
  37. data/lib/sportdb/formats/structs/season.rb +0 -123
  38. data/lib/sportdb/formats/structs/standings.rb +0 -247
  39. data/lib/sportdb/formats/structs/team.rb +0 -150
  40. data/lib/sportdb/formats/structs/team_usage.rb +0 -88
  41. data/test/test_clubs.rb +0 -40
  42. data/test/test_conf.rb +0 -65
  43. data/test/test_csv_match_parser.rb +0 -114
  44. data/test/test_csv_match_parser_utils.rb +0 -20
  45. data/test/test_csv_reader.rb +0 -31
  46. data/test/test_match.rb +0 -30
  47. data/test/test_match_auto.rb +0 -72
  48. data/test/test_match_auto_champs.rb +0 -45
  49. data/test/test_match_auto_euro.rb +0 -37
  50. data/test/test_match_auto_worldcup.rb +0 -61
  51. data/test/test_match_champs.rb +0 -27
  52. data/test/test_match_eng.rb +0 -26
  53. data/test/test_match_euro.rb +0 -27
  54. data/test/test_match_worldcup.rb +0 -27
  55. data/test/test_name_helper.rb +0 -67
  56. data/test/test_scores.rb +0 -122
  57. data/test/test_season.rb +0 -62
@@ -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,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
@@ -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
@@ -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
@@ -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,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
@@ -1,67 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_name_helper.rb
6
-
7
-
8
- require 'helper'
9
-
10
-
11
- class TestNameHelper < MiniTest::Test
12
-
13
- include SportDb::NameHelper
14
-
15
-
16
- def test_strip_norm ## strip (remove) non-norm characters e.g. ()'- etc.
17
- [['Estudiantes (LP)', 'Estudiantes LP'],
18
- ['Central Córdoba (SdE)', 'Central Córdoba SdE'],
19
- ['Saint Patrick’s Athletic FC', 'Saint Patricks Athletic FC'],
20
- ['Myllykosken Pallo −47', 'Myllykosken Pallo 47'],
21
- ].each do |rec|
22
- assert_equal rec[1], strip_norm( rec[0] )
23
- end
24
- end
25
-
26
- def test_strip_year
27
- [['A (1911-1912)', 'A'],
28
- ['B (1911-1912, 1913-1915)', 'B'],
29
- ['C (1911-___)', 'C'],
30
- ['D (1911-???)', 'D'],
31
- ['FC Linz (1946-2001, 2013-)', 'FC Linz'],
32
- ['Admira Wien (-????)', 'Admira Wien'],
33
- ['Admira Wien (-____)', 'Admira Wien'],
34
- ].each do |rec|
35
- assert_equal rec[1], strip_year( rec[0] )
36
- end
37
- end
38
-
39
- def test_strip_lang
40
- [['Bayern Munich [en]', 'Bayern Munich'],
41
- ].each do |rec|
42
- assert_equal rec[1], strip_lang( rec[0] )
43
- end
44
- end
45
-
46
-
47
- def test_variants
48
- ## hungarian
49
- assert_equal ['Raba ETO Gyor'], variants( 'Rába ETO Győr' )
50
- assert_equal ['Raba ETO Gyor', 'Rába ETO Gyoer'], variants( 'Rába ETO Györ' )
51
-
52
- ## romanian
53
- assert_equal ['Targu Mures'], variants( 'Târgu Mureș' )
54
- assert_equal ['Targu Mures'], variants( 'Târgu Mureş' )
55
- end
56
-
57
-
58
- =begin
59
- ### fix: move to ClubReader!!!!! not for general use
60
- def test_wiki
61
- assert_equal 'FC Wacker Innsbruck', strip_wiki( 'FC Wacker Innsbruck (2002)' )
62
- assert_equal 'SK Austria Klagenfurt', strip_wiki( 'SK Austria Klagenfurt (2007)' )
63
-
64
- assert_equal 'Willem II', strip_wiki( 'Willem II (football club)' )
65
- end
66
- =end
67
- end # class TestNameHelper
@@ -1,122 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_scores.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestScores < MiniTest::Test
11
-
12
- def test_de
13
- ScoreFormats.lang = :de
14
- data = [
15
- [ '10:0', [nil,nil, 10,0]],
16
- [ '1:22', [nil,nil, 1,22]],
17
- [ '1-22', [nil,nil, 1,22]],
18
-
19
- ## do not support three digits for now - why? why not?
20
- [ '1:222', []],
21
- [ '111:0', []],
22
- [ '1-222', []],
23
- [ '111-0', []],
24
-
25
- [ '2:2 (1:1, 1:0) n.V. 5:1 i.E.', [1,0, 1,1, 2,2, 5,1]],
26
- [ '2:2 (1:1, 1:0) n.V.', [1,0, 1,1, 2,2]],
27
- [ '2:2 (1:1, ) n.V. 5:1 i.E.', [nil,nil, 1,1, 2,2, 5,1]],
28
- [ '2:2 (1:1, ) n.V.', [nil,nil, 1,1, 2,2]],
29
-
30
- [ '2:2 (1:1) n.V. 5:1 i.E.', [nil,nil, 1,1, 2,2, 5,1]],
31
- [ '2:2 (1:1) n.V.', [nil,nil, 1,1, 2,2]],
32
-
33
- [ '2-2 (1-1, 1-0) n.V. 5-1 i.E.', [1,0, 1,1, 2,2, 5,1]],
34
- [ '2-2 (1-1, 1-0) n.V.', [1,0, 1,1, 2,2]],
35
- [ '2-2 (1-1, ) n.V. 5-1 i.E.', [nil,nil, 1,1, 2,2, 5,1]],
36
- [ '2-2 (1-1, ) n.V.', [nil,nil, 1,1, 2,2]],
37
-
38
- [ '2 : 2 ( 1 : 1 , 1 : 0 ) n.V. 5 : 1 i.E.', [1,0, 1,1, 2,2, 5,1]],
39
- [ '2 : 2 ( 1 : 1 , 1 : 0 ) n.V.', [1,0, 1,1, 2,2]],
40
- [ '2 : 2 ( 1 : 1 , ) n.V. 5 : 1 i.E.', [nil,nil, 1,1, 2,2, 5,1]],
41
- [ '2 : 2 ( 1 : 1 , ) n.V.', [nil,nil, 1,1, 2,2]],
42
-
43
- ## alternate format
44
- ['i.E. 2:4, n.V. 3:3 (1:1, 1:0)', [1,0, 1,1, 3,3, 2,4]],
45
- ['iE 2:4 nV 3:3 (1:1, 1:0)', [1,0, 1,1, 3,3, 2,4]],
46
- ['i.E. 2:4 n.V. 3:3 (1:1, 1:0)', [1,0, 1,1, 3,3, 2,4]],
47
- ['i.E. 2:4, n.V. 3:3 (1:1)', [nil, nil, 1,1, 3,3, 2,4]],
48
- ['i.E. 2:4 n.V. 3:3 (1:1)', [nil, nil, 1,1, 3,3, 2,4]],
49
- ['n.V. 3:2 (2:2, 1:2)', [1,2, 2,2, 3,2]],
50
- ['n.V. 3:2 (2:2)', [nil, nil, 2,2, 3,2]],
51
- ]
52
-
53
- assert_score( data )
54
- end
55
-
56
- def test_en
57
- ScoreFormats.lang = :en
58
-
59
- data = [
60
- [ '1-22', [nil,nil, 1, 22]],
61
- [ '1x22', [nil,nil, 1, 22]],
62
- [ '1X22', [nil,nil, 1,22]],
63
-
64
- ## do not support three digits for now - why? why not?
65
- [ '1-222', []],
66
- [ '111-0', []],
67
- [ '111x0', []],
68
- [ '111X0', []],
69
-
70
- ## do not support colon sep for now in en locale - why? why not?
71
- [ '2:1', []],
72
- [ '2:1 (1:1)', []],
73
-
74
-
75
- [ '2-1 (1-1)', [1,1, 2,1]],
76
- [ '2x1 (1x1)', [1,1, 2,1]],
77
- [ '2X1 (1X1)', [1,1, 2,1]],
78
-
79
- [ '2-1 a.e.t. (1-1, 0-0)', [0,0, 1,1, 2,1]],
80
- [ '2-1aet (1-1, 0-0)', [0,0, 1,1, 2,1]],
81
- [ '2-1 A.E.T. (1-1, 0-0)', [0,0, 1,1, 2,1]],
82
- [ '2-1AET (1-1, 0-0)', [0,0, 1,1, 2,1]],
83
-
84
- [ '3-4 pen. 2-2 a.e.t. (1-1, 1-1)', [1,1, 1,1, 2,2, 3,4]],
85
- [ '3-4 pen 2-2 a.e.t. (1-1, 1-1)', [1,1, 1,1, 2,2, 3,4]],
86
- [ '3-4 pen 2-2 a.e.t. (1-1, 1-1)', [1,1, 1,1, 2,2, 3,4]],
87
- [ '3-4p 2-2aet (1-1, 1-1)', [1,1, 1,1, 2,2, 3,4]],
88
- [ '3-4PSO 2-2AET (1-1, 1-1)', [1,1, 1,1, 2,2, 3,4]],
89
-
90
- [ '4-3 pen. 1-0 a.e.t. (1-0, )', [nil,nil, 1,0, 1,0, 4,3]],
91
- [ '3-4 pen. 2-1 a.e.t. (2-1, )', [nil,nil, 2,1, 2,1, 3,4]],
92
- [ '4-1 a.e.t. (3-1, )', [nil,nil, 3,1, 4,1]],
93
- [ '3-4aet (1-1,)', [nil,nil, 1,1, 3,4]],
94
- [ '3-4 a.e.t. (1-1,)', [nil,nil, 1,1, 3,4]],
95
-
96
- [ '4-3 pen. 1-0 a.e.t. (1-0)', [nil,nil, 1,0, 1,0, 4,3]],
97
- [ '3-4 pen. 2-1 a.e.t. (2-1)', [nil,nil, 2,1, 2,1, 3,4]],
98
- [ '4-1 a.e.t. (3-1)', [nil,nil, 3,1, 4,1]],
99
- [ '3-4aet (1-1)', [nil,nil, 1,1, 3,4]],
100
- [ '3-4 a.e.t. (1-1)', [nil,nil, 1,1, 3,4]],
101
-
102
- [ '3-1 pen (1-1)', [nil,nil, 1,1, nil, nil, 3,1]],
103
-
104
- ## try with more "liberal" spaces
105
- [ '2 - 1 ( 1 - 1 )', [1,1, 2,1]],
106
- [ '2 - 1 a.e.t. ( 1 - 1 , 0 - 0 )', [0,0, 1,1, 2,1]],
107
- [ '4 - 1 a.e.t. ( 3 - 1, )', [nil,nil, 3,1, 4,1]],
108
- ]
109
-
110
- assert_score( data )
111
- end
112
-
113
- private
114
- def assert_score( data )
115
- data.each do |rec|
116
- line = rec[0].dup
117
- exp = rec[1]
118
-
119
- assert_equal exp, ScoreFormats.find!( line ).to_a, "failed >#{rec[0]}< - >#{line}<"
120
- end
121
- end
122
- end # class TestScores