sportdb-formats 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 268dcbbc6a6406aeba7cd67e96d353157aac8193
4
- data.tar.gz: 6a3d098d6e4f6dadd1d995127f4cc79588c5b900
3
+ metadata.gz: 25a05ffd2370b2e9c8c24516e332e8c81b69ae2a
4
+ data.tar.gz: 5a033c65a78d9313316098d75b5ea9b021946b5b
5
5
  SHA512:
6
- metadata.gz: 977c372feb715497cf80a3246a6bc1ed861189f104550af33c771e05205e5de31d234812884f2d88ba298858ea5e6fd1776fdde5b2a29eeca47fc195a6b43f05
7
- data.tar.gz: c1c422f192ef4dd5bedcff217f32cbb8b986665a986ccf6800d8bf42ae8cbcf8d68313baec251d3510d773a048fc779350fefa0038536e4e53256079843c01cb
6
+ metadata.gz: 3c3e031a037e67c819c582bf5fbe99c581f4d3120fe49dd3445cdfadf96b812cf47f86ac4c3c1ee52457fbe4c29e47df39ebd2e44732828dae414a26f04af568
7
+ data.tar.gz: 4964b799f112e4f565f30e99325de611d38015e2f377d9a4abe8bc26f6ccc8c0cd718f5f24c1fe3bdc04ded097bf2095bdbf676c9b1eccc432160a5020b063d3
data/Manifest.txt CHANGED
@@ -2,17 +2,9 @@ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
- config/fixtures/de.yml
6
- config/fixtures/en.yml
7
- config/fixtures/es.yml
8
- config/fixtures/fr.yml
9
- config/fixtures/it.yml
10
- config/fixtures/pt.yml
11
- config/fixtures/ro.yml
12
5
  lib/sportdb/formats.rb
13
6
  lib/sportdb/formats/datafile.rb
14
7
  lib/sportdb/formats/date.rb
15
- lib/sportdb/formats/lang.rb
16
8
  lib/sportdb/formats/outline_reader.rb
17
9
  lib/sportdb/formats/season_utils.rb
18
10
  lib/sportdb/formats/version.rb
@@ -21,6 +13,5 @@ test/test_csv_reader.rb
21
13
  test/test_datafile.rb
22
14
  test/test_datafile_match.rb
23
15
  test/test_date.rb
24
- test/test_lang.rb
25
16
  test/test_outline_reader.rb
26
17
  test/test_season_utils.rb
data/Rakefile CHANGED
@@ -20,13 +20,12 @@ Hoe.spec 'sportdb-formats' do
20
20
  self.licenses = ['Public Domain']
21
21
 
22
22
  self.extra_deps = [
23
- ['alphabets', '>= 0.1.0'],
24
- ['csvreader', '>= 1.2.4'],
25
- ['textutils', '>= 1.4.0'],
23
+ ['alphabets', '>= 0.1.0'],
24
+ ['csvreader', '>= 1.2.4'],
25
+ ['sportdb-langs', '>= 0.0.1'],
26
26
  ]
27
27
 
28
28
  self.spec_extras = {
29
29
  required_ruby_version: '>= 2.2.2'
30
30
  }
31
-
32
31
  end
@@ -14,7 +14,8 @@ def parse_csv( txt )
14
14
  end
15
15
 
16
16
 
17
- require 'textutils' # TextUtils::Classifier, ...
17
+ ## more sportdb libs/gems
18
+ require 'sportdb/langs'
18
19
 
19
20
 
20
21
  ###
@@ -24,7 +25,6 @@ require 'sportdb/formats/outline_reader'
24
25
  require 'sportdb/formats/datafile'
25
26
  require 'sportdb/formats/season_utils'
26
27
 
27
- require 'sportdb/formats/lang'
28
28
  require 'sportdb/formats/date'
29
29
 
30
30
  ## let's put test configuration in its own namespace / module
@@ -40,17 +40,6 @@ end
40
40
  end # module SportDb
41
41
 
42
42
 
43
- module SportDb
44
- def self.lang
45
- # todo/fix: find a better way for single instance ??
46
- # will get us ruby warning: instance variable @lang not initialized => find a better way!!!
47
- # just use @lang w/o .nil? e.g.
48
- # @lang =|| Lang.new why? why not?? or better use @@lang =|| Lang.new for class variable!!!
49
- @lang ||= Lang.new
50
- @lang
51
- end
52
- end # module SportDb
53
-
54
43
 
55
44
 
56
45
  puts SportDb::Formats.banner # say hello
@@ -6,7 +6,7 @@ module Formats
6
6
 
7
7
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
8
8
  MINOR = 1
9
- PATCH = 2
9
+ PATCH = 3
10
10
  VERSION = [MAJOR,MINOR,PATCH].join('.')
11
11
 
12
12
  def self.version
@@ -21,10 +21,5 @@ module Formats
21
21
  File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )
22
22
  end
23
23
 
24
-
25
- def self.config_path
26
- "#{root}/config"
27
- end
28
-
29
24
  end # module Formats
30
25
  end # module SportDb
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-formats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
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-11-03 00:00:00.000000000 Z
11
+ date: 2019-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alphabets
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.2.4
41
41
  - !ruby/object:Gem::Dependency
42
- name: textutils
42
+ name: sportdb-langs
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.4.0
47
+ version: 0.0.1
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: 1.4.0
54
+ version: 0.0.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rdoc
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -93,17 +93,9 @@ files:
93
93
  - Manifest.txt
94
94
  - README.md
95
95
  - Rakefile
96
- - config/fixtures/de.yml
97
- - config/fixtures/en.yml
98
- - config/fixtures/es.yml
99
- - config/fixtures/fr.yml
100
- - config/fixtures/it.yml
101
- - config/fixtures/pt.yml
102
- - config/fixtures/ro.yml
103
96
  - lib/sportdb/formats.rb
104
97
  - lib/sportdb/formats/datafile.rb
105
98
  - lib/sportdb/formats/date.rb
106
- - lib/sportdb/formats/lang.rb
107
99
  - lib/sportdb/formats/outline_reader.rb
108
100
  - lib/sportdb/formats/season_utils.rb
109
101
  - lib/sportdb/formats/version.rb
@@ -112,7 +104,6 @@ files:
112
104
  - test/test_datafile.rb
113
105
  - test/test_datafile_match.rb
114
106
  - test/test_date.rb
115
- - test/test_lang.rb
116
107
  - test/test_outline_reader.rb
117
108
  - test/test_season_utils.rb
118
109
  homepage: https://github.com/sportdb/sport.db
@@ -1,46 +0,0 @@
1
- ###########################
2
- # known keywords for fixtures
3
-
4
-
5
- group: Gruppe
6
-
7
- round: Spieltag|Runde
8
-
9
-
10
- stage: Gruppenphase|Qualifikation|Play-off|Finalrunde|K.-o.-Phase
11
-
12
-
13
- ### Knock out rounds
14
-
15
- ## fix: add playoffs:
16
- round32: Sechzehntelfinale|1/16 Finale
17
- round16: Achtelfinale|1/8 Finale
18
- quarterfinals: Viertelfinale|1/4 Finale
19
- semifinals: Halbfinale|Semifinale|1/2 Finale
20
- fifthplace: Spiel um Platz 5
21
- thirdplace: Spiel um Platz 3
22
- final: Finale|Endspiel
23
-
24
- ### Pair matches/games if marked with leg1 n leg2
25
-
26
- leg1: Hin|Hinspiel|Hinspiele
27
- leg2: Rück|Rückspiel|Rückspiele
28
-
29
-
30
- #######################
31
- # months of year
32
-
33
- january: Jänner|Januar
34
- february: Feber|Februar
35
- march: März
36
- april: April
37
- may: Mai
38
- june: Juni
39
- july: Juli
40
- august: August
41
- september: September
42
- october: Oktober
43
- november: November
44
- december: Dezember
45
-
46
-
@@ -1,54 +0,0 @@
1
- ###########################
2
- # known keywords for fixtures
3
-
4
-
5
- group: Group
6
-
7
- round: Round|Matchday|Week
8
-
9
- stage: Stage|Phase|Rounds
10
- # e.g.
11
- # Group stage
12
- # Play off stage|Play-off stage
13
- # Knockout stage|Knockout stages
14
- # First stage
15
- # Second stage
16
- # Qualifying rounds
17
-
18
-
19
-
20
- ### Knockout rounds
21
-
22
- playoffs: Playoff|Playoffs|Play-off|Play-offs|Play-off for quarter-finals
23
- round32: Round of 32|Last 32
24
- round16: Round of 16|Last 16|8th finals
25
- quarterfinals: Quarterfinals|Quarter-finals|Quarters|Quarterfinal|Last 8
26
- semifinals: Semifinals|Semi-finals|Semis|Last 4
27
- fifthplace: Fifth place match|Fifth place|5th place match|5th place final|5th place|Match for fifth place|Match for 5th place
28
- thirdplace: Third place match|Third-place match|Third place|3rd place match|3rd place final|3rd place|Match for third place|Match for 3rd place|Third-place play-off|Third place play-off
29
- final: Final|Finals
30
-
31
-
32
- ### Pair matches/games if marked with leg1 n leg2
33
-
34
- leg1: 1st leg|First leg
35
- leg2: 2nd leg|Second leg
36
-
37
-
38
- #######################
39
- # months of year
40
-
41
- january: January
42
- february: February
43
- march: March
44
- april: April
45
- may: May
46
- june: June
47
- july: July
48
- august: August
49
- september: September
50
- october: October
51
- november: November
52
- december: December
53
-
54
-
@@ -1,48 +0,0 @@
1
- ###########################
2
- # known keywords for fixtures
3
-
4
-
5
- group: Grupo
6
-
7
- round: Fecha|Jornada
8
-
9
-
10
- stage: Primera fase|Segunda fase|Fase de grupos|Fase final
11
-
12
-
13
- ### Knock out rounds
14
-
15
- ## fix: add playoffs + fifthplace
16
-
17
-
18
- round32: Dieciseisavos de final|16vos de final
19
- round16: Octavos|Octavos de final|8vos de final
20
- quarterfinals: Cuartos|Cuartos de final|4tos de final
21
- semifinals: Semifinales|Semifinal
22
- thirdplace: Tercer lugar
23
- final: Final
24
-
25
- ### Pair matches/games if marked with leg1 n leg2
26
-
27
- leg1: Ida
28
- leg2: Vuelta
29
-
30
-
31
-
32
- #######################
33
- # months of year
34
-
35
- january: enero
36
- february: febrero
37
- march: marzo
38
- april: abril
39
- may: mayo
40
- june: junio
41
- july: julio
42
- august: agosto
43
- september: septiembre
44
- october: octubre
45
- november: noviembre
46
- december: diciembre
47
-
48
-
@@ -1,53 +0,0 @@
1
- ###########################
2
- # known keywords for fixtures
3
-
4
-
5
- group: Groupe
6
-
7
- round: Journée
8
-
9
- stage: Phase de groupes|Phase à élimination directe|Phase finale
10
- # e.g.
11
- # Group stage
12
- # Play off stage|Play-off stage
13
- # Knockout stage|Knockout stages
14
- # First stage
15
- # Second stage
16
- # Qualifying rounds
17
-
18
-
19
-
20
-
21
- ### Knockout rounds
22
-
23
- ## fix: add playoffs + fifthplace
24
-
25
-
26
- round32: Seizièmes de finale
27
- round16: Huitièmes de finale
28
- quarterfinals: Quarts de finale
29
- semifinals: Demi-finales
30
- thirdplace: Match pour la troisième place
31
- final: Finale
32
-
33
- ### Pair matches/games if marked with leg1 n leg2
34
-
35
- leg1: Match aller
36
- leg2: Match retour
37
-
38
-
39
- #######################
40
- # months of year
41
-
42
- january: janvier
43
- february: février
44
- march: mars
45
- april: avril
46
- may: mai
47
- june: juin
48
- july: juillet
49
- august: août
50
- september: septembre
51
- october: octobre
52
- november: novembre
53
- december: décembre
@@ -1,55 +0,0 @@
1
- ###########################
2
- # known keywords for fixtures
3
-
4
-
5
- group: Gruppo
6
-
7
-
8
- round: Giornata
9
-
10
- stage: Fase a gironi|Fase a eliminazione diretta
11
- # e.g.
12
- # Group stage
13
- # Play off stage|Play-off stage
14
- # Knockout stage|Knockout stages
15
- # First stage
16
- # Second stage
17
- # Qualifying rounds
18
-
19
-
20
-
21
-
22
- ### Knockout rounds
23
-
24
- ## fix: add playoffs + fifthplace
25
-
26
-
27
- round32: Sedicesimi di finale
28
- round16: Ottavi di finale
29
- quarterfinals: Quarti di finale
30
- semifinals: Semifinali
31
- thirdplace: Finale 3º posto
32
- final: Finale
33
-
34
- ### Pair matches/games if marked with leg1 n leg2
35
-
36
- leg1: Andata
37
- leg2: Ritorno
38
-
39
-
40
- #######################
41
- # months of year
42
-
43
- january: gennaio
44
- february: febbraio
45
- march: marzo
46
- april: aprile
47
- may: maggio
48
- june: giugno
49
- july: luglio
50
- august: agosto
51
- september: settembre
52
- october: ottobre
53
- november: novembre
54
- december: dicembre
55
-
@@ -1,46 +0,0 @@
1
- ###########################
2
- # known keywords for fixtures
3
-
4
-
5
- group: Grupo
6
-
7
- round: Rodada
8
-
9
- stage: Fase de grupos|Fase final|Primeira Fase|Segunda Fase
10
-
11
-
12
- ### Knock out rounds
13
-
14
- ## fix: add playoffs + fifthplace
15
-
16
- round32: 16-avos de final
17
- round16: Oitavos de final|Oitavas-de-final
18
- quarterfinals: Quartos de final|Quartas-de-final
19
- semifinals: Semifinais
20
- thirdplace: Terceiro lugar
21
- final: Final
22
-
23
-
24
- ### Pair matches/games if marked with leg1 n leg2
25
-
26
- leg1: 1º jogo # Ida -- exists ??
27
- leg2: 2º jogo # Volta -- exists ??
28
-
29
-
30
-
31
- #######################
32
- # months of year
33
-
34
- january: janeiro
35
- february: fevereiro
36
- march: março
37
- april: abril
38
- may: maio
39
- june: junho
40
- july: julho
41
- august: agosto
42
- september: setembro
43
- october: outubro
44
- november: novembro
45
- december: dezembro
46
-
@@ -1,55 +0,0 @@
1
- ###########################
2
- # known keywords for fixtures
3
-
4
-
5
- group: Grupa
6
-
7
- round: Runda|Etapa
8
-
9
-
10
- stage: Faza grupelor|Faza eliminatorie
11
- # e.g.
12
- # Group stage
13
- # Play off stage|Play-off stage
14
- # Knockout stage|Knockout stages
15
- # First stage
16
- # Second stage
17
- # Qualifying rounds
18
-
19
-
20
-
21
-
22
- ### Knockout rounds
23
-
24
- ## fix: add playoffs + fifthplace
25
-
26
-
27
- round32: 1/16 de finală
28
- round16: Optimi de finală
29
- quarterfinals: Sferturi de finală
30
- semifinals: Semifinale
31
- thirdplace: Meciul pentru locul 3
32
- final: Finala
33
-
34
- ### Pair matches/games if marked with leg1 n leg2
35
-
36
- leg1: Tur ## Prima manșă - use too ??
37
- leg2: Retur ## Manșa secundă - use too ??
38
-
39
-
40
- #######################
41
- # months of year
42
-
43
- january: ianuarie
44
- february: februarie
45
- march: martie
46
- april: aprilie
47
- may: mai
48
- june: iunie
49
- july: iulie
50
- august: august
51
- september: septembrie
52
- october: octombrie
53
- november: noiembrie
54
- december: decembrie
55
-
@@ -1,216 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module SportDb
4
-
5
- class Lang
6
-
7
- include LogUtils::Logging
8
-
9
- attr_reader :lang
10
-
11
- def initialize
12
- # fix/todo: load on demand; only if no fixtures loaded/configured use builtin
13
- load_builtin_words
14
- end
15
-
16
-
17
- def load_builtin_words
18
- builtin_words = {
19
- 'en' => 'fixtures/en',
20
- 'de' => 'fixtures/de',
21
- 'es' => 'fixtures/es',
22
- 'fr' => 'fixtures/fr',
23
- 'it' => 'fixtures/it',
24
- 'pt' => 'fixtures/pt',
25
- 'ro' => 'fixtures/ro'
26
- }
27
-
28
- load_words( builtin_words, SportDb::Formats.config_path )
29
- end
30
-
31
-
32
- def load_words( h, include_path )
33
- @lang = 'en' # make default lang english/en
34
- @words = {} # resets fixtures
35
- @cache = {} # reset cached values
36
-
37
- h.each_with_index do |(key,value),i|
38
- name = value
39
- path = "#{include_path}/#{name}.yml"
40
- logger.debug( "loading words #{key} (#{i+1}/#{h.size}) in '#{name}' (#{path})..." )
41
- @words[ key ] = YAML.load( File.read_utf8( path ))
42
- end
43
-
44
- @classifier = TextUtils::Classifier.new
45
- @words.each_with_index do |(key,value),i|
46
- logger.debug "train classifier for #{key} (#{i+1}/#{@words.size})"
47
- @classifier.train( key, value )
48
- end
49
-
50
- @classifier.dump # for debugging dump all words
51
- end
52
-
53
- def classify( text )
54
- @classifier.classify( text )
55
- end
56
-
57
- def classify_file( path )
58
- @classifier.classify_file( path )
59
- end
60
-
61
- def lang=(value)
62
- logger.debug "setting lang to #{value}"
63
-
64
- if @lang != value
65
-
66
- ### todo: make reset cached values into method/function for reuse (see load_words)
67
- # reset cached values on language change
68
- logger.debug "reseting cached lang values (lang changed from #{@lang} to #{value})"
69
-
70
- @cache = {}
71
- end
72
-
73
- @lang = value
74
-
75
- end
76
-
77
-
78
- def group
79
- @cache[ :group ] ||= group_getter
80
- end
81
-
82
- def round
83
- @cache[ :round ] ||= round_getter
84
- end
85
-
86
- def knockout_round
87
- @cache[ :knockout_round ] ||= knockout_round_getter
88
- end
89
-
90
- def leg1
91
- @cache[ :leg1 ] ||= leg1_getter
92
- end
93
-
94
- def leg2
95
- @cache[ :leg2 ] ||= leg2_getter
96
- end
97
-
98
-
99
-
100
- def regex_group
101
- @cache [ :regex_group ] ||= regex_group_getter
102
- end
103
-
104
- def regex_round
105
- @cache[ :regex_round ] ||= regex_round_getter
106
- end
107
-
108
- def regex_knockout_round
109
- @cache[ :regex_knockout_round ] ||= regex_knockout_round_getter
110
- end
111
-
112
- def regex_leg1
113
- @cache[ :regex_leg1 ] ||= regex_leg1_getter
114
- end
115
-
116
- def regex_leg2
117
- @cache[ :regex_leg2 ] ||= regex_leg2_getter
118
- end
119
-
120
- private
121
- def group_getter
122
- h = @words[ lang ]
123
- values = "" # NB: always construct a new string (do NOT use a reference to hash value)
124
- values << h['group']
125
- values
126
- end
127
-
128
- def round_getter
129
- # e.g. Spieltag|Runde|Achtelfinale|Viertelfinale|Halbfinale|Finale
130
-
131
- ## fix/todo:
132
- ## sort by length first - to allow best match e.g.
133
- ## 3rd place play-off instead of Play-off ?? etc. - why? why not?
134
-
135
- h = @words[ lang ]
136
- values = "" # NB: always construct a new string (do NOT use a reference to hash value)
137
- values << h['round']
138
-
139
- ### add knockout rounds values too
140
- values << "|" << h['round32']
141
- values << "|" << h['round16']
142
- values << "|" << h['quarterfinals']
143
- values << "|" << h['semifinals']
144
- values << "|" << h['fifthplace'] if h['fifthplace'] # nb: allow empty/is optional!!
145
- values << "|" << h['thirdplace']
146
- values << "|" << h['final']
147
- values << "|" << h['playoffs'] if h['playoffs'] # nb: allow empty/is optional!!
148
- values
149
- end
150
-
151
- def leg1_getter
152
- h = @words[ lang ]
153
- values = "" # NB: always construct a new string (do NOT use a reference to hash value)
154
- values << h['leg1']
155
- values
156
- end
157
-
158
- def leg2_getter
159
- h = @words[ lang ]
160
- values = "" # NB: always construct a new string (do NOT use a reference to hash value)
161
- values << h['leg2']
162
- values
163
- end
164
-
165
- def knockout_round_getter
166
- h = @words[ lang ]
167
- values = "" # NB: always construct a new string (do NOT use a reference to hash value)
168
- values << h['round32']
169
- values << "|" << h['round16']
170
- values << "|" << h['quarterfinals']
171
- values << "|" << h['semifinals']
172
- values << "|" << h['fifthplace'] if h['fifthplace'] # nb: allow empty/is optional!!
173
- values << "|" << h['thirdplace']
174
- values << "|" << h['final']
175
- values << "|" << h['playoffs'] if h['playoffs'] # nb: allow empty/is optional!!
176
- values
177
- end
178
-
179
- def regex_group_getter
180
- ## todo: escape for regex?
181
- ## NB: let's ignore case (that is, UPCASE,downcase); always use /i flag
182
- /#{group}/i
183
- end
184
-
185
- def regex_round_getter
186
- ## todo: escape for regex?
187
- ## todo: sort by length - biggest words go first? does regex match biggest word automatically?? - check
188
- ## todo/fix: make - optional e.g. convert to ( |-) or better [ \-] ??
189
- ## NB: let's ignore case (that is, UPCASE,downcase); always use /i flag
190
- /#{round}/i
191
- end
192
-
193
- def regex_knockout_round_getter
194
- ## todo: escape for regex?
195
- ## todo: sort by length - biggest words go first? does regex match biggest word automatically?? - check
196
- ## todo/fix: make - optional e.g. convert to ( |-) or better [ \-] ??
197
- ## NB: let's ignore case (that is, UPCASE,downcase); always use /i flag
198
- /#{knockout_round}/i
199
- end
200
-
201
- def regex_leg1_getter
202
- ## todo: escape for regex?
203
- ## NB: let's ignore case (that is, UPCASE,downcase); always use /i flag
204
- /#{leg1}/i
205
- end
206
-
207
- def regex_leg2_getter
208
- ## todo: escape for regex?
209
- ## NB: let's ignore case (that is, UPCASE,downcase); always use /i flag
210
- /#{leg2}/i
211
- end
212
-
213
- end # class Lang
214
-
215
-
216
- end # module SportDb
data/test/test_lang.rb DELETED
@@ -1,130 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_lang.rb
6
- # or better
7
- # rake -I ./lib test
8
-
9
- require 'helper'
10
-
11
- class TestLang < MiniTest::Test
12
-
13
- def test_getters
14
-
15
- lang = SportDb.lang
16
- lang.lang = 'en'
17
-
18
- group = 'Group'
19
-
20
- round = 'Round|Matchday|Week'
21
- round << '|Round of 32|Last 32'
22
- round << '|Round of 16|Last 16|8th finals'
23
- round << '|Quarterfinals|Quarter-finals|Quarters|Quarterfinal|Last 8'
24
- round << '|Semifinals|Semi-finals|Semis|Last 4'
25
- round << '|Fifth place match|Fifth place|5th place match|5th place final|5th place|Match for fifth place|Match for 5th place'
26
- round << '|Third place match|Third-place match|Third place|3rd place match|3rd place final|3rd place|Match for third place|Match for 3rd place|Third-place play-off|Third place play-off'
27
- round << '|Final|Finals'
28
- round << '|Playoff|Playoffs|Play-off|Play-offs|Play-off for quarter-finals'
29
-
30
- knockout_round = 'Round of 32|Last 32'
31
- knockout_round << '|Round of 16|Last 16|8th finals'
32
- knockout_round << '|Quarterfinals|Quarter-finals|Quarters|Quarterfinal|Last 8'
33
- knockout_round << '|Semifinals|Semi-finals|Semis|Last 4'
34
- knockout_round << '|Fifth place match|Fifth place|5th place match|5th place final|5th place|Match for fifth place|Match for 5th place'
35
- knockout_round << '|Third place match|Third-place match|Third place|3rd place match|3rd place final|3rd place|Match for third place|Match for 3rd place|Third-place play-off|Third place play-off'
36
- knockout_round << '|Final|Finals'
37
- knockout_round << '|Playoff|Playoffs|Play-off|Play-offs|Play-off for quarter-finals'
38
-
39
- assert_equal group, lang.group
40
- assert_equal round, lang.round
41
- assert_equal knockout_round, lang.knockout_round
42
-
43
- # NB: call twice to test caching with ||=
44
- assert_equal group, lang.group
45
- assert_equal round, lang.round
46
- assert_equal knockout_round, lang.knockout_round
47
-
48
- end
49
-
50
- def test_getters_de
51
- lang = SportDb.lang
52
- lang.lang = 'de'
53
-
54
- group = 'Gruppe'
55
-
56
- round = 'Spieltag|Runde'
57
- round << '|Sechzehntelfinale|1/16 Finale'
58
- round << '|Achtelfinale|1/8 Finale'
59
- round << '|Viertelfinale|1/4 Finale'
60
- round << '|Halbfinale|Semifinale|1/2 Finale'
61
- round << '|Spiel um Platz 5'
62
- round << '|Spiel um Platz 3'
63
- round << '|Finale|Endspiel'
64
-
65
- knockout_round = 'Sechzehntelfinale|1/16 Finale'
66
- knockout_round << '|Achtelfinale|1/8 Finale'
67
- knockout_round << '|Viertelfinale|1/4 Finale'
68
- knockout_round << '|Halbfinale|Semifinale|1/2 Finale'
69
- knockout_round << '|Spiel um Platz 5'
70
- knockout_round << '|Spiel um Platz 3'
71
- knockout_round << '|Finale|Endspiel'
72
-
73
-
74
- assert_equal group, lang.group
75
- assert_equal round, lang.round
76
- assert_equal knockout_round, lang.knockout_round
77
-
78
- # NB: call twice to test caching with ||=
79
-
80
- assert_equal group, lang.group
81
- assert_equal round, lang.round
82
- assert_equal knockout_round, lang.knockout_round
83
- end
84
-
85
- def test_regex_knockout_round
86
- lang = SportDb.lang
87
- lang.lang = 'en'
88
-
89
- lines = [
90
- '(4) Quarter-finals',
91
- '(5) Semi-finals',
92
- '(6) Final',
93
- '(1) Play-off 1st Leg // 11–15 October',
94
- '(2) Play-off 2nd Leg // 15-19 November',
95
- '(1) Play-off for quarter-finals',
96
- '(4) Match for fifth place',
97
- '(5) Match for third place',
98
- ## check for ALL UPCASE too
99
- '(4) QUARTER-FINALS',
100
- '(5) SEMI-FINALS',
101
- '(6) FINAL'
102
- ]
103
-
104
- lines.each do |line|
105
- assert( line =~ lang.regex_knockout_round )
106
- end
107
-
108
- end
109
-
110
- def test_regex_knockout_round_de
111
- lang = SportDb.lang
112
- lang.lang = 'de'
113
-
114
- lines = [
115
- '(1) Achtelfinale // Di+Mi 14.+15. & 21.+22. Feb 2012',
116
- '(2) Achtelfinale Rückspiele // Di+Mi 6.+7. & 13.+14. März 2012',
117
- '(3) Viertelfinale // Di+Mi 27.+28. März 2012',
118
- '(4) Viertelfinale Rückspiele // Di+Mi 3.+4. April 2012',
119
- '(5) Halbfinale // Di+Mi 17.+18. April 2012',
120
- '(6) Halbfinale Rückspiele // Di+Mi 24.+25. April 2012',
121
- '(7) Finale // Sa 19. Mai 2012'
122
- ]
123
-
124
- lines.each do |line|
125
- assert( line =~ lang.regex_knockout_round )
126
- end
127
-
128
- end
129
-
130
- end # class TestLang