sportdb-config 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +2 -0
- data/NOTES.md +1 -0
- data/Rakefile +5 -7
- data/lib/sportdb/config.rb +1 -1
- data/lib/sportdb/config/catalog.rb +75 -0
- data/lib/sportdb/config/version.rb +6 -5
- data/test/test_countries.rb +2 -2
- data/test/test_national_teams.rb +40 -0
- metadata +13 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72a9ce4c1edae6d428da40e3764282fea81995ae
|
4
|
+
data.tar.gz: aaf4a46f110099605e72df4f40cc416dba485ae2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32e485f24c938a59930978a95ce51734853af0c068d64d039cce9e10ca68532d14658c938f7c7a292b4f5a7d82d17dd4a9b7a1f1b69342c93c9080c4f77983be
|
7
|
+
data.tar.gz: 358731992f199ab916f07316ad9677972f8a8ddb76d75fdc83147e633af571bc4059e83b4a038eb121e924f01c2582d8aaaa6846e52ba948cde8abeb115cfe88
|
data/Manifest.txt
CHANGED
@@ -4,6 +4,7 @@ NOTES.md
|
|
4
4
|
README.md
|
5
5
|
Rakefile
|
6
6
|
lib/sportdb/config.rb
|
7
|
+
lib/sportdb/config/catalog.rb
|
7
8
|
lib/sportdb/config/config.rb
|
8
9
|
lib/sportdb/config/version.rb
|
9
10
|
lib/sportdb/config/wiki_index.rb
|
@@ -11,4 +12,5 @@ test/helper.rb
|
|
11
12
|
test/test_clubs.rb
|
12
13
|
test/test_countries.rb
|
13
14
|
test/test_leagues.rb
|
15
|
+
test/test_national_teams.rb
|
14
16
|
test/test_wiki_index.rb
|
data/NOTES.md
CHANGED
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require './lib/sportdb/config/version.rb'
|
|
3
3
|
|
4
4
|
Hoe.spec 'sportdb-config' do
|
5
5
|
|
6
|
-
self.version = SportDb::
|
6
|
+
self.version = SportDb::Module::Catalogs::VERSION
|
7
7
|
|
8
8
|
self.summary = "sportdb-config - sport.db configuration settings and built-in defaults"
|
9
9
|
self.description = summary
|
@@ -20,13 +20,11 @@ Hoe.spec 'sportdb-config' do
|
|
20
20
|
self.licenses = ['Public Domain']
|
21
21
|
|
22
22
|
self.extra_deps = [
|
23
|
-
['sportdb-
|
24
|
-
['sportdb-clubs', '>= 0.4.0'],
|
25
|
-
['sportdb-leagues', '>= 0.2.2'],
|
23
|
+
['sportdb-formats', '>= 1.1.0'],
|
26
24
|
## dataset libs / gems
|
27
|
-
['fifa', '>=
|
28
|
-
['footballdb-clubs', '>=
|
29
|
-
['footballdb-leagues', '>=
|
25
|
+
['fifa', '>= 2020.5.18'], ## for (builtin/default) countries
|
26
|
+
['footballdb-clubs', '>= 2020.6.16'], ## for (builtin/default) clubs
|
27
|
+
['footballdb-leagues', '>= 2020.6.16'], ## for (builtin/default) leagues & cups
|
30
28
|
]
|
31
29
|
|
32
30
|
self.spec_extras = {
|
data/lib/sportdb/config.rb
CHANGED
@@ -0,0 +1,75 @@
|
|
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 teams() @teams ||= build_team_index; end
|
16
|
+
def leagues() @leagues ||= build_league_index; end
|
17
|
+
|
18
|
+
|
19
|
+
def build_team_index() TeamIndex.new; end
|
20
|
+
|
21
|
+
def build_country_index ## todo/check: rename to setup_country_index or read_country_index - why? why not?
|
22
|
+
CountryIndex.new( Fifa.countries )
|
23
|
+
end
|
24
|
+
|
25
|
+
def build_national_team_index
|
26
|
+
## auto-build national teams from Fifa.countries for now
|
27
|
+
teams = []
|
28
|
+
Fifa.countries.each do |country|
|
29
|
+
team = NationalTeam.new( key: country.code.downcase, ## note: use country code (fifa)
|
30
|
+
name: country.name,
|
31
|
+
code: country.code, ## note: use country code (fifa)
|
32
|
+
alt_names: country.alt_names )
|
33
|
+
team.country = country
|
34
|
+
|
35
|
+
teams << team
|
36
|
+
end
|
37
|
+
|
38
|
+
NationalTeamIndex.new( teams )
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_club_index
|
42
|
+
## unify team names; team (builtin/known/shared) name mappings
|
43
|
+
## cleanup team names - use local ("native") name with umlaut etc.
|
44
|
+
## todo/fix: add to teamreader
|
45
|
+
## check that name and alt_names for a club are all unique (not duplicates)
|
46
|
+
|
47
|
+
clubs = if config.clubs_dir ## check if clubs_dir is defined / set (otherwise it's nil)
|
48
|
+
ClubIndex.build( config.clubs_dir )
|
49
|
+
else ## no clubs_dir set - try using builtin from footballdb-clubs
|
50
|
+
FootballDb::Import::build_club_index
|
51
|
+
end
|
52
|
+
|
53
|
+
if clubs.errors?
|
54
|
+
puts ""
|
55
|
+
puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
56
|
+
puts " #{clubs.errors.size} errors:"
|
57
|
+
pp clubs.errors
|
58
|
+
## exit 1
|
59
|
+
end
|
60
|
+
|
61
|
+
clubs
|
62
|
+
end # method build_club_index
|
63
|
+
|
64
|
+
|
65
|
+
def build_league_index
|
66
|
+
leagues = if config.leagues_dir ## check if clubs_dir is defined / set (otherwise it's nil)
|
67
|
+
LeagueIndex.build( config.leagues_dir )
|
68
|
+
else ## no leagues_dir set - try using builtin from footballdb-leagues
|
69
|
+
FootballDb::Import.build_league_index
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end # class Catalog
|
73
|
+
|
74
|
+
end # module Import
|
75
|
+
end # module SportDb
|
@@ -1,13 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
|
4
|
-
|
5
4
|
module SportDb
|
6
|
-
module
|
7
|
-
|
5
|
+
module Module
|
6
|
+
module Catalogs
|
8
7
|
|
9
8
|
MAJOR = 1 ## todo: namespace inside version or something - why? why not??
|
10
|
-
MINOR =
|
9
|
+
MINOR = 1
|
11
10
|
PATCH = 0
|
12
11
|
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
13
12
|
|
@@ -15,6 +14,7 @@ module Boot ## note: use a different module than Config to avoid confusion
|
|
15
14
|
VERSION
|
16
15
|
end
|
17
16
|
|
17
|
+
## todo/fix: rename to sportdb-catalogs - why? why not?
|
18
18
|
def self.banner
|
19
19
|
"sportdb-config/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
20
20
|
end
|
@@ -23,5 +23,6 @@ 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
|
-
end # module
|
26
|
+
end # module Catalogs
|
27
|
+
end # module Module
|
27
28
|
end # module SportDb
|
data/test/test_countries.rb
CHANGED
@@ -18,12 +18,12 @@ class TestCountries < MiniTest::Test
|
|
18
18
|
eng = COUNTRIES[:eng]
|
19
19
|
assert_equal 'eng', eng.key
|
20
20
|
assert_equal 'England', eng.name
|
21
|
-
assert_equal 'ENG', eng.
|
21
|
+
assert_equal 'ENG', eng.code
|
22
22
|
|
23
23
|
at = COUNTRIES[:at]
|
24
24
|
assert_equal 'at', at.key
|
25
25
|
assert_equal 'Austria', at.name
|
26
|
-
assert_equal 'AUT', at.
|
26
|
+
assert_equal 'AUT', at.code
|
27
27
|
|
28
28
|
assert at == COUNTRIES['AT']
|
29
29
|
assert at == COUNTRIES['at']
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_national_teams.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
class TestNationalTeams < MiniTest::Test
|
11
|
+
|
12
|
+
NATIONAL_TEAMS = SportDb::Import.catalog.national_teams
|
13
|
+
|
14
|
+
|
15
|
+
def test_find
|
16
|
+
t = NATIONAL_TEAMS.find( 'AUT' )
|
17
|
+
assert_equal 'Austria', t.name
|
18
|
+
assert_equal 'aut', t.key
|
19
|
+
assert_equal 'AUT', t.code
|
20
|
+
|
21
|
+
|
22
|
+
t = NATIONAL_TEAMS.find( 'England' )
|
23
|
+
assert_equal 'England', t.name
|
24
|
+
assert_equal 'eng', t.key
|
25
|
+
assert_equal 'ENG', t.code
|
26
|
+
|
27
|
+
## note: all dots (.) get always removed
|
28
|
+
t = NATIONAL_TEAMS.find( '...e.n.g.l.a.n.d...' )
|
29
|
+
assert_equal 'England', t.name
|
30
|
+
assert_equal 'eng', t.key
|
31
|
+
assert_equal 'ENG', t.code
|
32
|
+
|
33
|
+
## note: all spaces and dashes (-) get always removed
|
34
|
+
t = NATIONAL_TEAMS.find( '--- e n g l a n d ---' )
|
35
|
+
assert_equal 'England', t.name
|
36
|
+
assert_equal 'eng', t.key
|
37
|
+
assert_equal 'ENG', t.code
|
38
|
+
end
|
39
|
+
|
40
|
+
end # class TestNationalTeams
|
metadata
CHANGED
@@ -1,99 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.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: 2020-
|
11
|
+
date: 2020-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: sportdb-
|
14
|
+
name: sportdb-formats
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.1.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:
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: sportdb-clubs
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.4.0
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 0.4.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: sportdb-leagues
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.2.2
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.2.2
|
26
|
+
version: 1.1.0
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
28
|
name: fifa
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
58
30
|
requirements:
|
59
31
|
- - ">="
|
60
32
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
33
|
+
version: 2020.5.18
|
62
34
|
type: :runtime
|
63
35
|
prerelease: false
|
64
36
|
version_requirements: !ruby/object:Gem::Requirement
|
65
37
|
requirements:
|
66
38
|
- - ">="
|
67
39
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
40
|
+
version: 2020.5.18
|
69
41
|
- !ruby/object:Gem::Dependency
|
70
42
|
name: footballdb-clubs
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
72
44
|
requirements:
|
73
45
|
- - ">="
|
74
46
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
47
|
+
version: 2020.6.16
|
76
48
|
type: :runtime
|
77
49
|
prerelease: false
|
78
50
|
version_requirements: !ruby/object:Gem::Requirement
|
79
51
|
requirements:
|
80
52
|
- - ">="
|
81
53
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
54
|
+
version: 2020.6.16
|
83
55
|
- !ruby/object:Gem::Dependency
|
84
56
|
name: footballdb-leagues
|
85
57
|
requirement: !ruby/object:Gem::Requirement
|
86
58
|
requirements:
|
87
59
|
- - ">="
|
88
60
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
61
|
+
version: 2020.6.16
|
90
62
|
type: :runtime
|
91
63
|
prerelease: false
|
92
64
|
version_requirements: !ruby/object:Gem::Requirement
|
93
65
|
requirements:
|
94
66
|
- - ">="
|
95
67
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
68
|
+
version: 2020.6.16
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
70
|
name: rdoc
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,6 +110,7 @@ files:
|
|
138
110
|
- README.md
|
139
111
|
- Rakefile
|
140
112
|
- lib/sportdb/config.rb
|
113
|
+
- lib/sportdb/config/catalog.rb
|
141
114
|
- lib/sportdb/config/config.rb
|
142
115
|
- lib/sportdb/config/version.rb
|
143
116
|
- lib/sportdb/config/wiki_index.rb
|
@@ -145,6 +118,7 @@ files:
|
|
145
118
|
- test/test_clubs.rb
|
146
119
|
- test/test_countries.rb
|
147
120
|
- test/test_leagues.rb
|
121
|
+
- test/test_national_teams.rb
|
148
122
|
- test/test_wiki_index.rb
|
149
123
|
homepage: https://github.com/sportdb/sport.db
|
150
124
|
licenses:
|