sportdb-config 1.0.1 → 1.1.1
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 -5
- data/lib/sportdb/config.rb +1 -1
- data/lib/sportdb/config/catalog.rb +94 -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 +12 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75debc4f481f8b0cc4bd7f9d885d1bf526527189
|
4
|
+
data.tar.gz: '0489bb3235ebfb289ccf93c758a3c4a0cc7e37de'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 632a90def9488cbdc5eed0b6de6ba7e2796a2050618d7e1c077d6a3084627e94a5ac4c2e9868f6dfacc76115566425e6767b24994c03e654fde27de2c62cded0
|
7
|
+
data.tar.gz: 18882a224e55b3145a3deaf3892bd4f6ef70d3e0d0f1bec92f37d477deb4aa38bf5b1ae8c9aa54b17e7798130fb430bfcea7eca46b24ed0e48ae101ad3276d0a
|
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,11 +20,11 @@ Hoe.spec 'sportdb-config' do
|
|
20
20
|
self.licenses = ['Public Domain']
|
21
21
|
|
22
22
|
self.extra_deps = [
|
23
|
-
['sportdb-formats', '>= 1.0
|
23
|
+
['sportdb-formats', '>= 1.1.0'],
|
24
24
|
## dataset libs / gems
|
25
|
-
['fifa', '>= 2020.5.
|
26
|
-
['footballdb-clubs', '>= 2020.
|
27
|
-
['footballdb-leagues', '>= 2020.
|
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
|
28
28
|
]
|
29
29
|
|
30
30
|
self.spec_extras = {
|
data/lib/sportdb/config.rb
CHANGED
@@ -0,0 +1,94 @@
|
|
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
|
+
def events() @events ||= build_event_index; end
|
19
|
+
def seasons() @seasons ||= build_season_index; end
|
20
|
+
|
21
|
+
|
22
|
+
def build_team_index() TeamIndex.new; end
|
23
|
+
|
24
|
+
def build_country_index ## todo/check: rename to setup_country_index or read_country_index - why? why not?
|
25
|
+
CountryIndex.new( Fifa.countries )
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_national_team_index
|
29
|
+
## auto-build national teams from Fifa.countries for now
|
30
|
+
teams = []
|
31
|
+
Fifa.countries.each do |country|
|
32
|
+
team = NationalTeam.new( key: country.code.downcase, ## note: use country code (fifa)
|
33
|
+
name: country.name,
|
34
|
+
code: country.code, ## note: use country code (fifa)
|
35
|
+
alt_names: country.alt_names )
|
36
|
+
team.country = country
|
37
|
+
|
38
|
+
teams << team
|
39
|
+
end
|
40
|
+
|
41
|
+
NationalTeamIndex.new( teams )
|
42
|
+
end
|
43
|
+
|
44
|
+
def build_club_index
|
45
|
+
## unify team names; team (builtin/known/shared) name mappings
|
46
|
+
## cleanup team names - use local ("native") name with umlaut etc.
|
47
|
+
## todo/fix: add to teamreader
|
48
|
+
## check that name and alt_names for a club are all unique (not duplicates)
|
49
|
+
|
50
|
+
clubs = if config.clubs_dir ## check if clubs_dir is defined / set (otherwise it's nil)
|
51
|
+
ClubIndex.build( config.clubs_dir )
|
52
|
+
else ## no clubs_dir set - try using builtin from footballdb-clubs
|
53
|
+
FootballDb::Import::build_club_index
|
54
|
+
end
|
55
|
+
|
56
|
+
if clubs.errors?
|
57
|
+
puts ""
|
58
|
+
puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
59
|
+
puts " #{clubs.errors.size} errors:"
|
60
|
+
pp clubs.errors
|
61
|
+
## exit 1
|
62
|
+
end
|
63
|
+
|
64
|
+
clubs
|
65
|
+
end # method build_club_index
|
66
|
+
|
67
|
+
|
68
|
+
def build_league_index
|
69
|
+
leagues = if config.leagues_dir ## check if clubs_dir is defined / set (otherwise it's nil)
|
70
|
+
LeagueIndex.build( config.leagues_dir )
|
71
|
+
else ## no leagues_dir set - try using builtin from footballdb-leagues
|
72
|
+
FootballDb::Import.build_league_index
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
def build_event_index
|
78
|
+
if config.leagues_dir ## (re)use leagues dir for now - add separate seasons_dir - why? why not?
|
79
|
+
EventIndex.build( config.leagues_dir )
|
80
|
+
else
|
81
|
+
puts "!! WARN - no leagues_dir set; for now buit-in events in catalog - fix!!!!"
|
82
|
+
EventIndex.new ## return empty event index
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def build_season_index
|
87
|
+
# note: for now always (re)use the events from the event (info) index
|
88
|
+
SeasonIndex.new( events )
|
89
|
+
end
|
90
|
+
|
91
|
+
end # class Catalog
|
92
|
+
|
93
|
+
end # module Import
|
94
|
+
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 = 1
|
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,14 +1,14 @@
|
|
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.1
|
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-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-formats
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0
|
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: 1.0
|
26
|
+
version: 1.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: fifa
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2020.5.
|
33
|
+
version: 2020.5.18
|
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: 2020.5.
|
40
|
+
version: 2020.5.18
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: footballdb-clubs
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2020.
|
47
|
+
version: 2020.6.16
|
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: 2020.
|
54
|
+
version: 2020.6.16
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: footballdb-leagues
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2020.
|
61
|
+
version: 2020.6.16
|
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: 2020.
|
68
|
+
version: 2020.6.16
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rdoc
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- README.md
|
111
111
|
- Rakefile
|
112
112
|
- lib/sportdb/config.rb
|
113
|
+
- lib/sportdb/config/catalog.rb
|
113
114
|
- lib/sportdb/config/config.rb
|
114
115
|
- lib/sportdb/config/version.rb
|
115
116
|
- lib/sportdb/config/wiki_index.rb
|
@@ -117,6 +118,7 @@ files:
|
|
117
118
|
- test/test_clubs.rb
|
118
119
|
- test/test_countries.rb
|
119
120
|
- test/test_leagues.rb
|
121
|
+
- test/test_national_teams.rb
|
120
122
|
- test/test_wiki_index.rb
|
121
123
|
homepage: https://github.com/sportdb/sport.db
|
122
124
|
licenses:
|