sportdb-catalogs 1.0.0 → 1.2.0
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 +5 -7
- 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 +110 -0
- data/lib/sportdb/catalogs/event_info.rb +74 -0
- data/lib/sportdb/catalogs/ground.rb +106 -0
- data/lib/sportdb/catalogs/league.rb +87 -0
- data/lib/sportdb/catalogs/national_team.rb +61 -0
- data/lib/sportdb/catalogs/player.rb +125 -0
- data/lib/sportdb/catalogs/version.rb +2 -4
- data/lib/sportdb/catalogs.rb +172 -10
- metadata +34 -46
- 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
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-catalogs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-formats
|
@@ -16,117 +16,106 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: sqlite3
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: footballdb-
|
42
|
+
name: footballdb-data
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: footballdb-clubs
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 2020.7.7
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 2020.7.7
|
54
|
+
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rdoc
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- - "
|
59
|
+
- - ">="
|
74
60
|
- !ruby/object:Gem::Version
|
75
61
|
version: '4.0'
|
62
|
+
- - "<"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '7'
|
76
65
|
type: :development
|
77
66
|
prerelease: false
|
78
67
|
version_requirements: !ruby/object:Gem::Requirement
|
79
68
|
requirements:
|
80
|
-
- - "
|
69
|
+
- - ">="
|
81
70
|
- !ruby/object:Gem::Version
|
82
71
|
version: '4.0'
|
72
|
+
- - "<"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '7'
|
83
75
|
- !ruby/object:Gem::Dependency
|
84
76
|
name: hoe
|
85
77
|
requirement: !ruby/object:Gem::Requirement
|
86
78
|
requirements:
|
87
79
|
- - "~>"
|
88
80
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
81
|
+
version: '4.1'
|
90
82
|
type: :development
|
91
83
|
prerelease: false
|
92
84
|
version_requirements: !ruby/object:Gem::Requirement
|
93
85
|
requirements:
|
94
86
|
- - "~>"
|
95
87
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
88
|
+
version: '4.1'
|
97
89
|
description: sportdb-catalogs - sport.db (search 'n' find) catalogs for countries,
|
98
90
|
leagues, clubs, national teams, and more
|
99
|
-
email:
|
91
|
+
email: gerald.bauer@gmail.com
|
100
92
|
executables: []
|
101
93
|
extensions: []
|
102
94
|
extra_rdoc_files:
|
103
95
|
- CHANGELOG.md
|
104
96
|
- Manifest.txt
|
105
|
-
- NOTES.md
|
106
97
|
- README.md
|
107
98
|
files:
|
108
99
|
- CHANGELOG.md
|
109
100
|
- Manifest.txt
|
110
|
-
- NOTES.md
|
111
101
|
- README.md
|
112
102
|
- Rakefile
|
113
103
|
- lib/sportdb/catalogs.rb
|
114
|
-
- lib/sportdb/catalogs/
|
115
|
-
- lib/sportdb/catalogs/
|
104
|
+
- lib/sportdb/catalogs/base.rb
|
105
|
+
- lib/sportdb/catalogs/city.rb
|
106
|
+
- lib/sportdb/catalogs/club.rb
|
107
|
+
- lib/sportdb/catalogs/country.rb
|
108
|
+
- lib/sportdb/catalogs/event_info.rb
|
109
|
+
- lib/sportdb/catalogs/ground.rb
|
110
|
+
- lib/sportdb/catalogs/league.rb
|
111
|
+
- lib/sportdb/catalogs/national_team.rb
|
112
|
+
- lib/sportdb/catalogs/player.rb
|
116
113
|
- lib/sportdb/catalogs/version.rb
|
117
|
-
- lib/sportdb/catalogs/wiki_index.rb
|
118
|
-
- test/helper.rb
|
119
|
-
- test/test_clubs.rb
|
120
|
-
- test/test_clubs_history.rb
|
121
|
-
- test/test_countries.rb
|
122
|
-
- test/test_leagues.rb
|
123
|
-
- test/test_national_teams.rb
|
124
|
-
- test/test_wiki_index.rb
|
125
114
|
homepage: https://github.com/sportdb/sport.db
|
126
115
|
licenses:
|
127
116
|
- Public Domain
|
128
117
|
metadata: {}
|
129
|
-
post_install_message:
|
118
|
+
post_install_message:
|
130
119
|
rdoc_options:
|
131
120
|
- "--main"
|
132
121
|
- README.md
|
@@ -143,9 +132,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
132
|
- !ruby/object:Gem::Version
|
144
133
|
version: '0'
|
145
134
|
requirements: []
|
146
|
-
|
147
|
-
|
148
|
-
signing_key:
|
135
|
+
rubygems_version: 3.4.10
|
136
|
+
signing_key:
|
149
137
|
specification_version: 4
|
150
138
|
summary: sportdb-catalogs - sport.db (search 'n' find) catalogs for countries, leagues,
|
151
139
|
clubs, national teams, and more
|
@@ -1,105 +0,0 @@
|
|
1
|
-
|
2
|
-
module SportDb
|
3
|
-
module Import
|
4
|
-
|
5
|
-
|
6
|
-
class Catalog
|
7
|
-
def config() Import.config; end
|
8
|
-
|
9
|
-
|
10
|
-
## todo/check: rename to country_mappings/index - why? why not?
|
11
|
-
## or countries_by_code or countries_by_key
|
12
|
-
def countries() @countries ||= build_country_index; end
|
13
|
-
def national_teams() @national_teams ||= build_national_team_index; end
|
14
|
-
def clubs() @clubs ||= build_club_index; end
|
15
|
-
def clubs_history() @clubs_history ||= build_club_history_index; end ## note: used for now (only) lookups by season for now
|
16
|
-
def teams() @teams ||= build_team_index; end
|
17
|
-
def leagues() @leagues ||= build_league_index; end
|
18
|
-
|
19
|
-
def events() @events ||= build_event_index; end
|
20
|
-
def seasons() @seasons ||= build_season_index; end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
def build_team_index() TeamIndex.new; end
|
25
|
-
|
26
|
-
def build_country_index ## todo/check: rename to setup_country_index or read_country_index - why? why not?
|
27
|
-
CountryIndex.new( Fifa.countries )
|
28
|
-
end
|
29
|
-
|
30
|
-
def build_national_team_index
|
31
|
-
## auto-build national teams from Fifa.countries for now
|
32
|
-
teams = []
|
33
|
-
Fifa.countries.each do |country|
|
34
|
-
team = NationalTeam.new( key: country.code.downcase, ## note: use country code (fifa)
|
35
|
-
name: country.name,
|
36
|
-
code: country.code, ## note: use country code (fifa)
|
37
|
-
alt_names: country.alt_names )
|
38
|
-
team.country = country
|
39
|
-
|
40
|
-
teams << team
|
41
|
-
end
|
42
|
-
|
43
|
-
NationalTeamIndex.new( teams )
|
44
|
-
end
|
45
|
-
|
46
|
-
def build_club_index
|
47
|
-
## unify team names; team (builtin/known/shared) name mappings
|
48
|
-
## cleanup team names - use local ("native") name with umlaut etc.
|
49
|
-
## todo/fix: add to teamreader
|
50
|
-
## check that name and alt_names for a club are all unique (not duplicates)
|
51
|
-
|
52
|
-
clubs = if config.clubs_dir ## check if clubs_dir is defined / set (otherwise it's nil)
|
53
|
-
ClubIndex.build( config.clubs_dir )
|
54
|
-
else ## no clubs_dir set - try using builtin from footballdb-clubs
|
55
|
-
FootballDb::Import::build_club_index
|
56
|
-
end
|
57
|
-
|
58
|
-
if clubs.errors?
|
59
|
-
puts ""
|
60
|
-
puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
61
|
-
puts " #{clubs.errors.size} errors:"
|
62
|
-
pp clubs.errors
|
63
|
-
## exit 1
|
64
|
-
end
|
65
|
-
|
66
|
-
clubs
|
67
|
-
end # method build_club_index
|
68
|
-
|
69
|
-
def build_club_history_index
|
70
|
-
if config.clubs_dir ## (re)use clubs dir for now - why? why not?
|
71
|
-
ClubHistoryIndex.build( config.clubs_dir )
|
72
|
-
else
|
73
|
-
puts "!! WARN - no clubs_dir set; for now NO built-in club histories in catalog; sorry - fix!!!!"
|
74
|
-
ClubHistoryIndex.new ## return empty history index
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
def build_league_index
|
80
|
-
leagues = if config.leagues_dir ## check if clubs_dir is defined / set (otherwise it's nil)
|
81
|
-
LeagueIndex.build( config.leagues_dir )
|
82
|
-
else ## no leagues_dir set - try using builtin from footballdb-leagues
|
83
|
-
FootballDb::Import.build_league_index
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
def build_event_index
|
89
|
-
if config.leagues_dir ## (re)use leagues dir for now - add separate seasons_dir - why? why not?
|
90
|
-
EventIndex.build( config.leagues_dir )
|
91
|
-
else
|
92
|
-
puts "!! WARN - no leagues_dir set; for now NO built-in events in catalog; sorry - fix!!!!"
|
93
|
-
EventIndex.new ## return empty event index
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def build_season_index
|
98
|
-
# note: for now always (re)use the events from the event (info) index
|
99
|
-
SeasonIndex.new( events )
|
100
|
-
end
|
101
|
-
|
102
|
-
end # class Catalog
|
103
|
-
|
104
|
-
end # module Import
|
105
|
-
end # module SportDb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module SportDb
|
4
|
-
module Import
|
5
|
-
|
6
|
-
class Configuration
|
7
|
-
## note: add more configs (open class), see sportdb-formats for original config!!!
|
8
|
-
|
9
|
-
##
|
10
|
-
## todo: allow configure of countries_dir like clubs_dir
|
11
|
-
## "fallback" and use a default built-in world/countries.txt
|
12
|
-
|
13
|
-
####
|
14
|
-
# todo/check: find a better way to configure club / team datasets - why? why not?
|
15
|
-
attr_accessor :clubs_dir
|
16
|
-
## def clubs_dir() @clubs_dir; end ### note: return nil if NOT set on purpose for now - why? why not?
|
17
|
-
|
18
|
-
attr_accessor :leagues_dir
|
19
|
-
## def leagues_dir() @leagues_dir; end
|
20
|
-
|
21
|
-
def catalog() @catalog ||= Catalog.new; end
|
22
|
-
end # class Configuration
|
23
|
-
|
24
|
-
end # module Import
|
25
|
-
end # module SportDb
|
@@ -1,81 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module SportDb
|
4
|
-
module Import
|
5
|
-
|
6
|
-
|
7
|
-
class WikiIndex
|
8
|
-
|
9
|
-
def self.build( path )
|
10
|
-
pack = Package.new( path )
|
11
|
-
recs = []
|
12
|
-
pack.each_clubs_wiki do |entry|
|
13
|
-
recs += WikiReader.parse( entry.read )
|
14
|
-
end
|
15
|
-
recs
|
16
|
-
|
17
|
-
new( recs )
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
include NameHelper
|
22
|
-
## e.g. strip_lang, strip_year, normalize
|
23
|
-
|
24
|
-
## fix/todo:
|
25
|
-
## also used / duplicated in ClubIndex#add_wiki !!!
|
26
|
-
def strip_wiki( name ) # todo/check: rename to strip_wikipedia_en - why? why not?
|
27
|
-
## note: strip disambiguationn qualifier from wikipedia page name if present
|
28
|
-
## note: only remove year and foot... for now
|
29
|
-
## e.g. FC Wacker Innsbruck (2002) => FC Wacker Innsbruck
|
30
|
-
## Willem II (football club) => Willem II
|
31
|
-
##
|
32
|
-
## e.g. do NOT strip others !! e.g.
|
33
|
-
## América Futebol Clube (MG)
|
34
|
-
## only add more "special" cases on demand (that, is) if we find more
|
35
|
-
name = name.gsub( /\([12][^\)]+?\)/, '' ).strip ## starting with a digit 1 or 2 (assuming year)
|
36
|
-
name = name.gsub( /\(foot[^\)]+?\)/, '' ).strip ## starting with foot (assuming football ...)
|
37
|
-
name
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
def initialize( recs )
|
42
|
-
@pages_by_country = {}
|
43
|
-
|
44
|
-
## todo/fix:
|
45
|
-
## check for duplicate recs - report and exit on dupliate!!!!!!
|
46
|
-
recs.each do |rec|
|
47
|
-
h = @pages_by_country[ rec.country.key ] ||= {}
|
48
|
-
h[ normalize( strip_wiki( rec.name )) ] = rec
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
def find_by( club: ) ## todo/check: use find_by_club - why? why not?
|
54
|
-
find_by_club( club )
|
55
|
-
end
|
56
|
-
|
57
|
-
def find_by_club( club )
|
58
|
-
rec = nil
|
59
|
-
|
60
|
-
## get query params from club
|
61
|
-
names = [club.name]+club.alt_names
|
62
|
-
country_key = club.country.key
|
63
|
-
|
64
|
-
h = @pages_by_country[ country_key ]
|
65
|
-
if h
|
66
|
-
## todo/check: sort names ?
|
67
|
-
## sort by longest first (for best match)
|
68
|
-
names.each do |name|
|
69
|
-
## note: normalize AND sanitize (e.g. remove/string year and lang e.g. (1946-2001), [en] too)
|
70
|
-
rec = h[ normalize( strip_year( strip_lang( name ))) ]
|
71
|
-
break if rec ## bingo!! found - break on first match
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
rec ## note: return nil if nothing found
|
76
|
-
end
|
77
|
-
end # class WikiIndex
|
78
|
-
|
79
|
-
|
80
|
-
end # module Import
|
81
|
-
end # module SportDb
|
data/test/helper.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
## note: use the local version of sportdb gems
|
2
|
-
$LOAD_PATH.unshift( File.expand_path( '../sportdb-formats/lib' ))
|
3
|
-
|
4
|
-
## minitest setup
|
5
|
-
require 'minitest/autorun'
|
6
|
-
|
7
|
-
|
8
|
-
## our own code
|
9
|
-
require 'sportdb/catalogs'
|
10
|
-
|
11
|
-
|
12
|
-
SportDb::Import.config.clubs_dir = '../../../openfootball/clubs'
|
13
|
-
SportDb::Import.config.leagues_dir = '../../../openfootball/leagues'
|
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
|