sportdb-readers 0.4.2 → 0.4.3

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: d9ab08e50e95d7fbaf6197f8cea2a7a6dc3cb112
4
- data.tar.gz: 68a911b62e1fc80ab12d55874d2e6bc0f3dd63a5
3
+ metadata.gz: 935075d2b41927e37e8ccf597d5b3f0dee8e7009
4
+ data.tar.gz: 5d0e4a742fd769021d9272e6401d1584acfac367
5
5
  SHA512:
6
- metadata.gz: 73241f497262aaeb3b10a694c7af959745254adfcaa825ef577cbfcf89a5c44b1b6dd795e5c216bb69c6923af477b8306614675e7acd7c82729bb55fab39196e
7
- data.tar.gz: 19b772c539490c3e41d9d0324ec1b54afe7b5a973065491a0d14798f1b0dc9242974076d278ded95bbdfa146d5a31fcf7e1ecd1a68aba4e2a19472176ee93e24
6
+ metadata.gz: af375d0924b115d0ba81bc6b4f52a6e5d4af672c40a56bf922d83fcad4fb57bf8fd16a5cda304f6dff4f34b07c49e23088dd4dc160e0c6336ca02525b5481068
7
+ data.tar.gz: 3416642226590a5448c4a8f094f3db2e85693d37e0aeda5dff901ca0888977346af99ba9450fe9035cc31c395768d35c6fd13e42bedf6637685f0cea3bd60104
@@ -53,12 +53,14 @@ class AutoConfParser
53
53
 
54
54
  ## remove all protected text runs e.g. []
55
55
  ## fix: add [ to end-of-line too
56
+ ## todo/fix: move remove protected text runs AFTER find date!! - why? why not?
56
57
 
57
58
  line = line.gsub( /\[
58
59
  [^\]]+?
59
60
  \]/x, '' ).strip
60
61
  return true if line.empty? ## note: return true (for valid line with no match/clubs)
61
62
 
63
+
62
64
  ## split by geo (@) - remove for now
63
65
  values = line.split( '@' )
64
66
  line = values[0]
@@ -71,9 +73,19 @@ class AutoConfParser
71
73
  [^\]]+?
72
74
  \]/x, '' ).strip
73
75
 
74
- return true if line.empty? ## note: return true (for valid line with no match/clubs)
76
+ else
77
+ ## check for leading hours only e.g. 20.30 or 20:30 or 20h30
78
+ ## todo/fix: make language dependent (or move to find_date/hour etc.) - why? why not?
79
+ line = line.sub( %r{^
80
+ [12]?[0-9]
81
+ [h.:]
82
+ [0-9][0-9]
83
+ (?=[ ]) ## must be followed by space for now (add end of line too - why? why not?)
84
+ }x, '' ).strip
75
85
  end
76
86
 
87
+ return true if line.empty? ## note: return true (for valid line with no match/clubs)
88
+
77
89
 
78
90
  scores = find_scores!( line )
79
91
 
@@ -103,6 +115,15 @@ class AutoConfParser
103
115
  values = values.select { |value| !value.empty? } ## remove empty strings
104
116
 
105
117
  return true if values.size == 0 ## note: return true (for valid line with no match/clubs)
118
+
119
+ if values.size == 1
120
+ puts "(auto config) try matching clubs separated by spaces (2+):"
121
+ pp values
122
+
123
+ values = values[0].split( /[ ]{2,}/ )
124
+ pp values
125
+ end
126
+
106
127
  return false if values.size != 2
107
128
 
108
129
  puts "(auto config) try matching clubs:"
@@ -21,6 +21,12 @@ class MatchReaderV2 ## todo/check: rename to MatchReaderV2 (use plural?) why?
21
21
  league = Sync::League.find_or_create( rec[:league] )
22
22
  season = Sync::Season.find_or_create( rec[:season] )
23
23
 
24
+
25
+ ## todo/fix:
26
+ ## always auto create
27
+ ## 1) check for clubs count on event/stage - only if count == 0 use autoconf!!!
28
+ ## 2) add lang switch for date/lang too!!!!
29
+
24
30
  stage = nil
25
31
  auto_conf_clubs = nil
26
32
  if rec[:stage]
@@ -49,9 +55,7 @@ class MatchReaderV2 ## todo/check: rename to MatchReaderV2 (use plural?) why?
49
55
  ## step 1: map/find clubs
50
56
  club_recs = []
51
57
  ## note: loop over keys (holding the names); values hold the usage counter!! e.g. 'Arsenal' => 2, etc.
52
- country = config.countries[ league.country.key ] ## hack/fix: convert to Import::Country from Model::Country
53
- ## todo: check is_a? Country check to respond_to? :key in match in sportdb-clubs !!!!!
54
- ## todo/fix: just pass in league.country (and NOT key)
58
+ country = league.country
55
59
  auto_conf_clubs.keys.each do |name|
56
60
  club_rec = config.clubs.find_by!( name: name, country: country )
57
61
  club_recs << club_rec
@@ -79,18 +83,24 @@ class MatchReaderV2 ## todo/check: rename to MatchReaderV2 (use plural?) why?
79
83
  end
80
84
 
81
85
  ## hack for now: switch lang
82
- if ['at', 'de'].include?( league.country.key )
86
+ if ['de', 'at'].include?( league.country.key )
83
87
  SportDb.lang.lang = 'de'
84
- DateFormats.lang = 'de'
88
+ DateFormats.lang = 'de'
85
89
  elsif ['fr'].include?( league.country.key )
86
90
  SportDb.lang.lang = 'fr'
87
- DateFormats.lang = 'fr'
88
- elsif ['es'].include?( league.country.key )
91
+ DateFormats.lang = 'fr'
92
+ elsif ['it'].include?( league.country.key )
93
+ SportDb.lang.lang = 'it'
94
+ DateFormats.lang = 'it'
95
+ elsif ['es', 'mx'].include?( league.country.key )
89
96
  SportDb.lang.lang = 'es'
90
- DateFormats.lang = 'es'
97
+ DateFormats.lang = 'es'
98
+ elsif ['pt', 'br'].include?( league.country.key )
99
+ SportDb.lang.lang = 'pt'
100
+ DateFormats.lang = 'pt'
91
101
  else
92
102
  SportDb.lang.lang = 'en'
93
- DateFormats.lang = 'en'
103
+ DateFormats.lang = 'en'
94
104
  end
95
105
 
96
106
  ## todo/fix: set lang for now depending on league country!!!
@@ -6,7 +6,7 @@ module Readers
6
6
 
7
7
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
8
8
  MINOR = 4
9
- PATCH = 2
9
+ PATCH = 3
10
10
  VERSION = [MAJOR,MINOR,PATCH].join('.')
11
11
 
12
12
  def self.version
@@ -11,6 +11,162 @@ require 'helper'
11
11
 
12
12
  class TestAutoConfParser < MiniTest::Test
13
13
 
14
+ def test_at
15
+ txt = <<TXT
16
+ 29. Runde
17
+
18
+ [Sa 7.4.]
19
+ 16.00 RB Salzburg 2:0 Wacker Innsbruck
20
+ 18.30 SV Ried 0:1 Austria Wien
21
+ Kapfenberger SV 2:3 Admira Wacker
22
+ Rapid Wien 2:1 Wr. Neustadt
23
+ [So 8.4.]
24
+ 16.00 SV Mattersburg 0:2 Sturm Graz
25
+
26
+
27
+ 30. Runde
28
+
29
+ [Sa 14.4.]
30
+ 16.00 Wr. Neustadt 0:0 Kapfenberger SV
31
+ 18.30 Admira Wacker 1:1 Wacker Innsbruck
32
+ Sturm Graz 2:2 RB Salzburg
33
+ SV Ried 2:0 SV Mattersburg
34
+ [So 15.4.]
35
+ 16.00 Austria Wien 0:0 Rapid Wien
36
+
37
+ TXT
38
+
39
+ clubs = parse( txt, lang: 'de' )
40
+
41
+ assert_equal Hash(
42
+ 'RB Salzburg' => 2,
43
+ 'Wacker Innsbruck' => 2,
44
+ 'SV Ried' => 2,
45
+ 'Austria Wien' => 2,
46
+ 'Kapfenberger SV' => 2,
47
+ 'Admira Wacker' => 2,
48
+ 'Rapid Wien' => 2,
49
+ 'Wr. Neustadt' => 2,
50
+ 'SV Mattersburg' => 2,
51
+ 'Sturm Graz' => 2 ), clubs
52
+ end
53
+
54
+ def test_es
55
+ txt = <<TXT
56
+ Jornada 1
57
+
58
+ 18.08.2012 Barcelona R. Sociedad 5-1
59
+ 18.08.2012 Levante Atlético 1-1
60
+ 18.08.2012 Athletic Betis 3-5
61
+ 18.08.2012 Zaragoza Valladolid 0-1
62
+ 18.08.2012 R. Madrid Valencia 1-1
63
+ 18.08.2012 Celta Málaga 0-1
64
+ 18.08.2012 Sevilla Getafe 2-1
65
+ 18.08.2012 Mallorca Espanyol 2-1
66
+ 18.08.2012 Rayo Granada 1-0
67
+ 18.08.2012 Deportivo Osasuna 2-0
68
+
69
+
70
+ Jornada 2
71
+
72
+ 25.08.2012 Valladolid Levante 2-0
73
+ 25.08.2012 Espanyol Zaragoza 1-2
74
+ 25.08.2012 Málaga Mallorca 1-1
75
+ 25.08.2012 R. Sociedad Celta 2-1
76
+ 25.08.2012 Osasuna Barcelona 1-2
77
+ 25.08.2012 Valencia Deportivo 3-3
78
+ 25.08.2012 Getafe R. Madrid 2-1
79
+ 25.08.2012 Granada Sevilla 1-1
80
+ 25.08.2012 Betis Rayo 1-2
81
+ 25.08.2012 Atlético Athletic 4-0
82
+ TXT
83
+
84
+ clubs = parse( txt, lang: 'es' )
85
+
86
+ assert_equal Hash(#
87
+ 'Barcelona' => 2,
88
+ 'R. Sociedad' => 2,
89
+ 'Levante' => 2,
90
+ 'Atlético' => 2,
91
+ 'Athletic' => 2,
92
+ 'Betis' => 2,
93
+ 'Zaragoza' => 2,
94
+ 'Valladolid' => 2,
95
+ 'R. Madrid' => 2,
96
+ 'Valencia' => 2,
97
+ 'Celta' => 2,
98
+ 'Málaga' => 2,
99
+ 'Sevilla' => 2,
100
+ 'Getafe' => 2,
101
+ 'Mallorca' => 2,
102
+ 'Espanyol' => 2,
103
+ 'Rayo' => 2,
104
+ 'Granada' => 2,
105
+ 'Deportivo' => 2,
106
+ 'Osasuna' => 2), clubs
107
+ end
108
+
109
+
110
+ def test_fr
111
+ txt = <<TXT
112
+ Journée 1
113
+
114
+ [Ven 8. Août]
115
+ 20h30 Stade de Reims 2-2 Paris SG
116
+ [Sam 9. Août]
117
+ 21h00 SC Bastia 3-3 Olympique de Marseille
118
+ Évian TG 0-3 SM Caen
119
+ EA Guingamp 0-2 AS Saint-Étienne
120
+ LOSC Lille 0-0 FC Metz
121
+ Montpellier Hérault SC 0-1 Girondins de Bordeaux
122
+ FC Nantes 1-0 RC Lens
123
+ OGC Nice 3-2 Toulouse FC
124
+ [Dim 10. Août]
125
+ 17h00 Olympique Lyonnais 2-0 Stade Rennais FC
126
+ 21h00 AS Monaco FC 1-2 FC Lorient
127
+
128
+ Journée 2
129
+
130
+ [Ven 15. Août]
131
+ 20h30 SM Caen 0-1 LOSC Lille
132
+ [Sam 16. Août]
133
+ 17h00 Paris SG 2-0 SC Bastia
134
+ 20h00 RC Lens 0-1 EA Guingamp
135
+ FC Lorient 0-0 OGC Nice
136
+ FC Metz 1-1 FC Nantes
137
+ Stade Rennais FC 6-2 Évian TG
138
+ Toulouse FC 2-1 Olympique Lyonnais
139
+ [Dim 17. Août]
140
+ 17h00 Olympique de Marseille 0-2 Montpellier Hérault SC
141
+ AS Saint-Étienne 3-1 Stade de Reims
142
+ 21h00 Girondins de Bordeaux 4-1 AS Monaco FC
143
+ TXT
144
+
145
+ clubs = parse( txt, lang: 'fr' )
146
+
147
+ assert_equal Hash(
148
+ 'Stade de Reims' => 2,
149
+ 'Paris SG' => 2,
150
+ 'SC Bastia' => 2,
151
+ 'Olympique de Marseille' => 2,
152
+ 'Évian TG' => 2,
153
+ 'SM Caen' => 2,
154
+ 'EA Guingamp' => 2,
155
+ 'AS Saint-Étienne' => 2,
156
+ 'LOSC Lille' => 2,
157
+ 'FC Metz' => 2,
158
+ 'Montpellier Hérault SC' => 2,
159
+ 'Girondins de Bordeaux' => 2,
160
+ 'FC Nantes' => 2,
161
+ 'RC Lens' => 2,
162
+ 'OGC Nice' => 2,
163
+ 'Toulouse FC' => 2,
164
+ 'Olympique Lyonnais' => 2,
165
+ 'Stade Rennais FC' => 2,
166
+ 'AS Monaco FC' => 2,
167
+ 'FC Lorient' => 2), clubs
168
+ end
169
+
14
170
  def test_eng
15
171
  txt = <<TXT
16
172
  Matchday 1
@@ -70,8 +226,61 @@ TXT
70
226
  'Tottenham Hotspur' => 2,
71
227
  'Manchester United' => 2,
72
228
  'West Ham United' => 2 ), clubs
229
+
230
+
231
+ txt =<<TXT
232
+ Round 38
233
+
234
+ May/22 Aston Villa 1-0 Liverpool
235
+ May/22 Bolton 0-2 Manchester City
236
+ May/22 Everton 1-0 Chelsea
237
+ May/22 Fulham 2-2 Arsenal
238
+ May/22 Manchester United 4-2 Blackpool
239
+ May/22 Newcastle Utd 3-3 West Brom
240
+ May/22 Stoke City 0-1 Wigan
241
+ May/22 Tottenham 2-1 Birmingham
242
+ May/22 West Ham 0-3 Sunderland
243
+ May/22 Wolves 2-3 Blackburn
244
+
245
+ Round 37
246
+
247
+ May/17 Manchester City 3-0 Stoke City
248
+ May/15 Arsenal 1-2 Aston Villa
249
+ May/15 Birmingham 0-2 Fulham
250
+ May/15 Liverpool 0-2 Tottenham
251
+ May/15 Wigan 3-2 West Ham
252
+ May/15 Chelsea 2-2 Newcastle Utd
253
+ May/14 Blackburn 1-1 Manchester United
254
+ May/14 Blackpool 4-3 Bolton
255
+ May/14 Sunderland 1-3 Wolves
256
+ May/14 West Brom 1-0 Everton
257
+ TXT
258
+ clubs = parse( txt )
259
+
260
+ assert_equal Hash(
261
+ 'Aston Villa' => 2,
262
+ 'Liverpool' => 2,
263
+ 'Bolton' => 2,
264
+ 'Manchester City' => 2,
265
+ 'Everton' => 2,
266
+ 'Chelsea' => 2,
267
+ 'Fulham' => 2,
268
+ 'Arsenal' => 2,
269
+ 'Manchester United' => 2,
270
+ 'Blackpool' => 2,
271
+ 'Newcastle Utd' => 2,
272
+ 'West Brom' => 2,
273
+ 'Stoke City'=> 2,
274
+ 'Wigan' => 2,
275
+ 'Tottenham' => 2,
276
+ 'Birmingham' => 2,
277
+ 'West Ham' => 2,
278
+ 'Sunderland' => 2,
279
+ 'Wolves' => 2,
280
+ 'Blackburn' => 2), clubs
73
281
  end # method test_parse
74
282
 
283
+
75
284
  def test_mauritius
76
285
  txt = <<TXT
77
286
  Preliminary Round
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-readers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.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-28 00:00:00.000000000 Z
11
+ date: 2019-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sportdb-config