sportdb-formats 0.4.0 → 1.0.0

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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/Manifest.txt +24 -4
  3. data/Rakefile +3 -3
  4. data/lib/sportdb/formats.rb +25 -2
  5. data/lib/sportdb/formats/config.rb +40 -0
  6. data/lib/sportdb/formats/datafile.rb +42 -62
  7. data/lib/sportdb/formats/datafile_package.rb +160 -0
  8. data/lib/sportdb/formats/match/conf_parser.rb +120 -0
  9. data/lib/sportdb/formats/match/mapper.rb +319 -0
  10. data/lib/sportdb/formats/match/mapper_teams.rb +23 -0
  11. data/lib/sportdb/formats/match/match_parser.rb +659 -0
  12. data/lib/sportdb/formats/match/match_parser_auto_conf.rb +202 -0
  13. data/lib/sportdb/formats/name_helper.rb +84 -0
  14. data/lib/sportdb/formats/outline_reader.rb +53 -15
  15. data/lib/sportdb/formats/package.rb +172 -160
  16. data/lib/sportdb/formats/parser_helper.rb +81 -0
  17. data/lib/sportdb/formats/score/score_formats.rb +180 -0
  18. data/lib/sportdb/formats/score/score_parser.rb +196 -0
  19. data/lib/sportdb/formats/structs/country.rb +1 -43
  20. data/lib/sportdb/formats/structs/group.rb +25 -0
  21. data/lib/sportdb/formats/structs/league.rb +7 -26
  22. data/lib/sportdb/formats/structs/match.rb +72 -51
  23. data/lib/sportdb/formats/structs/round.rb +14 -4
  24. data/lib/sportdb/formats/structs/season.rb +3 -0
  25. data/lib/sportdb/formats/structs/team.rb +144 -0
  26. data/lib/sportdb/formats/version.rb +2 -2
  27. data/test/helper.rb +83 -1
  28. data/test/test_clubs.rb +3 -3
  29. data/test/test_conf.rb +65 -0
  30. data/test/test_datafile.rb +21 -30
  31. data/test/test_match.rb +0 -6
  32. data/test/test_match_auto.rb +72 -0
  33. data/test/test_match_auto_champs.rb +45 -0
  34. data/test/test_match_auto_euro.rb +37 -0
  35. data/test/test_match_auto_worldcup.rb +61 -0
  36. data/test/test_match_champs.rb +27 -0
  37. data/test/test_match_eng.rb +26 -0
  38. data/test/test_match_euro.rb +27 -0
  39. data/test/test_match_worldcup.rb +27 -0
  40. data/test/test_name_helper.rb +67 -0
  41. data/test/test_outline_reader.rb +3 -3
  42. data/test/test_package.rb +21 -2
  43. data/test/test_package_match.rb +78 -0
  44. data/test/test_scores.rb +67 -51
  45. metadata +32 -12
  46. data/lib/sportdb/formats/scores.rb +0 -253
  47. data/lib/sportdb/formats/structs/club.rb +0 -213
  48. data/test/test_club_helpers.rb +0 -63
  49. data/test/test_datafile_match.rb +0 -65
@@ -1,63 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_club_helpers.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestClubHelpers < MiniTest::Test
11
-
12
- Club = SportDb::Import::Club
13
-
14
- def strip_norm( name ) Club.strip_norm( name ); end
15
- def strip_lang( name ) Club.strip_lang( name ); end
16
- def strip_year( name ) Club.strip_year( name ); end
17
- def strip_wiki( name ) Club.strip_wiki( name ); end
18
-
19
-
20
-
21
- def test_norm ## strip (remove) non-norm characters e.g. ()'- etc.
22
- [
23
- ['Estudiantes (LP)', 'Estudiantes LP'],
24
- ['Central Córdoba (SdE)', 'Central Córdoba SdE'],
25
- ['Saint Patrick’s Athletic FC', 'Saint Patricks Athletic FC'],
26
- ['Myllykosken Pallo −47', 'Myllykosken Pallo 47'],
27
- ].each do |rec|
28
- assert_equal rec[1], strip_norm( rec[0] )
29
- end
30
- end
31
-
32
- def test_variants
33
- ## hungarian
34
- assert_equal ['Raba ETO Gyor'], Variant.find( 'Rába ETO Győr' )
35
- assert_equal ['Raba ETO Gyor', 'Rába ETO Gyoer'], Variant.find( 'Rába ETO Györ' )
36
-
37
- ## romanian
38
- assert_equal ['Targu Mures'], Variant.find( 'Târgu Mureș' )
39
- assert_equal ['Targu Mures'], Variant.find( 'Târgu Mureş' )
40
- end
41
-
42
-
43
-
44
-
45
- def test_lang
46
- assert_equal 'Bayern Munich', strip_lang( 'Bayern Munich [en]' )
47
- end
48
-
49
- def test_year
50
- assert_equal 'FC Linz', strip_year( 'FC Linz (1946-2001, 2013-)' )
51
-
52
- assert_equal 'Admira Wien', strip_year( 'Admira Wien (-????)' )
53
- assert_equal 'Admira Wien', strip_year( 'Admira Wien (-____)' )
54
- end
55
-
56
-
57
- def test_wiki
58
- assert_equal 'FC Wacker Innsbruck', strip_wiki( 'FC Wacker Innsbruck (2002)' )
59
- assert_equal 'SK Austria Klagenfurt', strip_wiki( 'SK Austria Klagenfurt (2007)' )
60
-
61
- assert_equal 'Willem II', strip_wiki( 'Willem II (football club)' )
62
- end
63
- end # class TestClubHelpers
@@ -1,65 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_datafile_match.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestDatafileMatch < MiniTest::Test
11
-
12
- def match_clubs( txt ) Datafile.match_clubs( txt ); end
13
- def match_clubs_wiki( txt ) Datafile.match_clubs_wiki( txt ); end
14
- def match_leagues( txt ) Datafile.match_leagues( txt ); end
15
- def match_conf( txt ) Datafile.match_conf( txt ); end
16
-
17
-
18
- CLUBS_TXT = [ ## with country code
19
- 'de.clubs.txt',
20
- 'deutschland/de.clubs.txt',
21
- ## without country code
22
- 'europe/de-deutschland/clubs.txt',
23
- 'de-deutschland/clubs.txt',
24
- 'deutschland/clubs.txt',
25
- 'clubs.txt' ]
26
-
27
- CLUBS_WIKI_TXT = [ ## with country code
28
- 'de.clubs.wiki.txt',
29
- 'deutschland/de.clubs.wiki.txt',
30
- ## without country code
31
- 'europe/de-deutschland/clubs.wiki.txt',
32
- 'de-deutschland/clubs.wiki.txt',
33
- 'deutschland/clubs.wiki.txt',
34
- 'clubs.wiki.txt' ]
35
-
36
- LEAGUES_TXT = [ 'europe/england/leagues.txt',
37
- 'england/leagues.txt',
38
- 'leagues.txt' ]
39
-
40
- CONF_TXT = [ 'austria/archives/2000s/2001-02/.conf.txt',
41
- 'austria/2019-20/.conf.txt',
42
- '.conf.txt' ]
43
-
44
-
45
- def test_match_clubs
46
- CLUBS_TXT.each { |txt| assert match_clubs( txt ) }
47
-
48
- CLUBS_WIKI_TXT.each { |txt| assert !match_clubs( txt ) }
49
- end
50
-
51
- def test_match_clubs_wiki
52
- CLUBS_WIKI_TXT.each { |txt| assert match_clubs_wiki( txt ) }
53
-
54
- CLUBS_TXT.each { |txt| assert !match_clubs_wiki( txt ) }
55
- end
56
-
57
- def test_match_leagues
58
- LEAGUES_TXT.each { |txt| assert match_leagues( txt ) }
59
- end
60
-
61
- def test_match_conf
62
- CONF_TXT.each { |txt| assert match_conf( txt ) }
63
- end
64
-
65
- end # class TestFindDatafileMatch