sportdb-catalogs 1.0.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +1 -0
- data/Manifest.txt +9 -11
- data/README.md +3 -54
- data/Rakefile +6 -8
- data/lib/sportdb/catalogs/base.rb +154 -0
- data/lib/sportdb/catalogs/city.rb +78 -0
- data/lib/sportdb/catalogs/club.rb +104 -0
- data/lib/sportdb/catalogs/country.rb +147 -0
- data/lib/sportdb/catalogs/event_info.rb +74 -0
- data/lib/sportdb/catalogs/ground.rb +106 -0
- data/lib/sportdb/catalogs/league.rb +170 -0
- data/lib/sportdb/catalogs/national_team.rb +61 -0
- data/lib/sportdb/catalogs/player.rb +125 -0
- data/lib/sportdb/catalogs/version.rb +3 -5
- data/lib/sportdb/catalogs.rb +172 -10
- metadata +35 -47
- data/NOTES.md +0 -5
- data/lib/sportdb/catalogs/catalog.rb +0 -105
- data/lib/sportdb/catalogs/config.rb +0 -25
- data/lib/sportdb/catalogs/wiki_index.rb +0 -81
- data/test/helper.rb +0 -13
- data/test/test_clubs.rb +0 -100
- data/test/test_clubs_history.rb +0 -47
- data/test/test_countries.rb +0 -33
- data/test/test_leagues.rb +0 -38
- data/test/test_national_teams.rb +0 -38
- data/test/test_wiki_index.rb +0 -42
data/test/test_clubs.rb
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_clubs.rb
|
4
|
-
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
class TestClubs < MiniTest::Test
|
9
|
-
|
10
|
-
CLUBS = SportDb::Import.catalog.clubs
|
11
|
-
|
12
|
-
|
13
|
-
def test_match
|
14
|
-
pp CLUBS.errors
|
15
|
-
|
16
|
-
CLUBS.dump_duplicates
|
17
|
-
|
18
|
-
m = CLUBS.match( 'Rapid Wien' )
|
19
|
-
assert_equal 'SK Rapid Wien', m[0].name
|
20
|
-
assert_equal 'Austria', m[0].country.name
|
21
|
-
assert_equal 'Wien', m[0].city
|
22
|
-
|
23
|
-
m = CLUBS.match( 'rapid wien' )
|
24
|
-
assert_equal 'SK Rapid Wien', m[0].name
|
25
|
-
assert_equal 'Austria', m[0].country.name
|
26
|
-
assert_equal 'Wien', m[0].city
|
27
|
-
|
28
|
-
## note: all dots (.) get always removed
|
29
|
-
m = CLUBS.match( '...r.a.p.i.d w.i.e.n...' )
|
30
|
-
assert_equal 'SK Rapid Wien', m[0].name
|
31
|
-
assert_equal 'Austria', m[0].country.name
|
32
|
-
assert_equal 'Wien', m[0].city
|
33
|
-
|
34
|
-
## note: all spaces and dashes (-) get always removed
|
35
|
-
m = CLUBS.match( '--- r a p i d w i e n ---' )
|
36
|
-
assert_equal 'SK Rapid Wien', m[0].name
|
37
|
-
assert_equal 'Austria', m[0].country.name
|
38
|
-
assert_equal 'Wien', m[0].city
|
39
|
-
|
40
|
-
m = CLUBS.match( 'RAPID WIEN' )
|
41
|
-
assert_equal 'SK Rapid Wien', m[0].name
|
42
|
-
assert_equal 'Austria', m[0].country.name
|
43
|
-
assert_equal 'Wien', m[0].city
|
44
|
-
|
45
|
-
|
46
|
-
c = CLUBS[ 'SK Rapid Wien' ] ## check canoncial name match (only)
|
47
|
-
assert_equal 'SK Rapid Wien', c.name
|
48
|
-
assert_equal 'Austria', c.country.name
|
49
|
-
assert_equal 'Wien', c.city
|
50
|
-
|
51
|
-
|
52
|
-
m = CLUBS.match( 'Arsenal' )
|
53
|
-
assert_equal 3, m.size
|
54
|
-
|
55
|
-
m = CLUBS.match( 'ARSENAL' )
|
56
|
-
assert_equal 3, m.size
|
57
|
-
|
58
|
-
m = CLUBS.match_by( name: 'Arsenal', country: 'eng' )
|
59
|
-
assert_equal 1, m.size
|
60
|
-
assert_equal 'Arsenal FC', m[0].name
|
61
|
-
assert_equal 'England', m[0].country.name
|
62
|
-
assert_equal 'London', m[0].city
|
63
|
-
|
64
|
-
m = CLUBS.match_by( name: 'Arsenal', country: 'ar' )
|
65
|
-
assert_equal 1, m.size
|
66
|
-
assert_equal 'Arsenal de Sarandí', m[0].name
|
67
|
-
assert_equal 'Argentina', m[0].country.name
|
68
|
-
assert_equal 'Sarandí', m[0].city
|
69
|
-
|
70
|
-
m = CLUBS.match_by( name: 'Arsenal', country: 'ru' )
|
71
|
-
assert_equal 1, m.size
|
72
|
-
assert_equal 'Arsenal Tula', m[0].name
|
73
|
-
assert_equal 'Russia', m[0].country.name
|
74
|
-
assert_equal 'Tula', m[0].city
|
75
|
-
|
76
|
-
|
77
|
-
m = CLUBS.match( 'Arsenal FC' )
|
78
|
-
assert_equal 2, m.size
|
79
|
-
|
80
|
-
m = CLUBS.match( 'Arsenal F.C.' )
|
81
|
-
assert_equal 2, m.size
|
82
|
-
|
83
|
-
m = CLUBS.match( '...A.r.s.e.n.a.l... F.C...' )
|
84
|
-
assert_equal 2, m.size
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
def test_wikipedia ## test wikipedia names and links/urls
|
89
|
-
m = CLUBS.match( 'Club Brugge KV' )
|
90
|
-
assert_equal 1, m.size
|
91
|
-
assert_equal 'Club Brugge KV', m[0].wikipedia
|
92
|
-
assert_equal 'https://en.wikipedia.org/wiki/Club_Brugge_KV', m[0].wikipedia_url
|
93
|
-
|
94
|
-
m = CLUBS.match( 'RSC Anderlecht' )
|
95
|
-
assert_equal 1, m.size
|
96
|
-
assert_equal 'R.S.C. Anderlecht', m[0].wikipedia
|
97
|
-
assert_equal 'https://en.wikipedia.org/wiki/R.S.C._Anderlecht', m[0].wikipedia_url
|
98
|
-
end
|
99
|
-
|
100
|
-
end # class TestClubs
|
data/test/test_clubs_history.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_clubs_history.rb
|
4
|
-
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
class TestClubsHistory < MiniTest::Test
|
9
|
-
|
10
|
-
CLUBS = SportDb::Import.catalog.clubs
|
11
|
-
CLUBS_HISTORY = SportDb::Import.catalog.clubs_history
|
12
|
-
|
13
|
-
|
14
|
-
def test_at
|
15
|
-
pp CLUBS_HISTORY.mappings
|
16
|
-
|
17
|
-
puts CLUBS_HISTORY.find_name_by( name: 'WSG Tirol', season: '2019/20' )
|
18
|
-
puts CLUBS_HISTORY.find_name_by( name: 'WSG Tirol', season: '2018/9' )
|
19
|
-
puts CLUBS_HISTORY.find_name_by( name: 'WSG Tirol', season: '2017/8' )
|
20
|
-
|
21
|
-
club = CLUBS.find( 'WSG Wattens' )
|
22
|
-
pp club
|
23
|
-
|
24
|
-
assert_equal 'WSG Tirol', club.name_by_season( '2019/20' )
|
25
|
-
assert_equal 'WSG Wattens', club.name_by_season( '2018/9' )
|
26
|
-
assert_equal 'WSG Wattens', club.name_by_season( '2017/8' )
|
27
|
-
|
28
|
-
|
29
|
-
club = CLUBS.find( 'Rapid Wien' )
|
30
|
-
pp club
|
31
|
-
|
32
|
-
assert_equal 'SK Rapid Wien', club.name_by_season( '2000/1' )
|
33
|
-
assert_equal 'SK Rapid Wien', club.name_by_season( '1891/2' )
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_eng
|
37
|
-
club = CLUBS.find_by( name: 'Arsenal', country: 'ENG' )
|
38
|
-
pp club
|
39
|
-
|
40
|
-
assert_equal 'Arsenal FC', club.name_by_season( '2000/1' )
|
41
|
-
assert_equal 'Arsenal FC', club.name_by_season( '1927/8' )
|
42
|
-
assert_equal 'The Arsenal FC', club.name_by_season( '1926/7' )
|
43
|
-
assert_equal 'Woolwich Arsenal FC', club.name_by_season( '1913/4' )
|
44
|
-
assert_equal 'Royal Arsenal FC', club.name_by_season( '1891/2' )
|
45
|
-
end
|
46
|
-
|
47
|
-
end # class TestClubsHistory
|
data/test/test_countries.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_countries.rb
|
4
|
-
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
class TestCountries < MiniTest::Test
|
9
|
-
|
10
|
-
COUNTRIES = SportDb::Import.catalog.countries
|
11
|
-
|
12
|
-
|
13
|
-
def test_countries
|
14
|
-
## pp COUNTRIES
|
15
|
-
|
16
|
-
eng = COUNTRIES.find( :eng )
|
17
|
-
assert_equal 'eng', eng.key
|
18
|
-
assert_equal 'England', eng.name
|
19
|
-
assert_equal 'ENG', eng.code
|
20
|
-
|
21
|
-
at = COUNTRIES.find( :at )
|
22
|
-
assert_equal 'at', at.key
|
23
|
-
assert_equal 'Austria', at.name
|
24
|
-
assert_equal 'AUT', at.code
|
25
|
-
|
26
|
-
assert at == COUNTRIES.find( 'AT' )
|
27
|
-
assert at == COUNTRIES.find( 'at' )
|
28
|
-
assert at == COUNTRIES.find( 'AUT' )
|
29
|
-
assert at == COUNTRIES.find( 'aut' )
|
30
|
-
assert at == COUNTRIES.find( :aut )
|
31
|
-
end
|
32
|
-
|
33
|
-
end # class TestCountries
|
data/test/test_leagues.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_leagues.rb
|
4
|
-
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
class TestLeagues < MiniTest::Test
|
9
|
-
|
10
|
-
LEAGUES = SportDb::Import.catalog.leagues
|
11
|
-
|
12
|
-
|
13
|
-
def test_match
|
14
|
-
pp LEAGUES.errors
|
15
|
-
|
16
|
-
LEAGUES.dump_duplicates
|
17
|
-
|
18
|
-
m = LEAGUES.match( 'English Premier League' )
|
19
|
-
pp m
|
20
|
-
assert_equal 'Premier League', m[0].name
|
21
|
-
assert_equal 'eng.1', m[0].key
|
22
|
-
assert_equal 'England', m[0].country.name
|
23
|
-
assert_equal 'eng', m[0].country.key
|
24
|
-
assert m[0].clubs?
|
25
|
-
assert m[0].domestic?
|
26
|
-
assert_equal false, m[0].intl?
|
27
|
-
assert_equal false, m[0].national_teams?
|
28
|
-
|
29
|
-
m = LEAGUES.match( 'Euro' )
|
30
|
-
pp m
|
31
|
-
assert_equal 'Euro', m[0].name
|
32
|
-
assert_equal 'euro', m[0].key
|
33
|
-
assert m[0].national_teams?
|
34
|
-
assert m[0].intl?
|
35
|
-
assert_equal false, m[0].clubs?
|
36
|
-
end
|
37
|
-
|
38
|
-
end # class TestLeagues
|
data/test/test_national_teams.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_national_teams.rb
|
4
|
-
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
class TestNationalTeams < MiniTest::Test
|
9
|
-
|
10
|
-
NATIONAL_TEAMS = SportDb::Import.catalog.national_teams
|
11
|
-
|
12
|
-
|
13
|
-
def test_find
|
14
|
-
t = NATIONAL_TEAMS.find( 'AUT' )
|
15
|
-
assert_equal 'Austria', t.name
|
16
|
-
assert_equal 'aut', t.key
|
17
|
-
assert_equal 'AUT', t.code
|
18
|
-
|
19
|
-
|
20
|
-
t = NATIONAL_TEAMS.find( 'England' )
|
21
|
-
assert_equal 'England', t.name
|
22
|
-
assert_equal 'eng', t.key
|
23
|
-
assert_equal 'ENG', t.code
|
24
|
-
|
25
|
-
## note: all dots (.) get always removed
|
26
|
-
t = NATIONAL_TEAMS.find( '...e.n.g.l.a.n.d...' )
|
27
|
-
assert_equal 'England', t.name
|
28
|
-
assert_equal 'eng', t.key
|
29
|
-
assert_equal 'ENG', t.code
|
30
|
-
|
31
|
-
## note: all spaces and dashes (-) get always removed
|
32
|
-
t = NATIONAL_TEAMS.find( '--- e n g l a n d ---' )
|
33
|
-
assert_equal 'England', t.name
|
34
|
-
assert_equal 'eng', t.key
|
35
|
-
assert_equal 'ENG', t.code
|
36
|
-
end
|
37
|
-
|
38
|
-
end # class TestNationalTeams
|
data/test/test_wiki_index.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_wiki_index.rb
|
4
|
-
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
class TestWikiIndex < MiniTest::Test
|
9
|
-
|
10
|
-
Club = SportDb::Import::Club
|
11
|
-
|
12
|
-
COUNTRIES = SportDb::Import.catalog.countries
|
13
|
-
|
14
|
-
|
15
|
-
def test_clubs
|
16
|
-
## note: CANNOT run if no "custom" clubs_dir set
|
17
|
-
return if SportDb::Import.config.clubs_dir.nil?
|
18
|
-
|
19
|
-
wiki = SportDb::Import::WikiIndex.build( SportDb::Import.config.clubs_dir )
|
20
|
-
## pp wiki
|
21
|
-
|
22
|
-
##############################################
|
23
|
-
## test wikipedia names and links/urls
|
24
|
-
be = COUNTRIES.find( 'be' )
|
25
|
-
|
26
|
-
club = Club.new
|
27
|
-
club.name = 'Club Brugge KV'
|
28
|
-
club.country = be
|
29
|
-
|
30
|
-
rec = wiki.find_by( club: club )
|
31
|
-
assert_equal 'Club Brugge KV', rec.name
|
32
|
-
|
33
|
-
|
34
|
-
club = Club.new
|
35
|
-
club.name = 'RSC Anderlecht'
|
36
|
-
club.country = be
|
37
|
-
|
38
|
-
rec = wiki.find_by( club: club )
|
39
|
-
assert_equal 'R.S.C. Anderlecht', rec.name
|
40
|
-
end
|
41
|
-
|
42
|
-
end # class TestWikiIndex
|