sportdb-config 0.9.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.
- checksums.yaml +4 -4
- data/README.md +13 -13
- data/Rakefile +5 -5
- data/lib/sportdb/config/config.rb +5 -123
- data/lib/sportdb/config/version.rb +2 -7
- data/lib/sportdb/config/wiki_index.rb +22 -10
- data/lib/sportdb/config.rb +3 -16
- data/test/helper.rb +2 -3
- data/test/test_clubs.rb +22 -19
- data/test/test_countries.rb +11 -8
- data/test/test_leagues.rb +20 -4
- data/test/test_wiki_index.rb +10 -3
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f9518da3271d41c53429151ae62de407a7fb4a3
|
4
|
+
data.tar.gz: f6c9717adedf654049ff162ac5560f2b41d2da1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb87146374b46e8be05e4a61d6b7b267983dc870bfd8ad4921eb9b88fd1d1d88de7aeabdfc6d0025d3ec6c6c73c2a33e299a5b7e109428ddab8660aa05bea1bd
|
7
|
+
data.tar.gz: ef49c48e64709fc21c123d26fc18404f9bd61f7196fb250fd462abb833c5811f5066c6dc131fed8565f9dd8f9f96cbabdcaa98ab97c3a6b278565b6d70c8359f
|
data/README.md
CHANGED
@@ -32,20 +32,20 @@ m[2].name; m[2].city; m[2].country
|
|
32
32
|
#=> "Arsenal de Sarandí", "Sarandí", "Argentina"
|
33
33
|
|
34
34
|
|
35
|
-
m = SportDb::Import.
|
35
|
+
m = SportDb::Import.catalog.clubs.match_by( name: 'Arsenal', country: 'eng' )
|
36
36
|
# -or- try alternative names (and auto-generated spelling variants)
|
37
|
-
m = SportDb::Import.
|
38
|
-
m = SportDb::Import.
|
39
|
-
m = SportDb::Import.
|
37
|
+
m = SportDb::Import.catalog.clubs.match_by( name: 'Arsenal FC', country: 'eng' )
|
38
|
+
m = SportDb::Import.catalog.clubs.match_by( name: 'Arsenal F.C.', country: 'eng' )
|
39
|
+
m = SportDb::Import.catalog.clubs.match_by( name: '...A.r.s.e.n.a.l... F.C...', country: 'eng' )
|
40
40
|
m.size # 1 club match found
|
41
41
|
#=> 1
|
42
42
|
m[0].name; m[0].city; m[0].country
|
43
43
|
#=> "Arsenal FC", "London", "England"
|
44
44
|
|
45
|
-
m = SportDb::Import.
|
45
|
+
m = SportDb::Import.catalog.clubs.match_by( name: 'Arsenal', country: 'ar' )
|
46
46
|
# -or- try alternative names (and auto-generated spelling variants)
|
47
|
-
m = SportDb::Import.
|
48
|
-
m = SportDb::Import.
|
47
|
+
m = SportDb::Import.catalog.clubs.match_by( name: 'Arsenal Sarandí', country: 'ar' )
|
48
|
+
m = SportDb::Import.catalog.clubs.match_by( name: 'Arsenal Sarandi', country: 'ar' )
|
49
49
|
m.size # 1 club match found
|
50
50
|
#=> 1
|
51
51
|
m[0].name; m[0].city; m[0].country
|
@@ -53,15 +53,15 @@ m[0].name; m[0].city; m[0].country
|
|
53
53
|
|
54
54
|
|
55
55
|
# try some more
|
56
|
-
m = SportDb::Import.
|
56
|
+
m = SportDb::Import.catalog.clubs.match( 'AZ' )
|
57
57
|
m[0].name; m[0].city; m[0].country
|
58
58
|
#=> "AZ Alkmaar", "Alkmaar", "Netherlands"
|
59
59
|
|
60
|
-
m = SportDb::Import.
|
60
|
+
m = SportDb::Import.catalog.clubs.match( 'Bayern' )
|
61
61
|
# -or- try alternative names (and auto-generated spelling variants)
|
62
|
-
m = SportDb::Import.
|
63
|
-
m = SportDb::Import.
|
64
|
-
m = SportDb::Import.
|
62
|
+
m = SportDb::Import.catalog.clubs.match( 'Bayern München' )
|
63
|
+
m = SportDb::Import.catalog.clubs.match( 'Bayern Munchen' )
|
64
|
+
m = SportDb::Import.catalog.clubs.match( 'Bayern Muenchen' )
|
65
65
|
m[0].name; m[0].city; m[0].country
|
66
66
|
#=> "Bayern München", "München", "Germany"
|
67
67
|
|
@@ -72,7 +72,7 @@ m[0].name; m[0].city; m[0].country
|
|
72
72
|
Let's print all names that have duplicate (more than one) matching club:
|
73
73
|
|
74
74
|
``` ruby
|
75
|
-
SportDb::Import.
|
75
|
+
SportDb::Import.catalog.clubs.mappings.each do |name, clubs|
|
76
76
|
if clubs.size > 1
|
77
77
|
puts "#{clubs.size} matching clubs for `#{name}`:"
|
78
78
|
clubs.each do |club|
|
data/Rakefile
CHANGED
@@ -21,12 +21,12 @@ Hoe.spec 'sportdb-config' do
|
|
21
21
|
|
22
22
|
self.extra_deps = [
|
23
23
|
['sportdb-countries', '>= 0.5.1'],
|
24
|
-
['sportdb-clubs', '>= 0.
|
25
|
-
['sportdb-leagues', '>= 0.2.
|
24
|
+
['sportdb-clubs', '>= 0.4.0'],
|
25
|
+
['sportdb-leagues', '>= 0.2.2'],
|
26
26
|
## dataset libs / gems
|
27
|
-
['fifa', '>=
|
28
|
-
['footballdb-clubs', '>=
|
29
|
-
['footballdb-leagues', '>=
|
27
|
+
['fifa', '>= 2019.11.27'], ## for (builtin/default) countries
|
28
|
+
['footballdb-clubs', '>= 2019.11.22'], ## for (builtin/default) clubs
|
29
|
+
['footballdb-leagues', '>= 2019.11.22'], ## for (builtin/default) leagues & cups
|
30
30
|
]
|
31
31
|
|
32
32
|
self.spec_extras = {
|
@@ -1,143 +1,25 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
3
|
module SportDb
|
5
4
|
module Import
|
6
5
|
|
7
|
-
# add builder convenience helper to ClubIndex - why? why not?
|
8
|
-
class ClubIndex
|
9
|
-
|
10
|
-
def self.build( path )
|
11
|
-
recs = []
|
12
|
-
datafiles = Datafile.find_clubs( path )
|
13
|
-
datafiles.each do |datafile|
|
14
|
-
recs += Club.read( datafile )
|
15
|
-
end
|
16
|
-
recs
|
17
|
-
|
18
|
-
clubs = new
|
19
|
-
clubs.add( recs )
|
20
|
-
|
21
|
-
## add wiki(pedia) anchored links
|
22
|
-
recs = []
|
23
|
-
datafiles = Datafile.find_clubs_wiki( path )
|
24
|
-
datafiles.each do |datafile|
|
25
|
-
recs += WikiReader.read( datafile )
|
26
|
-
end
|
27
|
-
|
28
|
-
pp recs
|
29
|
-
clubs.add_wiki( recs )
|
30
|
-
clubs
|
31
|
-
end
|
32
|
-
end # class ClubIndex
|
33
|
-
|
34
|
-
|
35
|
-
class LeagueIndex
|
36
|
-
|
37
|
-
def self.build( path )
|
38
|
-
recs = []
|
39
|
-
datafiles = Datafile.find_leagues( path )
|
40
|
-
datafiles.each do |datafile|
|
41
|
-
recs += League.read( datafile )
|
42
|
-
end
|
43
|
-
recs
|
44
|
-
|
45
|
-
leagues = new
|
46
|
-
leagues.add( recs )
|
47
|
-
leagues
|
48
|
-
end
|
49
|
-
end # class LeagueIndex
|
50
|
-
|
51
|
-
|
52
6
|
class Configuration
|
7
|
+
## note: add more configs (open class), see sportdb-formats for original config!!!
|
53
8
|
|
54
9
|
##
|
55
10
|
## todo: allow configure of countries_dir like clubs_dir
|
56
11
|
## "fallback" and use a default built-in world/countries.txt
|
57
12
|
|
58
|
-
## todo/check: rename to country_mappings/index - why? why not?
|
59
|
-
## or countries_by_code or countries_by_key
|
60
|
-
def countries
|
61
|
-
@countries ||= build_country_index
|
62
|
-
@countries
|
63
|
-
end
|
64
|
-
|
65
|
-
def build_country_index ## todo/check: rename to setup_country_index or read_country_index - why? why not?
|
66
|
-
CountryIndex.new( Fifa.countries )
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
def clubs
|
72
|
-
@clubs ||= build_club_index
|
73
|
-
@clubs
|
74
|
-
end
|
75
|
-
|
76
|
-
def leagues
|
77
|
-
@leagues ||= build_league_index
|
78
|
-
@leagues
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
13
|
####
|
83
|
-
# todo/
|
14
|
+
# todo/check: find a better way to configure club / team datasets - why? why not?
|
84
15
|
attr_accessor :clubs_dir
|
85
|
-
def clubs_dir() @clubs_dir; end ### note: return nil if NOT set on purpose for now - why? why not?
|
16
|
+
## def clubs_dir() @clubs_dir; end ### note: return nil if NOT set on purpose for now - why? why not?
|
86
17
|
|
87
18
|
attr_accessor :leagues_dir
|
88
|
-
def leagues_dir() @leagues_dir; end
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
def build_club_index
|
93
|
-
## unify team names; team (builtin/known/shared) name mappings
|
94
|
-
## cleanup team names - use local ("native") name with umlaut etc.
|
95
|
-
## todo/fix: add to teamreader
|
96
|
-
## check that name and alt_names for a club are all unique (not duplicates)
|
97
|
-
|
98
|
-
clubs = if clubs_dir ## check if clubs_dir is defined / set (otherwise it's nil)
|
99
|
-
ClubIndex.build( clubs_dir )
|
100
|
-
else ## no clubs_dir set - try using builtin from footballdb-clubs
|
101
|
-
## todo/fix: use build_club_index make public (remove private)!!!!
|
102
|
-
FootballDb::Import::Club.club_index
|
103
|
-
end
|
104
|
-
|
105
|
-
if clubs.errors?
|
106
|
-
puts ""
|
107
|
-
puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
108
|
-
puts " #{clubs.errors.size} errors:"
|
109
|
-
pp clubs.errors
|
110
|
-
## exit 1
|
111
|
-
end
|
112
|
-
|
113
|
-
clubs
|
114
|
-
end # method build_club_index
|
115
|
-
|
116
|
-
def build_league_index
|
117
|
-
leagues = if leagues_dir ## check if clubs_dir is defined / set (otherwise it's nil)
|
118
|
-
LeagueIndex.build( leagues_dir )
|
119
|
-
else ## no leagues_dir set - try using builtin from footballdb-leagues
|
120
|
-
## todo/fix: use build_league_index make public (remove private)!!!!
|
121
|
-
FootballDb::Import::League.league_index
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
19
|
+
## def leagues_dir() @leagues_dir; end
|
125
20
|
|
21
|
+
def catalog() @catalog ||= Catalog.new; end
|
126
22
|
end # class Configuration
|
127
23
|
|
128
|
-
|
129
|
-
## lets you use
|
130
|
-
## SportDb::Import.configure do |config|
|
131
|
-
## config.hello = 'World'
|
132
|
-
## end
|
133
|
-
|
134
|
-
def self.configure
|
135
|
-
yield( config )
|
136
|
-
end
|
137
|
-
|
138
|
-
def self.config
|
139
|
-
@config ||= Configuration.new
|
140
|
-
end
|
141
|
-
|
142
24
|
end # module Import
|
143
25
|
end # module SportDb
|
@@ -6,8 +6,8 @@ module SportDb
|
|
6
6
|
module Boot ## note: use a different module than Config to avoid confusion with Configuration/config etc.!!!!
|
7
7
|
## maybe rename later gem itself to sportdb-boot - why? why not?
|
8
8
|
|
9
|
-
MAJOR =
|
10
|
-
MINOR =
|
9
|
+
MAJOR = 1 ## todo: namespace inside version or something - why? why not??
|
10
|
+
MINOR = 0
|
11
11
|
PATCH = 0
|
12
12
|
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
13
13
|
|
@@ -23,10 +23,5 @@ module Boot ## note: use a different module than Config to avoid confusion
|
|
23
23
|
File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )
|
24
24
|
end
|
25
25
|
|
26
|
-
# def self.data_dir ## rename to config_dir - why? why not?
|
27
|
-
# "#{root}/config"
|
28
|
-
# end
|
29
|
-
|
30
|
-
|
31
26
|
end # module Boot
|
32
27
|
end # module SportDb
|
@@ -7,23 +7,35 @@ module SportDb
|
|
7
7
|
class WikiIndex
|
8
8
|
|
9
9
|
def self.build( path )
|
10
|
+
pack = Package.new( path )
|
10
11
|
recs = []
|
11
|
-
|
12
|
-
|
13
|
-
recs += WikiReader.read( datafile )
|
12
|
+
pack.each_clubs_wiki do |entry|
|
13
|
+
recs += WikiReader.parse( entry.read )
|
14
14
|
end
|
15
15
|
recs
|
16
16
|
|
17
|
-
|
17
|
+
new( recs )
|
18
18
|
end
|
19
19
|
|
20
20
|
|
21
|
-
|
22
|
-
##
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
def strip_wiki( name)
|
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
|
27
39
|
|
28
40
|
|
29
41
|
def initialize( recs )
|
data/lib/sportdb/config.rb
CHANGED
@@ -1,33 +1,20 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
### our own sportdb libs / gems
|
4
|
-
require 'sportdb/
|
5
|
-
require 'sportdb/clubs'
|
6
|
-
require 'sportdb/leagues'
|
7
|
-
|
4
|
+
require 'sportdb/formats'
|
8
5
|
|
9
6
|
### "built-in" default dataset libs / gems
|
10
7
|
require 'fifa' ## get a list of all fifa countries with (three letter) codes
|
11
|
-
require 'footballdb/clubs'
|
12
8
|
require 'footballdb/leagues'
|
9
|
+
require 'footballdb/clubs'
|
13
10
|
|
14
11
|
|
15
12
|
###
|
16
13
|
# our own code
|
17
14
|
require 'sportdb/config/version' # let version always go first
|
18
15
|
require 'sportdb/config/wiki_index'
|
16
|
+
require 'sportdb/config/catalog'
|
19
17
|
require 'sportdb/config/config'
|
20
18
|
|
21
19
|
|
22
|
-
|
23
|
-
## use global Import config - required for countries lookup / mapping (service)
|
24
|
-
SportDb::Import::ClubReader.config = SportDb::Import.config
|
25
|
-
SportDb::Import::ClubIndex.config = SportDb::Import.config
|
26
|
-
SportDb::Import::WikiReader.config = SportDb::Import.config
|
27
|
-
|
28
|
-
SportDb::Import::LeagueReader.config = SportDb::Import.config
|
29
|
-
SportDb::Import::LeagueIndex.config = SportDb::Import.config
|
30
|
-
|
31
|
-
|
32
|
-
|
33
20
|
puts SportDb::Boot.banner # say hello
|
data/test/helper.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
##
|
1
|
+
## note: use the local version of sportdb gems
|
2
|
+
$LOAD_PATH.unshift( File.expand_path( '../sportdb-formats/lib' ))
|
2
3
|
|
3
4
|
## minitest setup
|
4
|
-
|
5
5
|
require 'minitest/autorun'
|
6
6
|
|
7
7
|
|
8
8
|
## our own code
|
9
|
-
|
10
9
|
require 'sportdb/config'
|
11
10
|
|
12
11
|
|
data/test/test_clubs.rb
CHANGED
@@ -9,88 +9,91 @@ require 'helper'
|
|
9
9
|
|
10
10
|
class TestClubs < MiniTest::Test
|
11
11
|
|
12
|
+
CLUBS = SportDb::Import.catalog.clubs
|
13
|
+
|
14
|
+
|
12
15
|
def test_match
|
13
|
-
pp
|
16
|
+
pp CLUBS.errors
|
14
17
|
|
15
|
-
|
18
|
+
CLUBS.dump_duplicates
|
16
19
|
|
17
|
-
m =
|
20
|
+
m = CLUBS.match( 'Rapid Wien' )
|
18
21
|
assert_equal 'SK Rapid Wien', m[0].name
|
19
22
|
assert_equal 'Austria', m[0].country.name
|
20
23
|
assert_equal 'Wien', m[0].city
|
21
24
|
|
22
|
-
m =
|
25
|
+
m = CLUBS.match( 'rapid wien' )
|
23
26
|
assert_equal 'SK Rapid Wien', m[0].name
|
24
27
|
assert_equal 'Austria', m[0].country.name
|
25
28
|
assert_equal 'Wien', m[0].city
|
26
29
|
|
27
30
|
## note: all dots (.) get always removed
|
28
|
-
m =
|
31
|
+
m = CLUBS.match( '...r.a.p.i.d w.i.e.n...' )
|
29
32
|
assert_equal 'SK Rapid Wien', m[0].name
|
30
33
|
assert_equal 'Austria', m[0].country.name
|
31
34
|
assert_equal 'Wien', m[0].city
|
32
35
|
|
33
36
|
## note: all spaces and dashes (-) get always removed
|
34
|
-
m =
|
37
|
+
m = CLUBS.match( '--- r a p i d w i e n ---' )
|
35
38
|
assert_equal 'SK Rapid Wien', m[0].name
|
36
39
|
assert_equal 'Austria', m[0].country.name
|
37
40
|
assert_equal 'Wien', m[0].city
|
38
41
|
|
39
|
-
m =
|
42
|
+
m = CLUBS.match( 'RAPID WIEN' )
|
40
43
|
assert_equal 'SK Rapid Wien', m[0].name
|
41
44
|
assert_equal 'Austria', m[0].country.name
|
42
45
|
assert_equal 'Wien', m[0].city
|
43
46
|
|
44
47
|
|
45
|
-
c =
|
48
|
+
c = CLUBS[ 'SK Rapid Wien' ] ## check canoncial name match (only)
|
46
49
|
assert_equal 'SK Rapid Wien', c.name
|
47
50
|
assert_equal 'Austria', c.country.name
|
48
51
|
assert_equal 'Wien', c.city
|
49
52
|
|
50
53
|
|
51
|
-
m =
|
54
|
+
m = CLUBS.match( 'Arsenal' )
|
52
55
|
assert_equal 3, m.size
|
53
56
|
|
54
|
-
m =
|
57
|
+
m = CLUBS.match( 'ARSENAL' )
|
55
58
|
assert_equal 3, m.size
|
56
59
|
|
57
|
-
m =
|
60
|
+
m = CLUBS.match_by( name: 'Arsenal', country: 'eng' )
|
58
61
|
assert_equal 1, m.size
|
59
62
|
assert_equal 'Arsenal FC', m[0].name
|
60
63
|
assert_equal 'England', m[0].country.name
|
61
64
|
assert_equal 'London', m[0].city
|
62
65
|
|
63
|
-
m =
|
66
|
+
m = CLUBS.match_by( name: 'Arsenal', country: 'ar' )
|
64
67
|
assert_equal 1, m.size
|
65
68
|
assert_equal 'Arsenal de Sarandí', m[0].name
|
66
69
|
assert_equal 'Argentina', m[0].country.name
|
67
70
|
assert_equal 'Sarandí', m[0].city
|
68
71
|
|
69
|
-
m =
|
72
|
+
m = CLUBS.match_by( name: 'Arsenal', country: 'ru' )
|
70
73
|
assert_equal 1, m.size
|
71
74
|
assert_equal 'Arsenal Tula', m[0].name
|
72
75
|
assert_equal 'Russia', m[0].country.name
|
73
76
|
assert_equal 'Tula', m[0].city
|
74
77
|
|
75
78
|
|
76
|
-
m =
|
79
|
+
m = CLUBS.match( 'Arsenal FC' )
|
77
80
|
assert_equal 2, m.size
|
78
81
|
|
79
|
-
m =
|
82
|
+
m = CLUBS.match( 'Arsenal F.C.' )
|
80
83
|
assert_equal 2, m.size
|
81
84
|
|
82
|
-
m =
|
85
|
+
m = CLUBS.match( '...A.r.s.e.n.a.l... F.C...' )
|
83
86
|
assert_equal 2, m.size
|
84
87
|
end
|
85
88
|
|
86
|
-
def test_wikipedia ## test wikipedia names and links/urls
|
87
89
|
|
88
|
-
|
90
|
+
def test_wikipedia ## test wikipedia names and links/urls
|
91
|
+
m = CLUBS.match( 'Club Brugge KV' )
|
89
92
|
assert_equal 1, m.size
|
90
93
|
assert_equal 'Club Brugge KV', m[0].wikipedia
|
91
94
|
assert_equal 'https://en.wikipedia.org/wiki/Club_Brugge_KV', m[0].wikipedia_url
|
92
95
|
|
93
|
-
m =
|
96
|
+
m = CLUBS.match( 'RSC Anderlecht' )
|
94
97
|
assert_equal 1, m.size
|
95
98
|
assert_equal 'R.S.C. Anderlecht', m[0].wikipedia
|
96
99
|
assert_equal 'https://en.wikipedia.org/wiki/R.S.C._Anderlecht', m[0].wikipedia_url
|
data/test/test_countries.rb
CHANGED
@@ -9,24 +9,27 @@ require 'helper'
|
|
9
9
|
|
10
10
|
class TestCountries < MiniTest::Test
|
11
11
|
|
12
|
+
COUNTRIES = SportDb::Import.catalog.countries
|
13
|
+
|
14
|
+
|
12
15
|
def test_countries
|
13
|
-
## pp
|
16
|
+
## pp COUNTRIES
|
14
17
|
|
15
|
-
eng =
|
18
|
+
eng = COUNTRIES[:eng]
|
16
19
|
assert_equal 'eng', eng.key
|
17
20
|
assert_equal 'England', eng.name
|
18
21
|
assert_equal 'ENG', eng.fifa
|
19
22
|
|
20
|
-
at =
|
23
|
+
at = COUNTRIES[:at]
|
21
24
|
assert_equal 'at', at.key
|
22
25
|
assert_equal 'Austria', at.name
|
23
26
|
assert_equal 'AUT', at.fifa
|
24
27
|
|
25
|
-
assert at ==
|
26
|
-
assert at ==
|
27
|
-
assert at ==
|
28
|
-
assert at ==
|
29
|
-
assert at ==
|
28
|
+
assert at == COUNTRIES['AT']
|
29
|
+
assert at == COUNTRIES['at']
|
30
|
+
assert at == COUNTRIES['AUT']
|
31
|
+
assert at == COUNTRIES['aut']
|
32
|
+
assert at == COUNTRIES[:aut]
|
30
33
|
end
|
31
34
|
|
32
35
|
end # class TestCountries
|
data/test/test_leagues.rb
CHANGED
@@ -9,16 +9,32 @@ require 'helper'
|
|
9
9
|
|
10
10
|
class TestLeagues < MiniTest::Test
|
11
11
|
|
12
|
+
LEAGUES = SportDb::Import.catalog.leagues
|
13
|
+
|
14
|
+
|
12
15
|
def test_match
|
13
|
-
pp
|
16
|
+
pp LEAGUES.errors
|
14
17
|
|
15
|
-
|
18
|
+
LEAGUES.dump_duplicates
|
16
19
|
|
17
|
-
m =
|
18
|
-
|
20
|
+
m = LEAGUES.match( 'English Premier League' )
|
21
|
+
pp m
|
22
|
+
assert_equal 'Premier League', m[0].name
|
19
23
|
assert_equal 'eng.1', m[0].key
|
20
24
|
assert_equal 'England', m[0].country.name
|
21
25
|
assert_equal 'eng', m[0].country.key
|
26
|
+
assert m[0].clubs?
|
27
|
+
assert m[0].domestic?
|
28
|
+
assert_equal false, m[0].intl?
|
29
|
+
assert_equal false, m[0].national_teams?
|
30
|
+
|
31
|
+
m = LEAGUES.match( 'Euro' )
|
32
|
+
pp m
|
33
|
+
assert_equal 'Euro', m[0].name
|
34
|
+
assert_equal 'euro', m[0].key
|
35
|
+
assert m[0].national_teams?
|
36
|
+
assert m[0].intl?
|
37
|
+
assert_equal false, m[0].clubs?
|
22
38
|
end
|
23
39
|
|
24
40
|
end # class TestLeagues
|
data/test/test_wiki_index.rb
CHANGED
@@ -9,15 +9,22 @@ require 'helper'
|
|
9
9
|
|
10
10
|
class TestWikiIndex < MiniTest::Test
|
11
11
|
|
12
|
+
Club = SportDb::Import::Club
|
13
|
+
|
14
|
+
COUNTRIES = SportDb::Import.catalog.countries
|
15
|
+
|
16
|
+
|
12
17
|
def test_clubs
|
18
|
+
return if SportDb::Import.config.clubs_dir.nil? ## note: can't run if no "custom" clubs_dir set
|
19
|
+
|
13
20
|
wiki = SportDb::Import::WikiIndex.build( SportDb::Import.config.clubs_dir )
|
14
21
|
## pp wiki
|
15
22
|
|
16
23
|
##############################################
|
17
24
|
## test wikipedia names and links/urls
|
18
|
-
be =
|
25
|
+
be = COUNTRIES.find( 'be' )
|
19
26
|
|
20
|
-
club =
|
27
|
+
club = Club.new
|
21
28
|
club.name = 'Club Brugge KV'
|
22
29
|
club.country = be
|
23
30
|
|
@@ -25,7 +32,7 @@ class TestWikiIndex < MiniTest::Test
|
|
25
32
|
assert_equal 'Club Brugge KV', rec.name
|
26
33
|
|
27
34
|
|
28
|
-
club =
|
35
|
+
club = Club.new
|
29
36
|
club.name = 'RSC Anderlecht'
|
30
37
|
club.country = be
|
31
38
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-countries
|
@@ -30,70 +30,70 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.4.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: 0.
|
40
|
+
version: 0.4.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sportdb-leagues
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.2.
|
47
|
+
version: 0.2.2
|
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: 0.2.
|
54
|
+
version: 0.2.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: fifa
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2019.11.27
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 2019.11.27
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: footballdb-clubs
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 2019.11.22
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 2019.11.22
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: footballdb-leagues
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 2019.11.22
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 2019.11.22
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rdoc
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|