sportdb-config 0.6.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c2c01fdd2e8ff942c611f48d710ab0ccd6ddb88
4
- data.tar.gz: 86bf655cde4e2474bc1ac31448494e5381a73622
3
+ metadata.gz: 764ca27d3655813274fb75c7ccbb8f1d4e1dcb71
4
+ data.tar.gz: eef58b830eda10906d497555c681aab449436be0
5
5
  SHA512:
6
- metadata.gz: 0ddb39ee84dd3481384092114e80012b653cd7928c58c47c3f55ad2642d3e8bab2df4cc85f1c14b300d893cc640e4c74e333950cfa9fd1e8d4f02a92223f63d7
7
- data.tar.gz: fd4e20c0cf5b5bff7ad2c740816e3f97a567dcf0e1ee8d902e4961aa71686e138a46f575fe7538d0121224519d2056342635f2b15f2a55eee7c5c90339f1f0c7
6
+ metadata.gz: de0e7967586e5e1ef5b90bbcc0eba6b780d56d089a951dc3dab767b4c0b229b2c92afa4768c452702b23f5c8c17dd99b65254672e9534ab29a6987c629f1023d
7
+ data.tar.gz: 299672688171ddd354c55ee42a98eef867d90a5af345fa1885d23934a5811bd4610cab371f24c293fc77cc22178f1c901d74282a7fee862c58288285794dd02f
File without changes
data/Manifest.txt CHANGED
@@ -1,4 +1,4 @@
1
- HISTORY.md
1
+ CHANGELOG.md
2
2
  Manifest.txt
3
3
  NOTES.md
4
4
  README.md
@@ -13,28 +13,18 @@ config/world/be.txt
13
13
  config/world/de.txt
14
14
  config/world/eng.txt
15
15
  lib/sportdb/config.rb
16
- lib/sportdb/config/club.rb
17
- lib/sportdb/config/club_index.rb
18
- lib/sportdb/config/club_reader.rb
19
16
  lib/sportdb/config/config.rb
20
- lib/sportdb/config/countries.rb
21
17
  lib/sportdb/config/league.rb
22
18
  lib/sportdb/config/league_reader.rb
23
19
  lib/sportdb/config/league_utils.rb
24
20
  lib/sportdb/config/season_utils.rb
25
- lib/sportdb/config/variants.rb
26
21
  lib/sportdb/config/version.rb
27
22
  lib/sportdb/config/wiki_index.rb
28
- lib/sportdb/config/wiki_reader.rb
29
23
  test/helper.rb
30
- test/test_club_index.rb
31
- test/test_club_reader.rb
32
24
  test/test_clubs.rb
33
25
  test/test_config.rb
34
26
  test/test_countries.rb
35
27
  test/test_league_reader.rb
36
28
  test/test_league_utils.rb
37
29
  test/test_season_utils.rb
38
- test/test_variants.rb
39
30
  test/test_wiki_index.rb
40
- test/test_wiki_reader.rb
data/Rakefile CHANGED
@@ -11,16 +11,20 @@ Hoe.spec 'sportdb-config' do
11
11
  self.urls = ['https://github.com/sportdb/sport.db']
12
12
 
13
13
  self.author = 'Gerald Bauer'
14
- self.email = 'opensport@googlegroups.com'
14
+ self.email = 'opensport@googlegroups.com'
15
15
 
16
16
  # switch extension to .markdown for gihub formatting
17
- self.readme_file = 'README.md'
18
- self.history_file = 'HISTORY.md'
17
+ self.readme_file = 'README.md'
18
+ self.history_file = 'CHANGELOG.md'
19
19
 
20
20
  self.licenses = ['Public Domain']
21
21
 
22
22
  self.extra_deps = [
23
- ['fifa', '>= 0.1.1'],
23
+ ['sportdb-countries', '>= 0.2.0'],
24
+ ['sportdb-clubs', '>= 0.2.0'],
25
+ ## dataset libs / gems
26
+ ['fifa', '>= 1.0.0'], ## for (builtin/default) countries
27
+ ['footballdb-clubs', '>= 0.2.0'], ## for (builtin/default) clubs
24
28
  ]
25
29
 
26
30
  self.spec_extras = {
@@ -1,20 +1,12 @@
1
1
  # encoding: utf-8
2
2
 
3
+ ### our own sportdb libs / gems
4
+ require 'sportdb/countries'
5
+ require 'sportdb/clubs'
3
6
 
4
- require 'pp'
5
- require 'date'
6
- require 'fileutils'
7
-
8
-
9
- ## 3rd party gems
10
- require 'csvreader'
11
-
12
- def read_csv( path )
13
- CsvHash.read( path, :header_converters => :symbol )
14
- end
15
-
16
-
7
+ ### "built-in" default dataset libs / gems
17
8
  require 'fifa' ## get a list of all fifa countries with (three letter) codes
9
+ require 'footballdb/clubs'
18
10
 
19
11
 
20
12
  ###
@@ -25,31 +17,15 @@ require 'sportdb/config/season_utils'
25
17
  require 'sportdb/config/league_utils'
26
18
  require 'sportdb/config/league'
27
19
  require 'sportdb/config/league_reader'
28
-
29
- require 'sportdb/config/variants'
30
- require 'sportdb/config/countries'
31
- require 'sportdb/config/club'
32
- require 'sportdb/config/club_reader'
33
- require 'sportdb/config/club_index'
34
- require 'sportdb/config/wiki_reader'
35
20
  require 'sportdb/config/wiki_index'
36
21
  require 'sportdb/config/config'
37
22
 
38
23
 
39
24
 
40
-
41
- ## let's put test configuration in its own namespace / module
42
- module SportDb
43
-
44
- class Test ## todo/check: works with module too? use a module - why? why not?
45
-
46
- ####
47
- # todo/fix: find a better way to configure shared test datasets - why? why not?
48
- def self.data_dir() @data_dir ||= './test'; end
49
- def self.data_dir=( path ) @data_dir = path; end
50
- end
51
-
52
- end # module SportDb
25
+ ## use global Import config - required for countries lookup / mapping (service)
26
+ SportDb::Import::ClubReader.config = SportDb::Import.config
27
+ SportDb::Import::ClubIndex.config = SportDb::Import.config
28
+ SportDb::Import::WikiReader.config = SportDb::Import.config
53
29
 
54
30
 
55
31
 
@@ -3,6 +3,33 @@
3
3
  module SportDb
4
4
  module Import
5
5
 
6
+ # add builder convenience helper to ClubIndex
7
+ class ClubIndex
8
+
9
+ def self.build( path )
10
+ recs = []
11
+ datafiles = Configuration.find_datafiles_clubs( path )
12
+ datafiles.each do |datafile|
13
+ recs += ClubReader.read( datafile )
14
+ end
15
+ recs
16
+
17
+ clubs = self.new
18
+ clubs.add( recs )
19
+
20
+ ## add wiki(pedia) anchored links
21
+ recs = []
22
+ datafiles = Configuration.find_datafiles_clubs_wiki( path )
23
+ datafiles.each do |datafile|
24
+ recs += WikiReader.read( datafile )
25
+ end
26
+
27
+ pp recs
28
+ clubs.add_wiki( recs )
29
+ clubs
30
+ end
31
+ end # class ClubIndex
32
+
6
33
 
7
34
  class Configuration
8
35
 
@@ -31,7 +58,7 @@ class Configuration
31
58
  ####
32
59
  # todo/fix: find a better way to configure club / team datasets
33
60
  attr_accessor :clubs_dir
34
- def clubs_dir() @clubs_dir ||= './clubs'; end
61
+ def clubs_dir() @clubs_dir; end ### note: return nil if NOT set on purpose for now - why? why not?
35
62
 
36
63
 
37
64
  CLUBS_REGEX = %r{ (?:^|/) # beginning (^) or beginning of path (/)
@@ -63,13 +90,20 @@ class Configuration
63
90
  def self.find_datafiles_clubs_wiki( path ) find_datafiles( path, CLUBS_WIKI_REGEX ); end
64
91
 
65
92
 
93
+
66
94
  def build_club_index
67
95
  ## unify team names; team (builtin/known/shared) name mappings
68
96
  ## cleanup team names - use local ("native") name with umlaut etc.
69
97
  ## todo/fix: add to teamreader
70
98
  ## check that name and alt_names for a club are all unique (not duplicates)
71
99
 
72
- clubs = ClubIndex.build( clubs_dir )
100
+ clubs = if clubs_dir ## check if clubs_dir is defined / set (otherwise it's nil)
101
+ ClubIndex.build( clubs_dir )
102
+ else ## no clubs_dir set - try using builtin from footballdb-clubs
103
+ ## todo/fix: use build_club_index make public (remove private)!!!!
104
+ FootballDb::Club.club_index
105
+ end
106
+
73
107
  if clubs.errors?
74
108
  puts ""
75
109
  puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
@@ -82,8 +116,6 @@ class Configuration
82
116
  end # method build_club_index
83
117
 
84
118
 
85
-
86
-
87
119
  def leagues
88
120
  read_leagues() if @leagues.nil?
89
121
  @leagues
@@ -7,7 +7,7 @@ module Boot ## note: use a different module than Config to avoid confusion
7
7
  ## maybe rename later gem itself to sportdb-boot - why? why not?
8
8
 
9
9
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
10
- MINOR = 6
10
+ MINOR = 7
11
11
  PATCH = 0
12
12
  VERSION = [MAJOR,MINOR,PATCH].join('.')
13
13
 
data/test/test_clubs.rb CHANGED
@@ -9,35 +9,91 @@ require 'helper'
9
9
 
10
10
  class TestClubs < MiniTest::Test
11
11
 
12
- def strip_lang( name ) SportDb::Import::Club.strip_lang( name ); end
13
- def strip_year( name ) SportDb::Import::Club.strip_year( name ); end
12
+ def test_match
13
+ pp SportDb::Import.config.clubs.errors
14
14
 
15
+ SportDb::Import.config.clubs.dump_duplicates
15
16
 
16
- def test_lang
17
- assert_equal 'Bayern Munich', strip_lang( 'Bayern Munich [en]' )
18
- end
17
+ m = SportDb::Import.config.clubs.match( 'Rapid Wien' )
18
+ assert_equal 'SK Rapid Wien', m[0].name
19
+ assert_equal 'Austria', m[0].country.name
20
+ assert_equal 'Wien', m[0].city
21
+
22
+ m = SportDb::Import.config.clubs.match( 'rapid wien' )
23
+ assert_equal 'SK Rapid Wien', m[0].name
24
+ assert_equal 'Austria', m[0].country.name
25
+ assert_equal 'Wien', m[0].city
26
+
27
+ ## note: all dots (.) get always removed
28
+ m = SportDb::Import.config.clubs.match( '...r.a.p.i.d w.i.e.n...' )
29
+ assert_equal 'SK Rapid Wien', m[0].name
30
+ assert_equal 'Austria', m[0].country.name
31
+ assert_equal 'Wien', m[0].city
32
+
33
+ ## note: all spaces and dashes (-) get always removed
34
+ m = SportDb::Import.config.clubs.match( '--- r a p i d w i e n ---' )
35
+ assert_equal 'SK Rapid Wien', m[0].name
36
+ assert_equal 'Austria', m[0].country.name
37
+ assert_equal 'Wien', m[0].city
38
+
39
+ m = SportDb::Import.config.clubs.match( 'RAPID WIEN' )
40
+ assert_equal 'SK Rapid Wien', m[0].name
41
+ assert_equal 'Austria', m[0].country.name
42
+ assert_equal 'Wien', m[0].city
43
+
44
+
45
+ c = SportDb::Import.config.clubs[ 'SK Rapid Wien' ] ## check canoncial name match (only)
46
+ assert_equal 'SK Rapid Wien', c.name
47
+ assert_equal 'Austria', c.country.name
48
+ assert_equal 'Wien', c.city
19
49
 
20
- def test_year
21
- assert_equal 'FC Linz', strip_year( 'FC Linz (1946-2001, 2013-)' )
22
- end
23
50
 
51
+ m = SportDb::Import.config.clubs.match( 'Arsenal' )
52
+ assert_equal 3, m.size
24
53
 
25
- def test_duplicats
26
- club = SportDb::Import::Club.new
27
- club.name = "Rapid Wien"
54
+ m = SportDb::Import.config.clubs.match( 'ARSENAL' )
55
+ assert_equal 3, m.size
28
56
 
29
- assert_equal false, club.duplicates?
30
- duplicates = {}
31
- assert_equal duplicates, club.duplicates
57
+ m = SportDb::Import.config.clubs.match_by( name: 'Arsenal', country: 'eng' )
58
+ assert_equal 1, m.size
59
+ assert_equal 'Arsenal FC', m[0].name
60
+ assert_equal 'England', m[0].country.name
61
+ assert_equal 'London', m[0].city
62
+
63
+ m = SportDb::Import.config.clubs.match_by( name: 'Arsenal', country: 'ar' )
64
+ assert_equal 1, m.size
65
+ assert_equal 'Arsenal de Sarandí', m[0].name
66
+ assert_equal 'Argentina', m[0].country.name
67
+ assert_equal 'Sarandí', m[0].city
68
+
69
+ m = SportDb::Import.config.clubs.match_by( name: 'Arsenal', country: 'ru' )
70
+ assert_equal 1, m.size
71
+ assert_equal 'Arsenal Tula', m[0].name
72
+ assert_equal 'Russia', m[0].country.name
73
+ assert_equal 'Tula', m[0].city
74
+
75
+
76
+ m = SportDb::Import.config.clubs.match( 'Arsenal FC' )
77
+ assert_equal 2, m.size
78
+
79
+ m = SportDb::Import.config.clubs.match( 'Arsenal F.C.' )
80
+ assert_equal 2, m.size
81
+
82
+ m = SportDb::Import.config.clubs.match( '...A.r.s.e.n.a.l... F.C...' )
83
+ assert_equal 2, m.size
84
+ end
32
85
 
33
- club.alt_names_auto += ['Rapid', 'Rapid Wien', 'SK Rapid Wien']
86
+ def test_wikipedia ## test wikipedia names and links/urls
34
87
 
35
- pp club
88
+ m = SportDb::Import.config.clubs.match( 'Club Brugge KV' )
89
+ assert_equal 1, m.size
90
+ assert_equal 'Club Brugge KV', m[0].wikipedia
91
+ assert_equal 'https://en.wikipedia.org/wiki/Club_Brugge_KV', m[0].wikipedia_url
36
92
 
37
- assert_equal true, club.duplicates?
38
- duplicates = {'rapidwien'=>['Rapid Wien','Rapid Wien']}
39
- pp club.duplicates
40
- assert_equal duplicates, club.duplicates
93
+ m = SportDb::Import.config.clubs.match( 'RSC Anderlecht' )
94
+ assert_equal 1, m.size
95
+ assert_equal 'R.S.C. Anderlecht', m[0].wikipedia
96
+ assert_equal 'https://en.wikipedia.org/wiki/R.S.C._Anderlecht', m[0].wikipedia_url
41
97
  end
42
98
 
43
99
  end # class TestClubs
metadata CHANGED
@@ -1,29 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.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: 2019-08-12 00:00:00.000000000 Z
11
+ date: 2019-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sportdb-countries
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.0
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.2.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.2.0
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: fifa
15
43
  requirement: !ruby/object:Gem::Requirement
16
44
  requirements:
17
45
  - - ">="
18
46
  - !ruby/object:Gem::Version
19
- version: 0.1.1
47
+ version: 1.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
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: 0.2.0
20
62
  type: :runtime
21
63
  prerelease: false
22
64
  version_requirements: !ruby/object:Gem::Requirement
23
65
  requirements:
24
66
  - - ">="
25
67
  - !ruby/object:Gem::Version
26
- version: 0.1.1
68
+ version: 0.2.0
27
69
  - !ruby/object:Gem::Dependency
28
70
  name: rdoc
29
71
  requirement: !ruby/object:Gem::Requirement
@@ -57,7 +99,7 @@ email: opensport@googlegroups.com
57
99
  executables: []
58
100
  extensions: []
59
101
  extra_rdoc_files:
60
- - HISTORY.md
102
+ - CHANGELOG.md
61
103
  - Manifest.txt
62
104
  - NOTES.md
63
105
  - README.md
@@ -71,7 +113,7 @@ extra_rdoc_files:
71
113
  - config/world/de.txt
72
114
  - config/world/eng.txt
73
115
  files:
74
- - HISTORY.md
116
+ - CHANGELOG.md
75
117
  - Manifest.txt
76
118
  - NOTES.md
77
119
  - README.md
@@ -86,31 +128,21 @@ files:
86
128
  - config/world/de.txt
87
129
  - config/world/eng.txt
88
130
  - lib/sportdb/config.rb
89
- - lib/sportdb/config/club.rb
90
- - lib/sportdb/config/club_index.rb
91
- - lib/sportdb/config/club_reader.rb
92
131
  - lib/sportdb/config/config.rb
93
- - lib/sportdb/config/countries.rb
94
132
  - lib/sportdb/config/league.rb
95
133
  - lib/sportdb/config/league_reader.rb
96
134
  - lib/sportdb/config/league_utils.rb
97
135
  - lib/sportdb/config/season_utils.rb
98
- - lib/sportdb/config/variants.rb
99
136
  - lib/sportdb/config/version.rb
100
137
  - lib/sportdb/config/wiki_index.rb
101
- - lib/sportdb/config/wiki_reader.rb
102
138
  - test/helper.rb
103
- - test/test_club_index.rb
104
- - test/test_club_reader.rb
105
139
  - test/test_clubs.rb
106
140
  - test/test_config.rb
107
141
  - test/test_countries.rb
108
142
  - test/test_league_reader.rb
109
143
  - test/test_league_utils.rb
110
144
  - test/test_season_utils.rb
111
- - test/test_variants.rb
112
145
  - test/test_wiki_index.rb
113
- - test/test_wiki_reader.rb
114
146
  homepage: https://github.com/sportdb/sport.db
115
147
  licenses:
116
148
  - Public Domain