sportdb-langs 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/Manifest.txt +16 -0
- data/README.md +26 -0
- data/Rakefile +30 -0
- data/config/de.yml +27 -0
- data/config/en.yml +35 -0
- data/config/es.yml +28 -0
- data/config/fr.yml +36 -0
- data/config/it.yml +37 -0
- data/config/pt.yml +27 -0
- data/config/ro.yml +37 -0
- data/lib/sportdb/langs.rb +28 -0
- data/lib/sportdb/langs/lang.rb +140 -0
- data/lib/sportdb/langs/version.rb +30 -0
- data/test/helper.rb +8 -0
- data/test/test_lang.rb +125 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: af6c5e308db1fd11a1d44df5e98a9c51a88c7d6d
|
4
|
+
data.tar.gz: 6787554eeb07756da698cda8ac3d462967ea05d2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 05de60f164fe56f7263a0e421958a8adc6267a27ed008d3d90091cb4d887df9b3856d27f383ca5ed833bc84411b8e508c25d7fc0d9af1c6d885226376c4116a1
|
7
|
+
data.tar.gz: 0fc01d52b6a37762b1a8fe00b53776302f4dd28b4598c76acd503822698ee1e93633bbcbcd7917899f13083d7891062a1477ab5fc38e5d9c21f04d23c2db119d
|
data/CHANGELOG.md
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
CHANGELOG.md
|
2
|
+
Manifest.txt
|
3
|
+
README.md
|
4
|
+
Rakefile
|
5
|
+
config/de.yml
|
6
|
+
config/en.yml
|
7
|
+
config/es.yml
|
8
|
+
config/fr.yml
|
9
|
+
config/it.yml
|
10
|
+
config/pt.yml
|
11
|
+
config/ro.yml
|
12
|
+
lib/sportdb/langs.rb
|
13
|
+
lib/sportdb/langs/lang.rb
|
14
|
+
lib/sportdb/langs/version.rb
|
15
|
+
test/helper.rb
|
16
|
+
test/test_lang.rb
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# sportdb-langs - sport.db language utilities
|
2
|
+
|
3
|
+
|
4
|
+
* home :: [github.com/sportdb/sport.db](https://github.com/sportdb/sport.db)
|
5
|
+
* bugs :: [github.com/sportdb/sport.db/issues](https://github.com/sportdb/sport.db/issues)
|
6
|
+
* gem :: [rubygems.org/gems/sportdb-langs](https://rubygems.org/gems/sportdb-langs)
|
7
|
+
* rdoc :: [rubydoc.info/gems/sportdb-langs](http://rubydoc.info/gems/sportdb-langs)
|
8
|
+
* forum :: [opensport](http://groups.google.com/group/opensport)
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
To be done
|
15
|
+
|
16
|
+
## License
|
17
|
+
|
18
|
+
The `sportdb-langs` scripts are dedicated to the public domain.
|
19
|
+
Use it as you please with no restrictions whatsoever.
|
20
|
+
|
21
|
+
|
22
|
+
## Questions? Comments?
|
23
|
+
|
24
|
+
Send them along to the
|
25
|
+
[Open Sports & Friends Forum/Mailing List](http://groups.google.com/group/opensport).
|
26
|
+
Thanks!
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'hoe'
|
2
|
+
require './lib/sportdb/langs/version.rb'
|
3
|
+
|
4
|
+
Hoe.spec 'sportdb-langs' do
|
5
|
+
|
6
|
+
self.version = SportDb::Langs::VERSION
|
7
|
+
|
8
|
+
self.summary = "sportdb-langs - sport.db language utilities"
|
9
|
+
self.description = summary
|
10
|
+
|
11
|
+
self.urls = ['https://github.com/sportdb/sport.db']
|
12
|
+
|
13
|
+
self.author = 'Gerald Bauer'
|
14
|
+
self.email = 'opensport@googlegroups.com'
|
15
|
+
|
16
|
+
# switch extension to .markdown for gihub formatting
|
17
|
+
self.readme_file = 'README.md'
|
18
|
+
self.history_file = 'CHANGELOG.md'
|
19
|
+
|
20
|
+
self.licenses = ['Public Domain']
|
21
|
+
|
22
|
+
self.extra_deps = [
|
23
|
+
['logutils', '>= 0.6.1'],
|
24
|
+
]
|
25
|
+
|
26
|
+
self.spec_extras = {
|
27
|
+
required_ruby_version: '>= 2.2.2'
|
28
|
+
}
|
29
|
+
|
30
|
+
end
|
data/config/de.yml
ADDED
@@ -0,0 +1,27 @@
|
|
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
|
data/config/en.yml
ADDED
@@ -0,0 +1,35 @@
|
|
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
|
data/config/es.yml
ADDED
@@ -0,0 +1,28 @@
|
|
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
|
data/config/fr.yml
ADDED
@@ -0,0 +1,36 @@
|
|
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
|
data/config/it.yml
ADDED
@@ -0,0 +1,37 @@
|
|
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
|
data/config/pt.yml
ADDED
@@ -0,0 +1,27 @@
|
|
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 ??
|
data/config/ro.yml
ADDED
@@ -0,0 +1,37 @@
|
|
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 ??
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
|
4
|
+
## 3rd party libs/gems
|
5
|
+
require 'logutils' ## note: requires (stdlibs) pp, yaml, etc.
|
6
|
+
|
7
|
+
|
8
|
+
###
|
9
|
+
# our own code
|
10
|
+
require 'sportdb/langs/version' # let version always go first
|
11
|
+
require 'sportdb/langs/lang'
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
module SportDb
|
16
|
+
def self.lang
|
17
|
+
# todo/fix: find a better way for single instance ??
|
18
|
+
# will get us ruby warning: instance variable @lang not initialized => find a better way!!!
|
19
|
+
# just use @lang w/o .nil? e.g.
|
20
|
+
# @lang =|| Lang.new why? why not?? or better use @@lang =|| Lang.new for class variable!!!
|
21
|
+
@lang ||= Lang.new
|
22
|
+
@lang
|
23
|
+
end
|
24
|
+
end # module SportDb
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
puts SportDb::Langs.banner # say hello
|
@@ -0,0 +1,140 @@
|
|
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
|
+
langs = %w[en de es fr it pt ro]
|
19
|
+
|
20
|
+
load_words( langs, SportDb::Langs.config_path )
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def load_words( langs, include_path )
|
25
|
+
@lang = 'en' # make default lang english/en
|
26
|
+
@words = {} # resets fixtures
|
27
|
+
@cache = {} # reset cached values
|
28
|
+
|
29
|
+
langs.each_with_index do |lang,i|
|
30
|
+
path = "#{include_path}/#{lang}.yml"
|
31
|
+
logger.debug( "loading words #{lang} (#{i+1}/#{langs.size}) in (#{path})..." )
|
32
|
+
@words[ lang ] = YAML.load( File.open( path, 'r:utf-8' ).read )
|
33
|
+
@cache[ lang ] = {} ## setup empty cache (hash)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def lang=(value)
|
39
|
+
logger.debug "setting lang to #{value}"
|
40
|
+
|
41
|
+
@lang = value.to_s # note: make sure it's a string (not a symbol) - fix: use symbol internally - why? why not?
|
42
|
+
@lang
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
def group() @cache[ @lang ][ :group ] ||= build_group; end
|
47
|
+
def round() @cache[ @lang ][ :round ] ||= build_round; end
|
48
|
+
def knockout_round() @cache[ @lang ][ :knockout_round ] ||= build_knockout_round; end
|
49
|
+
def leg1() @cache[ @lang ][ :leg1 ] ||= build_leg1; end
|
50
|
+
def leg2() @cache[ @lang ][ :leg2 ] ||= build_leg2; end
|
51
|
+
|
52
|
+
|
53
|
+
## regex helpers
|
54
|
+
## todo/fix: escape for regex?
|
55
|
+
## note: let's ignore case (that is, UPCASE,downcase); always use /i flag
|
56
|
+
## todo: escape for regex?
|
57
|
+
## todo/fix: sort by length - biggest words go first? does regex match biggest word automatically?? - check
|
58
|
+
## todo/fix: make - optional e.g. convert to ( |-) or better [ \-] ??
|
59
|
+
## note: let's ignore case (that is, UPCASE,downcase); always use /i flag
|
60
|
+
## todo/fix: escape for regex?
|
61
|
+
## todo/fix: sort by length - biggest words go first? does regex match biggest word automatically?? - check
|
62
|
+
## todo/fix: make - optional e.g. convert to ( |-) or better [ \-] ??
|
63
|
+
## note: let's ignore case (that is, UPCASE,downcase); always use /i flag
|
64
|
+
## todo/fix: escape for regex?
|
65
|
+
## note: let's ignore case (that is, UPCASE,downcase); always use /i flag
|
66
|
+
## todo/fix: escape for regex?
|
67
|
+
## note: let's ignore case (that is, UPCASE,downcase); always use /i flag
|
68
|
+
def group_re() @cache[ @lang ][ :group_re ] ||= /#{group}/i; end
|
69
|
+
def round_re() @cache[ @lang ][ :round_re ] ||= /#{round}/i; end
|
70
|
+
def knockout_round_re() @cache[ @lang ][ :knockout_round_re ] ||= /#{knockout_round}/i; end
|
71
|
+
def leg1_re() @cache[ @lang ][ :leg1_re ] ||= /#{leg1}/i; end
|
72
|
+
def leg2_re() @cache[ @lang ][ :leg2_re ] ||= /#{leg2}/i; end
|
73
|
+
|
74
|
+
## "old" names - deprecated -remove latter!!!!
|
75
|
+
alias_method :regex_group, :group_re
|
76
|
+
alias_method :regex_round, :round_re
|
77
|
+
alias_method :regex_knockout_round, :knockout_round_re
|
78
|
+
alias_method :regex_leg1, :leg1_re
|
79
|
+
alias_method :regex_leg2, :leg2_re
|
80
|
+
|
81
|
+
|
82
|
+
def build_group
|
83
|
+
h = @words[ @lang ]
|
84
|
+
values = "" # Note: always construct a new string (do NOT use a reference to hash value)
|
85
|
+
values << h['group']
|
86
|
+
values
|
87
|
+
end
|
88
|
+
|
89
|
+
def build_round
|
90
|
+
# e.g. Spieltag|Runde|Achtelfinale|Viertelfinale|Halbfinale|Finale
|
91
|
+
|
92
|
+
## fix/todo:
|
93
|
+
## sort by length first - to allow best match e.g.
|
94
|
+
## 3rd place play-off instead of Play-off ?? etc. - why? why not?
|
95
|
+
h = @words[ @lang ]
|
96
|
+
values = "" # NB: always construct a new string (do NOT use a reference to hash value)
|
97
|
+
values << h['round']
|
98
|
+
|
99
|
+
### add knockout rounds values too
|
100
|
+
values << "|" << h['round32']
|
101
|
+
values << "|" << h['round16']
|
102
|
+
values << "|" << h['quarterfinals']
|
103
|
+
values << "|" << h['semifinals']
|
104
|
+
values << "|" << h['fifthplace'] if h['fifthplace'] # nb: allow empty/is optional!!
|
105
|
+
values << "|" << h['thirdplace']
|
106
|
+
values << "|" << h['final']
|
107
|
+
values << "|" << h['playoffs'] if h['playoffs'] # nb: allow empty/is optional!!
|
108
|
+
values
|
109
|
+
end
|
110
|
+
|
111
|
+
def build_leg1
|
112
|
+
h = @words[ @lang ]
|
113
|
+
values = "" # NB: always construct a new string (do NOT use a reference to hash value)
|
114
|
+
values << h['leg1']
|
115
|
+
values
|
116
|
+
end
|
117
|
+
|
118
|
+
def build_leg2
|
119
|
+
h = @words[ @lang ]
|
120
|
+
values = "" # NB: always construct a new string (do NOT use a reference to hash value)
|
121
|
+
values << h['leg2']
|
122
|
+
values
|
123
|
+
end
|
124
|
+
|
125
|
+
def build_knockout_round
|
126
|
+
h = @words[ @lang ]
|
127
|
+
values = "" # NB: always construct a new string (do NOT use a reference to hash value)
|
128
|
+
values << h['round32']
|
129
|
+
values << "|" << h['round16']
|
130
|
+
values << "|" << h['quarterfinals']
|
131
|
+
values << "|" << h['semifinals']
|
132
|
+
values << "|" << h['fifthplace'] if h['fifthplace'] # nb: allow empty/is optional!!
|
133
|
+
values << "|" << h['thirdplace']
|
134
|
+
values << "|" << h['final']
|
135
|
+
values << "|" << h['playoffs'] if h['playoffs'] # nb: allow empty/is optional!!
|
136
|
+
values
|
137
|
+
end
|
138
|
+
|
139
|
+
end # class Lang
|
140
|
+
end # module SportDb
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
|
4
|
+
module SportDb
|
5
|
+
module Langs ## note: we use Langs with s (plular)
|
6
|
+
|
7
|
+
MAJOR = 0 ## todo: namespace inside version or something - why? why not??
|
8
|
+
MINOR = 0
|
9
|
+
PATCH = 1
|
10
|
+
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
11
|
+
|
12
|
+
def self.version
|
13
|
+
VERSION
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.banner
|
17
|
+
"sportdb-langs/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.root
|
21
|
+
File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def self.config_path
|
26
|
+
"#{root}/config"
|
27
|
+
end
|
28
|
+
|
29
|
+
end # module Langs
|
30
|
+
end # module SportDb
|
data/test/helper.rb
ADDED
data/test/test_lang.rb
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_lang.rb
|
6
|
+
|
7
|
+
require 'helper'
|
8
|
+
|
9
|
+
class TestLang < MiniTest::Test
|
10
|
+
|
11
|
+
def test_en
|
12
|
+
|
13
|
+
lang = SportDb.lang
|
14
|
+
lang.lang = 'en'
|
15
|
+
|
16
|
+
group = 'Group'
|
17
|
+
|
18
|
+
round = 'Round|Matchday|Week'
|
19
|
+
round << '|Round of 32|Last 32'
|
20
|
+
round << '|Round of 16|Last 16|8th finals'
|
21
|
+
round << '|Quarterfinals|Quarter-finals|Quarters|Quarterfinal|Last 8'
|
22
|
+
round << '|Semifinals|Semi-finals|Semis|Last 4'
|
23
|
+
round << '|Fifth place match|Fifth place|5th place match|5th place final|5th place|Match for fifth place|Match for 5th place'
|
24
|
+
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'
|
25
|
+
round << '|Final|Finals'
|
26
|
+
round << '|Playoff|Playoffs|Play-off|Play-offs|Play-off for quarter-finals'
|
27
|
+
|
28
|
+
knockout_round = 'Round of 32|Last 32'
|
29
|
+
knockout_round << '|Round of 16|Last 16|8th finals'
|
30
|
+
knockout_round << '|Quarterfinals|Quarter-finals|Quarters|Quarterfinal|Last 8'
|
31
|
+
knockout_round << '|Semifinals|Semi-finals|Semis|Last 4'
|
32
|
+
knockout_round << '|Fifth place match|Fifth place|5th place match|5th place final|5th place|Match for fifth place|Match for 5th place'
|
33
|
+
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'
|
34
|
+
knockout_round << '|Final|Finals'
|
35
|
+
knockout_round << '|Playoff|Playoffs|Play-off|Play-offs|Play-off for quarter-finals'
|
36
|
+
|
37
|
+
assert_equal group, lang.group
|
38
|
+
assert_equal round, lang.round
|
39
|
+
assert_equal knockout_round, lang.knockout_round
|
40
|
+
|
41
|
+
# Note: call twice to test caching with ||=
|
42
|
+
assert_equal group, lang.group
|
43
|
+
assert_equal round, lang.round
|
44
|
+
assert_equal knockout_round, lang.knockout_round
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_de
|
48
|
+
lang = SportDb.lang
|
49
|
+
lang.lang = 'de'
|
50
|
+
|
51
|
+
group = 'Gruppe'
|
52
|
+
|
53
|
+
round = 'Spieltag|Runde'
|
54
|
+
round << '|Sechzehntelfinale|1/16 Finale'
|
55
|
+
round << '|Achtelfinale|1/8 Finale'
|
56
|
+
round << '|Viertelfinale|1/4 Finale'
|
57
|
+
round << '|Halbfinale|Semifinale|1/2 Finale'
|
58
|
+
round << '|Spiel um Platz 5'
|
59
|
+
round << '|Spiel um Platz 3'
|
60
|
+
round << '|Finale|Endspiel'
|
61
|
+
|
62
|
+
knockout_round = 'Sechzehntelfinale|1/16 Finale'
|
63
|
+
knockout_round << '|Achtelfinale|1/8 Finale'
|
64
|
+
knockout_round << '|Viertelfinale|1/4 Finale'
|
65
|
+
knockout_round << '|Halbfinale|Semifinale|1/2 Finale'
|
66
|
+
knockout_round << '|Spiel um Platz 5'
|
67
|
+
knockout_round << '|Spiel um Platz 3'
|
68
|
+
knockout_round << '|Finale|Endspiel'
|
69
|
+
|
70
|
+
|
71
|
+
assert_equal group, lang.group
|
72
|
+
assert_equal round, lang.round
|
73
|
+
assert_equal knockout_round, lang.knockout_round
|
74
|
+
|
75
|
+
# Note: call twice to test caching with ||=
|
76
|
+
assert_equal group, lang.group
|
77
|
+
assert_equal round, lang.round
|
78
|
+
assert_equal knockout_round, lang.knockout_round
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
def test_en__knockout_round_re
|
83
|
+
lang = SportDb.lang
|
84
|
+
lang.lang = 'en'
|
85
|
+
|
86
|
+
lines = [
|
87
|
+
'(4) Quarter-finals',
|
88
|
+
'(5) Semi-finals',
|
89
|
+
'(6) Final',
|
90
|
+
'(1) Play-off 1st Leg // 11–15 October',
|
91
|
+
'(2) Play-off 2nd Leg // 15-19 November',
|
92
|
+
'(1) Play-off for quarter-finals',
|
93
|
+
'(4) Match for fifth place',
|
94
|
+
'(5) Match for third place',
|
95
|
+
## check for ALL UPCASE too
|
96
|
+
'(4) QUARTER-FINALS',
|
97
|
+
'(5) SEMI-FINALS',
|
98
|
+
'(6) FINAL'
|
99
|
+
]
|
100
|
+
|
101
|
+
lines.each do |line|
|
102
|
+
assert( line =~ lang.knockout_round_re )
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_de__knockout_round_re
|
107
|
+
lang = SportDb.lang
|
108
|
+
lang.lang = 'de'
|
109
|
+
|
110
|
+
lines = [
|
111
|
+
'(1) Achtelfinale // Di+Mi 14.+15. & 21.+22. Feb 2012',
|
112
|
+
'(2) Achtelfinale Rückspiele // Di+Mi 6.+7. & 13.+14. März 2012',
|
113
|
+
'(3) Viertelfinale // Di+Mi 27.+28. März 2012',
|
114
|
+
'(4) Viertelfinale Rückspiele // Di+Mi 3.+4. April 2012',
|
115
|
+
'(5) Halbfinale // Di+Mi 17.+18. April 2012',
|
116
|
+
'(6) Halbfinale Rückspiele // Di+Mi 24.+25. April 2012',
|
117
|
+
'(7) Finale // Sa 19. Mai 2012'
|
118
|
+
]
|
119
|
+
|
120
|
+
lines.each do |line|
|
121
|
+
assert( line =~ lang.knockout_round_re )
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
end # class TestLang
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sportdb-langs
|
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-11-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: logutils
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.6.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.6.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hoe
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.16'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.16'
|
55
|
+
description: sportdb-langs - sport.db language utilities
|
56
|
+
email: opensport@googlegroups.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files:
|
60
|
+
- CHANGELOG.md
|
61
|
+
- Manifest.txt
|
62
|
+
- README.md
|
63
|
+
files:
|
64
|
+
- CHANGELOG.md
|
65
|
+
- Manifest.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- config/de.yml
|
69
|
+
- config/en.yml
|
70
|
+
- config/es.yml
|
71
|
+
- config/fr.yml
|
72
|
+
- config/it.yml
|
73
|
+
- config/pt.yml
|
74
|
+
- config/ro.yml
|
75
|
+
- lib/sportdb/langs.rb
|
76
|
+
- lib/sportdb/langs/lang.rb
|
77
|
+
- lib/sportdb/langs/version.rb
|
78
|
+
- test/helper.rb
|
79
|
+
- test/test_lang.rb
|
80
|
+
homepage: https://github.com/sportdb/sport.db
|
81
|
+
licenses:
|
82
|
+
- Public Domain
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options:
|
86
|
+
- "--main"
|
87
|
+
- README.md
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 2.2.2
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.5.2
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: sportdb-langs - sport.db language utilities
|
106
|
+
test_files: []
|