sportdb-formats 1.1.6 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +2 -0
  3. data/Manifest.txt +4 -25
  4. data/Rakefile +1 -1
  5. data/lib/sportdb/formats/country/country_reader.rb +142 -142
  6. data/lib/sportdb/formats/datafile.rb +59 -59
  7. data/lib/sportdb/formats/event/event_reader.rb +184 -183
  8. data/lib/sportdb/formats/goals.rb +53 -9
  9. data/lib/sportdb/formats/ground/ground_reader.rb +289 -0
  10. data/lib/sportdb/formats/league/league_reader.rb +152 -168
  11. data/lib/sportdb/formats/lines_reader.rb +47 -0
  12. data/lib/sportdb/formats/match/match_parser.rb +130 -13
  13. data/lib/sportdb/formats/match/match_parser_auto_conf.rb +270 -202
  14. data/lib/sportdb/formats/outline_reader.rb +0 -1
  15. data/lib/sportdb/formats/package.rb +394 -374
  16. data/lib/sportdb/formats/search/sport.rb +357 -0
  17. data/lib/sportdb/formats/search/world.rb +139 -0
  18. data/lib/sportdb/formats/team/club_index_history.rb +134 -134
  19. data/lib/sportdb/formats/team/club_reader.rb +318 -350
  20. data/lib/sportdb/formats/team/club_reader_history.rb +203 -203
  21. data/lib/sportdb/formats/team/wiki_reader.rb +108 -108
  22. data/lib/sportdb/formats/version.rb +4 -7
  23. data/lib/sportdb/formats.rb +60 -27
  24. metadata +13 -35
  25. data/lib/sportdb/formats/country/country_index.rb +0 -192
  26. data/lib/sportdb/formats/event/event_index.rb +0 -141
  27. data/lib/sportdb/formats/league/league_index.rb +0 -178
  28. data/lib/sportdb/formats/team/club_index.rb +0 -338
  29. data/lib/sportdb/formats/team/national_team_index.rb +0 -114
  30. data/lib/sportdb/formats/team/team_index.rb +0 -43
  31. data/test/helper.rb +0 -132
  32. data/test/test_club_index.rb +0 -183
  33. data/test/test_club_index_history.rb +0 -107
  34. data/test/test_club_reader.rb +0 -201
  35. data/test/test_club_reader_history.rb +0 -212
  36. data/test/test_club_reader_props.rb +0 -54
  37. data/test/test_country_index.rb +0 -63
  38. data/test/test_country_reader.rb +0 -89
  39. data/test/test_datafile.rb +0 -30
  40. data/test/test_datafile_package.rb +0 -46
  41. data/test/test_goals.rb +0 -113
  42. data/test/test_league_index.rb +0 -157
  43. data/test/test_league_outline_reader.rb +0 -55
  44. data/test/test_league_reader.rb +0 -72
  45. data/test/test_outline_reader.rb +0 -31
  46. data/test/test_package.rb +0 -78
  47. data/test/test_package_match.rb +0 -102
  48. data/test/test_regex.rb +0 -67
  49. data/test/test_wiki_reader.rb +0 -77
@@ -1,157 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_league_index.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestLeagueIndex < MiniTest::Test
11
-
12
- def test_match
13
- recs = SportDb::Import::LeagueReader.parse( <<TXT )
14
- = England =
15
- 1 English Premier League
16
- | ENG PL | England Premier League | Premier League
17
- 2 English Championship
18
- | ENG CS | England Championship | Championship
19
- 3 English League One
20
- | England League One | League One
21
- 4 English League Two
22
- 5 English National League
23
-
24
- cup EFL Cup
25
- | League Cup | Football League Cup
26
- | ENG LC | England Liga Cup
27
-
28
- = Scotland =
29
- 1 Scottish Premiership
30
- 2 Scottish Championship
31
- 3 Scottish League One
32
- 4 Scottish League Two
33
- TXT
34
-
35
- leagues = SportDb::Import::LeagueIndex.new
36
- leagues.add( recs )
37
-
38
- pp leagues.errors
39
-
40
- leagues.dump_duplicates
41
-
42
- m = leagues.match( 'English Premier League' )
43
- assert_equal 'English Premier League', m[0].name
44
- assert_equal 'eng.1', m[0].key
45
- assert_equal 'England', m[0].country.name
46
- assert_equal 'eng', m[0].country.key
47
-
48
- m = leagues.match( 'english premier league' )
49
- assert_equal 'English Premier League', m[0].name
50
- assert_equal 'eng.1', m[0].key
51
- assert_equal 'England', m[0].country.name
52
- assert_equal 'eng', m[0].country.key
53
-
54
- m = leagues.match( 'englishpremierleague' )
55
- assert_equal 'English Premier League', m[0].name
56
- assert_equal 'eng.1', m[0].key
57
- assert_equal 'England', m[0].country.name
58
- assert_equal 'eng', m[0].country.key
59
-
60
- ## note: all dots (.) get always removed
61
- m = leagues.match( '...e.n.g.l.i.s.h.p.r.e.m.i.e.r.l.e.a.g.u.e...' )
62
- assert_equal 'English Premier League', m[0].name
63
- assert_equal 'eng.1', m[0].key
64
- assert_equal 'England', m[0].country.name
65
- assert_equal 'eng', m[0].country.key
66
-
67
- ## note: all spaces and dashes (-) get always removed
68
- m = leagues.match( '--- e n g l i s h p r e m i e r l e a g u e ---' )
69
- assert_equal 'English Premier League', m[0].name
70
- assert_equal 'eng.1', m[0].key
71
- assert_equal 'England', m[0].country.name
72
- assert_equal 'eng', m[0].country.key
73
-
74
- m = leagues.match( 'ENGLISH PREMIER LEAGUE' )
75
- assert_equal 'English Premier League', m[0].name
76
- assert_equal 'eng.1', m[0].key
77
- assert_equal 'England', m[0].country.name
78
- assert_equal 'eng', m[0].country.key
79
-
80
- ## check alt names
81
- m = leagues.match( 'ENG PL' )
82
- assert_equal 'English Premier League', m[0].name
83
- assert_equal 'eng.1', m[0].key
84
- assert_equal 'England', m[0].country.name
85
- assert_equal 'eng', m[0].country.key
86
- end
87
-
88
- def test_match_by
89
- recs = SportDb::Import::LeagueReader.parse( <<TXT )
90
- = Germany =
91
- 1 Bundesliga
92
-
93
- = Austria =
94
- 1 Bundesliga
95
-
96
- = England =
97
- 1 English Premier League
98
- | Premier League
99
-
100
- = Wales =
101
- 1 Welsh Premier League
102
- | Premier League
103
- TXT
104
-
105
- leagues = SportDb::Import::LeagueIndex.new
106
- leagues.add( recs )
107
-
108
- pp leagues.errors
109
-
110
- leagues.dump_duplicates
111
-
112
- m = leagues.match( 'Bundesliga' )
113
- assert_equal 2, m.size
114
-
115
- m = leagues.match( 'AT' ) ## check auto-generated/added shortcut names
116
- assert_equal 1, m.size
117
- assert_equal 'Bundesliga', m[0].name
118
- m = leagues.match( 'AT 1' )
119
- assert_equal 1, m.size
120
- assert_equal 'Bundesliga', m[0].name
121
- m = leagues.match( 'AUT' )
122
- assert_equal 1, m.size
123
- assert_equal 'Bundesliga', m[0].name
124
- m = leagues.match( 'AUT 1' )
125
- assert_equal 1, m.size
126
- assert_equal 'Bundesliga', m[0].name
127
- m = leagues.match( 'Austria 1' )
128
- assert_equal 1, m.size
129
- assert_equal 'Bundesliga', m[0].name
130
-
131
-
132
- m = leagues.match_by( name: 'Bundesliga', country: 'at' )
133
- assert_equal 1, m.size
134
- m = leagues.match_by( name: 'Bundesliga', country: 'de' )
135
- assert_equal 1, m.size
136
-
137
-
138
- m = leagues.match( 'Premier League' )
139
- assert_equal 2, m.size
140
-
141
- m = leagues.match( 'ENG' ) ## check auto-generated/added shortcut names
142
- assert_equal 1, m.size
143
- assert_equal 'English Premier League', m[0].name
144
- m = leagues.match( 'ENG 1' )
145
- assert_equal 1, m.size
146
- assert_equal 'English Premier League', m[0].name
147
- m = leagues.match( 'England 1' )
148
- assert_equal 1, m.size
149
- assert_equal 'English Premier League', m[0].name
150
-
151
- m = leagues.match_by( name: 'Premier League', country: 'eng' )
152
- assert_equal 1, m.size
153
- m = leagues.match_by( name: 'Premier League', country: 'wal' )
154
- assert_equal 1, m.size
155
- end
156
-
157
- end # class TestLeagueIndex
@@ -1,55 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_league_outline_reader.rb
6
-
7
-
8
- require 'helper'
9
-
10
-
11
- class TestLeagueOutlineReader < MiniTest::Test
12
-
13
- def test_parse
14
- txt = <<TXT
15
- = ENG PL 2019/20
16
-
17
- line
18
- line
19
-
20
- = ENG CS 2019/20
21
-
22
- line
23
- line
24
-
25
- = ENG PL 2020/1
26
-
27
- line
28
- line
29
- TXT
30
-
31
- secs = SportDb::LeagueOutlineReader.parse( txt )
32
- pp secs
33
-
34
- assert_equal 3, secs.size
35
-
36
- league = secs[0][:league]
37
- assert_equal 'English Premier League', league.name
38
- assert_equal 'eng.1', league.key
39
- assert_equal 'England', league.country.name
40
- assert_equal 'eng', league.country.key
41
-
42
- season = secs[0][:season]
43
- assert_equal '2019/20', season.key
44
-
45
- ## try with season filter
46
- secs = SportDb::LeagueOutlineReader.parse( txt, season: '2020/21' )
47
- pp secs
48
-
49
- assert_equal 1, secs.size
50
-
51
- season = secs[0][:season]
52
- assert_equal '2020/21', season.key
53
- end
54
-
55
- end # class TestLeagueOutlineReader
@@ -1,72 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_league_reader.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestLeagueReader < MiniTest::Test
11
-
12
- def test_parse_at
13
- recs = SportDb::Import::LeagueReader.parse( <<TXT )
14
- ==============================
15
- = Austria
16
- 1 Bundesliga
17
- | AUT BL | Österreich Bundesliga
18
- 2 2. Liga
19
- | Österreich Zweite Liga
20
-
21
- 3.o Regionalliga Ost
22
- | AUT RLO | Österreich Regionalliga Ost
23
- 3.m Regionalliga Mitte
24
- | AUT RLM | Österreich Regionalliga Mitte
25
- 3.sbg Regionalliga Salzburg
26
- | RL SBG
27
- 3.t Regionalliga Tirol
28
- | RL TIR
29
- TXT
30
-
31
- pp recs
32
-
33
- assert_equal 6, recs.size
34
- assert_equal '2. Liga', recs[1].name
35
- assert_equal 'at.2', recs[1].key
36
- assert_equal 'Austria', recs[1].country.name
37
- assert_equal 'at', recs[1].country.key
38
-
39
- assert recs[0].alt_names_auto.include?( 'AT' )
40
- assert recs[0].alt_names_auto.include?( 'AT 1' )
41
- assert recs[0].alt_names_auto.include?( 'AUT 1' )
42
- assert recs[0].alt_names_auto.include?( 'Austria 1' )
43
-
44
- assert recs[1].alt_names_auto.include?( 'AT 2' )
45
- assert recs[1].alt_names_auto.include?( 'AUT 2' )
46
- assert recs[1].alt_names_auto.include?( 'Austria 2' )
47
- end
48
-
49
-
50
- def test_parse_us
51
- recs = SportDb::Import::LeagueReader.parse( <<TXT )
52
- =============================================
53
- = United States
54
- 1 Major League Soccer
55
- | USA MLS | USA Major League Soccer
56
- cup US Open Cup
57
- | USA US Open Cup
58
- TXT
59
-
60
- pp recs
61
-
62
- assert_equal 2, recs.size
63
- assert_equal 'Major League Soccer', recs[0].name
64
- assert_equal 'us.1', recs[0].key
65
- assert_equal 'United States', recs[0].country.name
66
- assert_equal 'us', recs[0].country.key
67
-
68
- assert_equal 'US Open Cup', recs[1].name
69
- assert_equal 'us.cup', recs[1].key
70
- end
71
-
72
- end # class TestLeagueReader
@@ -1,31 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_outline_reader.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestOutlineReader < MiniTest::Test
11
-
12
- def test_parse
13
- outline = SportDb::OutlineReader.parse( <<TXT )
14
- =============================
15
- = ÖFB Cup 2011/12
16
- =============================
17
-
18
- FC Red Bull Salzburg ## Bundesliga
19
- FK Austria Wien
20
- TXT
21
-
22
- pp outline
23
-
24
- assert_equal 2, outline.size
25
-
26
- assert_equal [:h1, 'ÖFB Cup 2011/12'], outline[0]
27
- assert_equal [:p, ['FC Red Bull Salzburg',
28
- 'FK Austria Wien']], outline[1]
29
- end
30
-
31
- end # class TestOutlineReader
data/test/test_package.rb DELETED
@@ -1,78 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_package.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestPackage < MiniTest::Test
11
-
12
- AUSTRIA_DIR = '../../../openfootball/austria'
13
- AUSTRIA_CSV_DIR = '../../../footballcsv/austria'
14
-
15
- ENGLAND_DIR = '../../../openfootball/england'
16
- ENGLAND_CSV_DIR = '../../../footballcsv/england'
17
-
18
-
19
- def test_match_by
20
-
21
- [ AUSTRIA_CSV_DIR,
22
- ENGLAND_CSV_DIR,
23
- "#{SportDb::Test.data_dir}/packages/test-levels",
24
- ].each do |path|
25
- puts
26
- puts "match (csv) in #{path}:"
27
- pack = SportDb::Package.new( path )
28
- pp pack.match_by_season_dir( format: 'csv' )
29
- puts "---"
30
- pp pack.match_by_season( format: 'csv' )
31
- end
32
-
33
- [ AUSTRIA_DIR,
34
- ENGLAND_DIR,
35
- "#{SportDb::Test.data_dir}/packages/test-levels",
36
- ].each do |path|
37
- puts
38
- puts "match (txt) in #{path}:"
39
- pack = SportDb::Package.new( path )
40
- pp pack.match_by_season_dir
41
- puts "---"
42
- pp pack.match_by_season( start: '2000' ) ## note: try with start season filter!!
43
- end
44
- end
45
-
46
-
47
- CLUBS_DIR = '../../../openfootball/clubs' ## source repo directory path
48
- LEAGUES_DIR = '../../../openfootball/leagues'
49
-
50
- def test_bundle
51
- datafiles = SportDb::Package.find_clubs( CLUBS_DIR )
52
- pp datafiles
53
-
54
- ## todo/fix: turn into Datafile::Bundle.new and Bundle#write/save -why? why not?
55
- bundle = Datafile::Bundle.new( './tmp/clubs.txt' )
56
- bundle.write <<TXT
57
- ##########################################
58
- # auto-generated all-in-one single datafile clubs.txt bundle
59
- # on #{Time.now} from #{datafiles.size} datafile(s)
60
- TXT
61
- bundle.write datafiles
62
- bundle.close
63
- end
64
-
65
- def test_bundle_old
66
- datafiles = SportDb::Package.find_leagues( LEAGUES_DIR )
67
- pp datafiles
68
-
69
- Datafile.write_bundle( './tmp/leagues.txt',
70
- datafiles: datafiles,
71
- header: <<TXT )
72
- ##########################################
73
- # auto-generated all-in-one single datafile leagues.txt bundle
74
- # on #{Time.now} from #{datafiles.size} datafile(s)
75
- TXT
76
- end
77
-
78
- end # class TestPackage
@@ -1,102 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_package_match.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestPackageMatch < MiniTest::Test
11
-
12
- CLUBS_DIR = '../../../openfootball/clubs' ## source repo directory path
13
- LEAGUES_DIR = '../../../openfootball/leagues'
14
- AUSTRIA_DIR = '../../../openfootball/austria'
15
-
16
- AUSTRIA_CSV_DIR = '../../../footballcsv/austria'
17
-
18
-
19
- def test_find
20
- datafiles = SportDb::Package.find_clubs( CLUBS_DIR )
21
- pp datafiles
22
-
23
- datafiles = SportDb::Package.find_clubs_wiki( CLUBS_DIR )
24
- pp datafiles
25
-
26
- datafiles = SportDb::Package.find_leagues( LEAGUES_DIR )
27
- pp datafiles
28
-
29
- datafiles = SportDb::Package.find_conf( AUSTRIA_DIR )
30
- pp datafiles
31
-
32
- datafiles = SportDb::Package.find_match( AUSTRIA_DIR )
33
- puts
34
- puts "== find_match (in #{AUSTRIA_DIR}) - found #{datafiles.size}:"
35
- pp datafiles
36
-
37
- datafiles = SportDb::Package.find_match( AUSTRIA_CSV_DIR )
38
- puts
39
- puts "== find_match (in #{AUSTRIA_CSV_DIR}) - found #{datafiles.size}:"
40
- pp datafiles
41
-
42
-
43
- datafiles = SportDb::Package.find_match( AUSTRIA_DIR, format: 'csv' )
44
- puts
45
- puts "== find_match+csv (in #{AUSTRIA_DIR}) - found #{datafiles.size}:"
46
- pp datafiles
47
-
48
- datafiles = SportDb::Package.find_match( AUSTRIA_CSV_DIR, format: 'csv' )
49
- puts
50
- puts "== find_match+csv (in #{AUSTRIA_CSV_DIR}) - found #{datafiles.size}:"
51
- pp datafiles
52
- end
53
-
54
-
55
- CLUBS_TXT = [ ## with country code
56
- 'de.clubs.txt',
57
- 'deutschland/de.clubs.txt',
58
- ## without country code
59
- 'europe/de-deutschland/clubs.txt',
60
- 'de-deutschland/clubs.txt',
61
- 'deutschland/clubs.txt',
62
- 'clubs.txt' ]
63
-
64
- CLUBS_WIKI_TXT = [ ## with country code
65
- 'de.clubs.wiki.txt',
66
- 'deutschland/de.clubs.wiki.txt',
67
- ## without country code
68
- 'europe/de-deutschland/clubs.wiki.txt',
69
- 'de-deutschland/clubs.wiki.txt',
70
- 'deutschland/clubs.wiki.txt',
71
- 'clubs.wiki.txt' ]
72
-
73
- LEAGUES_TXT = [ 'europe/england/leagues.txt',
74
- 'england/leagues.txt',
75
- 'leagues.txt' ]
76
-
77
- CONF_TXT = [ 'austria/archives/2000s/2001-02/.conf.txt',
78
- 'austria/2019-20/.conf.txt',
79
- '.conf.txt' ]
80
-
81
-
82
- def test_match_clubs
83
- CLUBS_TXT.each { |path| assert SportDb::Package.match_clubs?( path ) }
84
-
85
- CLUBS_WIKI_TXT.each { |path| assert !SportDb::Package.match_clubs?( path ) }
86
- end
87
-
88
- def test_match_clubs_wiki
89
- CLUBS_WIKI_TXT.each { |path| assert SportDb::Package.match_clubs_wiki?( path ) }
90
-
91
- CLUBS_TXT.each { |path| assert !SportDb::Package.match_clubs_wiki?( path ) }
92
- end
93
-
94
- def test_match_leagues
95
- LEAGUES_TXT.each { |path| assert SportDb::Package.match_leagues?( path ) }
96
- end
97
-
98
- def test_match_conf
99
- CONF_TXT.each { |path| assert SportDb::Package.match_conf?( path ) }
100
- end
101
-
102
- end # class TestPackageMatch
data/test/test_regex.rb DELETED
@@ -1,67 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_regex.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestRegex < MiniTest::Test
11
-
12
- HEADER_SEP_RE = SportDb::MatchParser::HEADER_SEP_RE
13
-
14
- def test_header_sep
15
- assert_equal ['Round', 'Fr+Sa Dec 11+12'], 'Round // Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
16
- assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 /// Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
17
- assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 -- Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
18
- assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 --- Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
19
- assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 ++ Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
20
- assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 +++ Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
21
- assert_equal ['Round 11', 'Fr+Sa Dec 11+12'], 'Round 11 || Fr+Sa Dec 11+12'.split( HEADER_SEP_RE )
22
-
23
- assert_equal ['Final - Leg 1'], 'Final - Leg 1'.split( HEADER_SEP_RE )
24
- assert_equal ['Final | Leg 1'], 'Final | Leg 1'.split( HEADER_SEP_RE )
25
- assert_equal ['Final / Leg 1'], 'Final / Leg 1'.split( HEADER_SEP_RE )
26
- assert_equal ['Final, Leg 1'], 'Final, Leg 1'.split( HEADER_SEP_RE )
27
- end
28
-
29
-
30
- ADDR_MARKER_RE = SportDb::Import::ClubReader::ADDR_MARKER_RE
31
- B_TEAM_MARKER_RE = SportDb::Import::ClubReader::B_TEAM_MARKER_RE
32
-
33
- def test_addr
34
- assert '~ Wien' =~ ADDR_MARKER_RE
35
- assert 'Wien ~' =~ ADDR_MARKER_RE
36
- assert 'Fischhofgasse 12 ~ 1100 Wien' =~ ADDR_MARKER_RE
37
- assert 'Fischhofgasse 12 ++ 1100 Wien' =~ ADDR_MARKER_RE
38
- assert 'Fischhofgasse 12 +++ 1100 Wien' =~ ADDR_MARKER_RE
39
- assert 'Fischhofgasse 12 // 1100 Wien' =~ ADDR_MARKER_RE
40
- assert 'Fischhofgasse 12 /// 1100 Wien' =~ ADDR_MARKER_RE
41
-
42
- assert_nil 'Fischhofgasse 12 + 1100 Wien' =~ ADDR_MARKER_RE
43
- assert_nil 'Fischhofgasse 12++1100 Wien' =~ ADDR_MARKER_RE ## todo/fix: make it a match!!! why? why not?
44
- assert_nil 'Fischhofgasse 12 / 1100 Wien' =~ ADDR_MARKER_RE
45
- assert_nil 'Fischhofgasse 12//1100 Wien' =~ ADDR_MARKER_RE ## todo/fix: make it a match!!! why? why not?
46
-
47
- assert_nil 'Atlanta United FC, 2017, Atlanta › Georgia' =~ ADDR_MARKER_RE
48
- end
49
-
50
- def test_b_team
51
- assert 'b) Rapid Wien II' =~ B_TEAM_MARKER_RE
52
- assert '(b) Rapid Wien II' =~ B_TEAM_MARKER_RE
53
- assert '(b.) Rapid Wien II' =~ B_TEAM_MARKER_RE
54
- assert 'ii) Rapid Wien II' =~ B_TEAM_MARKER_RE
55
- assert 'II) Rapid Wien II' =~ B_TEAM_MARKER_RE
56
- assert '(ii.) Rapid Wien II' =~ B_TEAM_MARKER_RE
57
- assert '2) Rapid Wien II' =~ B_TEAM_MARKER_RE
58
- assert '(2) Rapid Wien II' =~ B_TEAM_MARKER_RE
59
-
60
- assert_nil '(3) Rapid Wien II' =~ B_TEAM_MARKER_RE
61
- assert_nil '(iii) Rapid Wien II' =~ B_TEAM_MARKER_RE
62
- assert_nil 'iii) Rapid Wien II' =~ B_TEAM_MARKER_RE
63
- assert_nil 'c) Rapid Wien II' =~ B_TEAM_MARKER_RE
64
- assert_nil '(c) Rapid Wien II' =~ B_TEAM_MARKER_RE
65
- end
66
-
67
- end # class TestRegex
@@ -1,77 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_wiki_reader.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestWikiReader < MiniTest::Test
11
-
12
- def test_parse_at
13
- recs = SportDb::Import::WikiReader.parse( <<TXT )
14
- ===================================
15
- = Albania
16
-
17
- FK Partizani Tirana
18
- KF Tirana
19
- FK Kukësi
20
- KF Laçi
21
- TXT
22
-
23
- pp recs
24
-
25
- assert_equal 4, recs.size
26
- assert_equal 'FK Partizani Tirana', recs[0].name
27
- assert_equal 'Albania', recs[0].country.name
28
- assert_equal 'al', recs[0].country.key
29
- end
30
-
31
-
32
- def test_parse_be
33
- recs = SportDb::Import::WikiReader.parse( <<TXT )
34
- ===========================
35
- = Belgium
36
-
37
- R.S.C._Anderlecht
38
- Royal_Antwerp_F.C.
39
- Cercle_Brugge_K.S.V.
40
- R._Charleroi_S.C.
41
- Club_Brugge_KV
42
- TXT
43
-
44
- pp recs
45
-
46
- assert_equal 5, recs.size
47
- assert_equal 'R.S.C. Anderlecht', recs[0].name
48
- assert_equal 'Belgium', recs[0].country.name
49
- assert_equal 'be', recs[0].country.key
50
- end
51
-
52
- def test_parse_world
53
- recs = SportDb::Import::WikiReader.parse( <<TXT )
54
- = Albania =
55
-
56
- FK Partizani Tirana
57
-
58
-
59
- = Belgium =
60
-
61
- # some comments here
62
- R.S.C._Anderlecht # some end-of-line comments here
63
- TXT
64
-
65
- pp recs
66
-
67
- assert_equal 2, recs.size
68
- assert_equal 'FK Partizani Tirana', recs[0].name
69
- assert_equal 'Albania', recs[0].country.name
70
- assert_equal 'al', recs[0].country.key
71
-
72
- assert_equal 'R.S.C. Anderlecht', recs[1].name
73
- assert_equal 'Belgium', recs[1].country.name
74
- assert_equal 'be', recs[1].country.key
75
- end
76
-
77
- end # class TestWikiReader