footballdb-leagues 2019.12.16 → 2020.5.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,30 @@
1
+ ## our own code (without "top-level" shortcuts e.g. "modular version")
2
+ require 'footballdb/leagues'
3
+
4
+
5
+ ###
6
+ # add convenience top-level shortcuts / aliases
7
+
8
+ module SportDb
9
+ module Import
10
+
11
+ class Catalog
12
+ def build_country_index() CountryIndex.new( Fifa.countries ); end
13
+ def build_league_index() FootballDb::Import.build_league_index; end
14
+
15
+ def countries() @countries ||= build_country_index; end
16
+ def leagues() @leagues ||= build_league_index; end
17
+ end
18
+
19
+ configure do |config|
20
+ config.catalog = Catalog.new
21
+ end
22
+
23
+ end # module Import
24
+ end # module SportDb
25
+
26
+
27
+ ### add top-level (global) convenience alias
28
+ League = SportDb::Import.catalog.leagues
29
+
30
+
@@ -4,9 +4,9 @@
4
4
  module FootballDb
5
5
  module Leagues
6
6
 
7
- MAJOR = 2019 ## todo: namespace inside version or something - why? why not??
8
- MINOR = 12
9
- PATCH = 16
7
+ MAJOR = 2020 ## todo: namespace inside version or something - why? why not??
8
+ MINOR = 5
9
+ PATCH = 10
10
10
  VERSION = [MAJOR,MINOR,PATCH].join('.')
11
11
 
12
12
  def self.version
@@ -1,10 +1,6 @@
1
- # encoding: utf-8
2
-
3
-
4
1
  ###
5
- # sport.db gems / libraries
2
+ # sport.db gems / libraries via fifa
6
3
  require 'fifa'
7
- require 'sportdb/leagues'
8
4
 
9
5
 
10
6
  ###
@@ -15,60 +11,18 @@ require 'footballdb/leagues/version' # let version always go first
15
11
  module FootballDb
16
12
  module Import
17
13
 
18
- ## add "fake" configuration for stand-alone usage
19
- class Configuration
20
- def initialize
21
- recs = Fifa.countries
22
- @countries = SportDb::Import::CountryIndex.new( recs )
23
- end
24
-
25
- def countries() @countries; end
26
- end
27
-
28
-
29
-
30
-
31
- class League ## todo/check: use a module instead of class - why? why not?
32
- def self.leagues() league_index.leagues; end ## return all leagues (struct-like) records
33
- def self.all() leagues; end ## use ActiveRecord-like alias for leagues
34
-
35
- def self.mappings() league_index.mappings; end
36
-
37
- def self.match( name ) league_index.match( name ); end
38
- def self.match_by( name:, country: ) league_index.match_by( name: name, country: country ); end
39
-
40
-
41
- def self.league_index
42
- @league_index ||= build_league_index
43
- @league_index
44
- end
45
-
46
- private
47
14
  def self.build_league_index
48
- if defined?( SportDb::Import::Configuration )
49
- # assume running "inside" sportdb - (re)use sportdb configuration
50
- else
51
- # assume running "stand-alone" - setup configuration for countries / country mapping
52
- config = Configuration.new
53
- SportDb::Import::LeagueReader.config = config
54
- SportDb::Import::LeagueIndex.config = config
55
- end
56
-
57
- recs = SportDb::Import::LeagueReader.read( "#{FootballDb::Leagues.data_dir}/leagues.txt" )
58
- league_index = SportDb::Import::LeagueIndex.new
59
- league_index.add( recs )
60
- league_index
15
+ recs = SportDb::Import::League.read( "#{FootballDb::Leagues.data_dir}/leagues.txt" )
16
+ index = SportDb::Import::LeagueIndex.new
17
+ index.add( recs )
18
+ index
61
19
  end
62
- end # class League
63
20
 
64
21
  end # module Import
65
22
  end # module FootballDb
66
23
 
67
24
 
68
-
69
- ### add top-level (global) convenience alias
70
- League = FootballDb::Import::League
25
+ puts FootballDb::Leagues.banner # say hello
71
26
 
72
27
 
73
28
 
74
- puts FootballDb::Leagues.banner # say hello
data/test/helper.rb CHANGED
@@ -1,10 +1,7 @@
1
- ## $:.unshift(File.dirname(__FILE__))
2
-
3
1
  ## minitest setup
4
2
 
5
3
  require 'minitest/autorun'
6
4
 
7
5
 
8
6
  ## our own code
9
-
10
- require 'footballdb/leagues'
7
+ require 'footballdb/leagues/auto'
data/test/test_league.rb CHANGED
@@ -11,12 +11,12 @@ class TestLeague < MiniTest::Test
11
11
 
12
12
  def test_match
13
13
  m = League.match( 'English Premier League' )
14
- assert_equal 'English Premier League', m[0].name
15
- assert_equal 'eng.1', m[0].key
16
- assert_equal 'England', m[0].country.name
14
+ assert_equal 'Premier League', m[0].name
15
+ assert_equal 'eng.1', m[0].key
16
+ assert_equal 'England', m[0].country.name
17
17
 
18
18
  m = League.match( 'ENG PL' )
19
- assert_equal 'English Premier League', m[0].name
19
+ assert_equal 'Premier League', m[0].name
20
20
  assert_equal 'eng.1', m[0].key
21
21
  assert_equal 'England', m[0].country.name
22
22
  end
@@ -26,7 +26,7 @@ class TestLeague < MiniTest::Test
26
26
  assert m.size > 1 ## more than one match expected
27
27
 
28
28
  m = League.match_by( name: 'Premier League', country: 'eng' )
29
- assert_equal 'English Premier League', m[0].name
29
+ assert_equal 'Premier League', m[0].name
30
30
  assert_equal 'eng.1', m[0].key
31
31
  assert_equal 'England', m[0].country.name
32
32
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: footballdb-leagues
3
3
  version: !ruby/object:Gem::Version
4
- version: 2019.12.16
4
+ version: 2020.5.10
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-12-16 00:00:00.000000000 Z
11
+ date: 2020-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: sportdb-leagues
14
+ name: sportdb-formats
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.2
19
+ version: 1.0.1
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: 0.2.2
26
+ version: 1.0.1
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: 2019.11.27
33
+ version: 2020.5.10
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: 2019.11.27
40
+ version: 2020.5.10
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -82,10 +82,11 @@ files:
82
82
  - Rakefile
83
83
  - config/leagues.txt
84
84
  - lib/footballdb/leagues.rb
85
+ - lib/footballdb/leagues/auto.rb
85
86
  - lib/footballdb/leagues/version.rb
86
87
  - test/helper.rb
87
88
  - test/test_league.rb
88
- homepage: https://github.com/sportdb/sport.db
89
+ homepage: https://github.com/sportdb/football.db
89
90
  licenses:
90
91
  - Public Domain
91
92
  metadata: {}