sportdb-formats 1.0.5 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/Manifest.txt +8 -11
  3. data/Rakefile +1 -1
  4. data/lib/sportdb/formats.rb +19 -0
  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 +27 -7
  10. data/lib/sportdb/formats/league/league_reader.rb +7 -1
  11. data/lib/sportdb/formats/match/mapper.rb +63 -63
  12. data/lib/sportdb/formats/match/mapper_teams.rb +1 -1
  13. data/lib/sportdb/formats/match/match_parser.rb +141 -193
  14. data/lib/sportdb/formats/match/match_parser_csv.rb +169 -25
  15. data/lib/sportdb/formats/match/match_status_parser.rb +86 -0
  16. data/lib/sportdb/formats/name_helper.rb +4 -1
  17. data/lib/sportdb/formats/package.rb +57 -9
  18. data/lib/sportdb/formats/parser_helper.rb +11 -2
  19. data/lib/sportdb/formats/score/score_formats.rb +19 -0
  20. data/lib/sportdb/formats/score/score_parser.rb +10 -2
  21. data/lib/sportdb/formats/season_utils.rb +0 -11
  22. data/lib/sportdb/formats/structs/group.rb +5 -12
  23. data/lib/sportdb/formats/structs/match.rb +7 -1
  24. data/lib/sportdb/formats/structs/round.rb +6 -13
  25. data/lib/sportdb/formats/structs/season.rb +114 -45
  26. data/lib/sportdb/formats/structs/standings.rb +30 -9
  27. data/lib/sportdb/formats/structs/team.rb +8 -2
  28. data/lib/sportdb/formats/team/club_index.rb +13 -11
  29. data/lib/sportdb/formats/team/club_index_history.rb +138 -0
  30. data/lib/sportdb/formats/team/club_reader_history.rb +203 -0
  31. data/lib/sportdb/formats/team/club_reader_props.rb +2 -3
  32. data/lib/sportdb/formats/version.rb +2 -2
  33. data/test/helper.rb +48 -81
  34. data/test/test_club_index_history.rb +107 -0
  35. data/test/test_club_reader_history.rb +212 -0
  36. data/test/test_country_reader.rb +2 -2
  37. data/test/test_datafile_package.rb +1 -1
  38. data/test/test_match_status_parser.rb +49 -0
  39. data/test/test_regex.rb +25 -7
  40. data/test/test_scores.rb +2 -0
  41. data/test/test_season.rb +68 -19
  42. metadata +12 -15
  43. data/test/test_conf.rb +0 -65
  44. data/test/test_csv_match_parser.rb +0 -114
  45. data/test/test_csv_match_parser_utils.rb +0 -20
  46. data/test/test_match_auto.rb +0 -72
  47. data/test/test_match_auto_champs.rb +0 -45
  48. data/test/test_match_auto_euro.rb +0 -37
  49. data/test/test_match_auto_worldcup.rb +0 -61
  50. data/test/test_match_champs.rb +0 -27
  51. data/test/test_match_eng.rb +0 -26
  52. data/test/test_match_euro.rb +0 -27
  53. 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
-
@@ -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,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