sportdb-config 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/HISTORY.md +3 -0
  3. data/Manifest.txt +65 -0
  4. data/README.md +27 -0
  5. data/Rakefile +26 -0
  6. data/config/geos/eng.txt +162 -0
  7. data/config/leagues/eng.txt +40 -0
  8. data/config/leagues/fr.txt +9 -0
  9. data/config/leagues/gr.txt +7 -0
  10. data/config/leagues/sco.txt +19 -0
  11. data/config/teams/al.txt +6 -0
  12. data/config/teams/at.txt +26 -0
  13. data/config/teams/be.txt +58 -0
  14. data/config/teams/bg.txt +6 -0
  15. data/config/teams/by.txt +5 -0
  16. data/config/teams/ca.txt +4 -0
  17. data/config/teams/ch.txt +10 -0
  18. data/config/teams/cy.txt +7 -0
  19. data/config/teams/cz.txt +6 -0
  20. data/config/teams/de.txt +129 -0
  21. data/config/teams/dk.txt +6 -0
  22. data/config/teams/eng.txt +294 -0
  23. data/config/teams/es.txt +148 -0
  24. data/config/teams/fi.txt +6 -0
  25. data/config/teams/fr.txt +98 -0
  26. data/config/teams/ga.txt +5 -0
  27. data/config/teams/gr.txt +87 -0
  28. data/config/teams/hr.txt +9 -0
  29. data/config/teams/hu.txt +5 -0
  30. data/config/teams/ie.txt +5 -0
  31. data/config/teams/is.txt +6 -0
  32. data/config/teams/it.txt +99 -0
  33. data/config/teams/lu.txt +6 -0
  34. data/config/teams/mc.txt +4 -0
  35. data/config/teams/md.txt +4 -0
  36. data/config/teams/mt.txt +6 -0
  37. data/config/teams/mx.txt +30 -0
  38. data/config/teams/nir.txt +6 -0
  39. data/config/teams/nl.txt +45 -0
  40. data/config/teams/no.txt +7 -0
  41. data/config/teams/pl.txt +6 -0
  42. data/config/teams/pt.txt +53 -0
  43. data/config/teams/ro.txt +5 -0
  44. data/config/teams/rs.txt +6 -0
  45. data/config/teams/ru.txt +5 -0
  46. data/config/teams/sco.txt +73 -0
  47. data/config/teams/se.txt +6 -0
  48. data/config/teams/si.txt +5 -0
  49. data/config/teams/sk.txt +5 -0
  50. data/config/teams/tr.txt +39 -0
  51. data/config/teams/ua.txt +5 -0
  52. data/config/teams/us.txt +44 -0
  53. data/config/teams/wal.txt +16 -0
  54. data/lib/sportdb/config.rb +26 -0
  55. data/lib/sportdb/config/config.rb +77 -0
  56. data/lib/sportdb/config/league.rb +118 -0
  57. data/lib/sportdb/config/league_reader.rb +65 -0
  58. data/lib/sportdb/config/structs/team.rb +45 -0
  59. data/lib/sportdb/config/team_reader.rb +108 -0
  60. data/lib/sportdb/config/utils/league_utils.rb +24 -0
  61. data/lib/sportdb/config/utils/season_utils.rb +116 -0
  62. data/lib/sportdb/config/version.rb +35 -0
  63. data/test/helper.rb +10 -0
  64. data/test/test_config.rb +19 -0
  65. data/test/test_league_utils.rb +90 -0
  66. data/test/test_season_utils.rb +29 -0
  67. metadata +189 -0
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+
4
+
5
+ module SportDb
6
+ module Boot ## note: use a different module than Config to avoid confusion with Configuration/config etc.!!!!
7
+ ## maybe rename later gem itself to sportdb-boot - why? why not?
8
+
9
+ MAJOR = 0 ## todo: namespace inside version or something - why? why not??
10
+ MINOR = 0
11
+ PATCH = 1
12
+ VERSION = [MAJOR,MINOR,PATCH].join('.')
13
+
14
+ def self.version
15
+ VERSION
16
+ end
17
+
18
+ def self.banner
19
+ "sportdb-config/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
20
+ end
21
+
22
+ def self.root
23
+ File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )
24
+ end
25
+
26
+ def self.data_dir ## rename to config_dir - why? why not?
27
+ "#{root}/config"
28
+ end
29
+
30
+ def self.test_data_dir
31
+ "#{root}/test/data"
32
+ end
33
+
34
+ end # module Boot
35
+ end
@@ -0,0 +1,10 @@
1
+ ## $:.unshift(File.dirname(__FILE__))
2
+
3
+ ## minitest setup
4
+
5
+ require 'minitest/autorun'
6
+
7
+
8
+ ## our own code
9
+
10
+ require 'sportdb/config'
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_config.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+ class TestConfig < MiniTest::Test
11
+
12
+ def test_teams
13
+
14
+ pp SportDb::Import.config.teams
15
+
16
+ assert true ## assume ok if we get here
17
+ end # method test_teams
18
+
19
+ end # class TestConfig
@@ -0,0 +1,90 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_league_utils.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+ class TestLeagueUtils < MiniTest::Test
11
+
12
+ def test_basename_eng
13
+ assert_equal '1-premierleague', LeagueUtils.basename( '1', country: 'eng', season: '2011-12' )
14
+ assert_equal '1-premierleague', LeagueUtils.basename( '1', country: 'eng' )
15
+ assert_equal '1-premierleague', LeagueUtils.basename( '1', country: 'eng-england' ) ## allow country code or (repo) package name
16
+ assert_equal '1-division1', LeagueUtils.basename( '1', country: 'eng', season: '1991-92' )
17
+ assert_equal '3a', LeagueUtils.basename( '3a', country: 'eng', season: '2011-12' )
18
+
19
+ assert_equal '2-championship', LeagueUtils.basename( '2', country: 'eng', season: '2011-12' )
20
+ assert_equal '2-championship', LeagueUtils.basename( '2', country: 'eng' )
21
+ assert_equal '2-championship', LeagueUtils.basename( '2', country: 'eng-england' ) ## allow country code or (repo) package name
22
+ assert_equal '2-division1', LeagueUtils.basename( '2', country: 'eng', season: '2003-04' )
23
+ assert_equal '2-division2', LeagueUtils.basename( '2', country: 'eng', season: '1991-92' )
24
+ assert_equal '2-division2', LeagueUtils.basename( '2', country: 'eng', season: '1989-90' )
25
+ end # method test_basename
26
+
27
+ def test_basename_sco
28
+ assert_equal '1-premiership', LeagueUtils.basename( '1', country: 'sco' )
29
+ assert_equal '1-premierleague', LeagueUtils.basename( '1', country: 'sco', season: '2012-13' )
30
+ assert_equal '1-premierdivision', LeagueUtils.basename( '1', country: 'sco', season: '1997-98' )
31
+
32
+ assert_equal '2-championship', LeagueUtils.basename( '2', country: 'sco' )
33
+ assert_equal '2-division1', LeagueUtils.basename( '2', country: 'sco', season: '2012-13' )
34
+ end
35
+
36
+ def test_basename_fr
37
+ assert_equal '1-ligue1', LeagueUtils.basename( '1', country: 'fr' )
38
+ assert_equal '1-division1', LeagueUtils.basename( '1', country: 'fr', season: '2001-02' )
39
+ end
40
+
41
+ def test_basename_gr
42
+ assert_equal '1-superleague', LeagueUtils.basename( '1', country: 'gr' )
43
+ assert_equal '1-alphaethniki', LeagueUtils.basename( '1', country: 'gr', season: '2005-06' )
44
+ end
45
+
46
+
47
+
48
+ def test_read_txt
49
+
50
+ hash = SportDb::Import::LeagueReader.read( <<TXT)
51
+ 1 => premierleague, English Premier League
52
+ 2 => championship, English Championship League
53
+ 3 => league1, English League 1
54
+ 4 => league2, English League 2
55
+ 5 => conference, English Conference
56
+
57
+ #########################################
58
+ # until (including) 2003-04 season
59
+
60
+ [2003-04] # or just use 2003-04: or similar - why? why not?
61
+ # or use 2003/04 - 1992/93 - why? why not?
62
+
63
+ 1 => premierleague, English Premier League
64
+ 2 => division1, English Division 1
65
+ 3 => division2, English Division 2
66
+ 4 => division3, English Division 3
67
+
68
+
69
+ #############################################
70
+ # note: in season 1992/93 the premier league starts
71
+ # until (including) 1991-92} season
72
+
73
+ [1991-92]
74
+ 1 => division1, English Division 1
75
+ 2 => division2, English Division 2
76
+ 3 => division3, English Division 3
77
+ 3a => division3n, English Division 3 (North)
78
+ 3b => division3s, English Division 3 (South)
79
+ 4 => division4, English Division 4 ## check if real?
80
+ TXT
81
+
82
+
83
+ assert_equal 'premierleague', hash['*']['1']
84
+ assert_equal 'championship', hash['*']['2']
85
+ assert_equal 'league1', hash['*']['3']
86
+
87
+ assert_equal 'division1', hash['1991-92']['1']
88
+ assert_equal 'division2', hash['1991-92']['2']
89
+ end # method test_parse_leagues_txt
90
+ end # class TestLeagueUtils
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_season_utils.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+ class TestSeasonUtils < MiniTest::Test
11
+
12
+ def test_directory
13
+ assert_equal '2010-11', SeasonUtils.directory( '2010-11' )
14
+ assert_equal '2010-11', SeasonUtils.directory( '2010-2011' )
15
+ assert_equal '2010-11', SeasonUtils.directory( '2010/11' )
16
+ assert_equal '2010-11', SeasonUtils.directory( '2010/2011' )
17
+ assert_equal '2010', SeasonUtils.directory( '2010' )
18
+
19
+ assert_equal '2010s/2010-11', SeasonUtils.directory( '2010-11', format: 'long' )
20
+ assert_equal '2010s/2010-11', SeasonUtils.directory( '2010-2011', format: 'long' )
21
+ assert_equal '2010s/2010', SeasonUtils.directory( '2010', format: 'long' )
22
+
23
+ assert_equal '1999-00', SeasonUtils.directory( '1999-00' )
24
+ assert_equal '1999-00', SeasonUtils.directory( '1999-2000' )
25
+ assert_equal '1990s/1999-00', SeasonUtils.directory( '1999-00', format: 'long' )
26
+ assert_equal '1990s/1999-00', SeasonUtils.directory( '1999-2000', format: 'long' )
27
+ end # method test_diretory
28
+
29
+ end # class TestSeasonlUtils
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sportdb-config
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Gerald Bauer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-06-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rdoc
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: hoe
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.16'
41
+ description: sportdb-config - sport.db configuration settings and built-in defaults
42
+ email: opensport@googlegroups.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files:
46
+ - HISTORY.md
47
+ - Manifest.txt
48
+ - README.md
49
+ - config/geos/eng.txt
50
+ - config/leagues/eng.txt
51
+ - config/leagues/fr.txt
52
+ - config/leagues/gr.txt
53
+ - config/leagues/sco.txt
54
+ - config/teams/al.txt
55
+ - config/teams/at.txt
56
+ - config/teams/be.txt
57
+ - config/teams/bg.txt
58
+ - config/teams/by.txt
59
+ - config/teams/ca.txt
60
+ - config/teams/ch.txt
61
+ - config/teams/cy.txt
62
+ - config/teams/cz.txt
63
+ - config/teams/de.txt
64
+ - config/teams/dk.txt
65
+ - config/teams/eng.txt
66
+ - config/teams/es.txt
67
+ - config/teams/fi.txt
68
+ - config/teams/fr.txt
69
+ - config/teams/ga.txt
70
+ - config/teams/gr.txt
71
+ - config/teams/hr.txt
72
+ - config/teams/hu.txt
73
+ - config/teams/ie.txt
74
+ - config/teams/is.txt
75
+ - config/teams/it.txt
76
+ - config/teams/lu.txt
77
+ - config/teams/mc.txt
78
+ - config/teams/md.txt
79
+ - config/teams/mt.txt
80
+ - config/teams/mx.txt
81
+ - config/teams/nir.txt
82
+ - config/teams/nl.txt
83
+ - config/teams/no.txt
84
+ - config/teams/pl.txt
85
+ - config/teams/pt.txt
86
+ - config/teams/ro.txt
87
+ - config/teams/rs.txt
88
+ - config/teams/ru.txt
89
+ - config/teams/sco.txt
90
+ - config/teams/se.txt
91
+ - config/teams/si.txt
92
+ - config/teams/sk.txt
93
+ - config/teams/tr.txt
94
+ - config/teams/ua.txt
95
+ - config/teams/us.txt
96
+ - config/teams/wal.txt
97
+ files:
98
+ - HISTORY.md
99
+ - Manifest.txt
100
+ - README.md
101
+ - Rakefile
102
+ - config/geos/eng.txt
103
+ - config/leagues/eng.txt
104
+ - config/leagues/fr.txt
105
+ - config/leagues/gr.txt
106
+ - config/leagues/sco.txt
107
+ - config/teams/al.txt
108
+ - config/teams/at.txt
109
+ - config/teams/be.txt
110
+ - config/teams/bg.txt
111
+ - config/teams/by.txt
112
+ - config/teams/ca.txt
113
+ - config/teams/ch.txt
114
+ - config/teams/cy.txt
115
+ - config/teams/cz.txt
116
+ - config/teams/de.txt
117
+ - config/teams/dk.txt
118
+ - config/teams/eng.txt
119
+ - config/teams/es.txt
120
+ - config/teams/fi.txt
121
+ - config/teams/fr.txt
122
+ - config/teams/ga.txt
123
+ - config/teams/gr.txt
124
+ - config/teams/hr.txt
125
+ - config/teams/hu.txt
126
+ - config/teams/ie.txt
127
+ - config/teams/is.txt
128
+ - config/teams/it.txt
129
+ - config/teams/lu.txt
130
+ - config/teams/mc.txt
131
+ - config/teams/md.txt
132
+ - config/teams/mt.txt
133
+ - config/teams/mx.txt
134
+ - config/teams/nir.txt
135
+ - config/teams/nl.txt
136
+ - config/teams/no.txt
137
+ - config/teams/pl.txt
138
+ - config/teams/pt.txt
139
+ - config/teams/ro.txt
140
+ - config/teams/rs.txt
141
+ - config/teams/ru.txt
142
+ - config/teams/sco.txt
143
+ - config/teams/se.txt
144
+ - config/teams/si.txt
145
+ - config/teams/sk.txt
146
+ - config/teams/tr.txt
147
+ - config/teams/ua.txt
148
+ - config/teams/us.txt
149
+ - config/teams/wal.txt
150
+ - lib/sportdb/config.rb
151
+ - lib/sportdb/config/config.rb
152
+ - lib/sportdb/config/league.rb
153
+ - lib/sportdb/config/league_reader.rb
154
+ - lib/sportdb/config/structs/team.rb
155
+ - lib/sportdb/config/team_reader.rb
156
+ - lib/sportdb/config/utils/league_utils.rb
157
+ - lib/sportdb/config/utils/season_utils.rb
158
+ - lib/sportdb/config/version.rb
159
+ - test/helper.rb
160
+ - test/test_config.rb
161
+ - test/test_league_utils.rb
162
+ - test/test_season_utils.rb
163
+ homepage: https://github.com/sportdb/sport.db
164
+ licenses:
165
+ - Public Domain
166
+ metadata: {}
167
+ post_install_message:
168
+ rdoc_options:
169
+ - "--main"
170
+ - README.md
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: 2.2.2
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubyforge_project:
185
+ rubygems_version: 2.5.2
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: sportdb-config - sport.db configuration settings and built-in defaults
189
+ test_files: []