worldfootball 0.2.0 → 0.2.2

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
  SHA256:
3
- metadata.gz: 78c749dd421814981a58c87104761091471a4ffe26a8261df132d77bca5ffb8f
4
- data.tar.gz: 23a146156f4e38f0e92ef9689ed6a965b044e6ae2e489cffb5da56883c7e6e7a
3
+ metadata.gz: 2e871cd1caa08e419ec61ec216e95becce7c4d7523f189d72819c8caeac3d064
4
+ data.tar.gz: e02aeb59551d0b67a3719fb770a4cbd66f0f0a8cefd707030e9c694c64e09920
5
5
  SHA512:
6
- metadata.gz: 64e28d3ffdb1056f9db34459ca7d23ba2116a9aeb8130d3b81a310590fc0ad5079eff635664d153a2798b5e9765a10e7508311d0c899b82c1c59f98bedecc60c
7
- data.tar.gz: 52ef6922b2b1e735a67b9aae8ecd409c3314aa3d2a48b056d2be2d272b85c4e48735e983dda88630c461a25354a5f6f9cb64eb0cb4d6f642cf873263da3af954
6
+ metadata.gz: 2a87baa018202326f680a82a964a215e77d776dea8d49cd7d30909840b2309fc3b9f562c2ded0f27513e21df24b83c6c6aa4b2ccf8ecda3619594dedd4f6ca53
7
+ data.tar.gz: 8c52cf35ac656cee3281921ce83fb0f947385bcf11d719c98ec8506f5b8b172fc574dacbce5dbc35864056cc313e7177f4118651e28cec303e5e0e53d0fe6e2a
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.2.0
1
+ ### 0.2.2
2
2
 
3
3
  ### 0.0.1 / 2024-07-04
4
4
 
data/Manifest.txt CHANGED
@@ -3,13 +3,17 @@ Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
5
  bin/wfb
6
+ config/leagues_america.csv
6
7
  config/leagues_asia.csv
7
8
  config/leagues_europe.csv
9
+ config/leagues_middle_east.csv
10
+ config/leagues_pacific.csv
11
+ config/rounds.csv
12
+ config/stages.csv
8
13
  lib/worldfootball.rb
9
14
  lib/worldfootball/build-parse_score.rb
10
15
  lib/worldfootball/build.rb
11
16
  lib/worldfootball/cache.rb
12
- lib/worldfootball/config.rb
13
17
  lib/worldfootball/convert.rb
14
18
  lib/worldfootball/convert_reports.rb
15
19
  lib/worldfootball/download.rb
@@ -18,5 +22,6 @@ lib/worldfootball/mods.rb
18
22
  lib/worldfootball/page.rb
19
23
  lib/worldfootball/page_report.rb
20
24
  lib/worldfootball/page_schedule.rb
25
+ lib/worldfootball/stages.rb
21
26
  lib/worldfootball/vacuum.rb
22
27
  lib/worldfootball/version.rb
data/bin/wfb CHANGED
@@ -30,6 +30,8 @@ def self.main( args=ARGV )
30
30
  opts = {
31
31
  cached: false,
32
32
  convert: true,
33
+ file: nil,
34
+ dry: false,
33
35
  }
34
36
 
35
37
 
@@ -43,19 +45,24 @@ parser = OptionParser.new do |parser|
43
45
  ## todo - add a single letter option for offline/cached
44
46
 
45
47
  parser.on( "--cache", "--cached", "--offline",
46
- "use cached data in >#{Webcache.root}<" ) do |cached|
48
+ "use cached data in #{Webcache.root}" ) do |cached|
47
49
  opts[:cached] = cached
48
50
  end
49
51
 
50
- parser.on( "--no-convert",
51
- "turn off conversion to .csv in #{Worldfootball.config.convert.out_dir} - default is (#{!opts[:convert]})" ) do |convert|
52
- opts[:convert] = !convert
52
+ parser.on( "--[no-]convert",
53
+ "turn on/off conversion to .csv in #{Worldfootball.config.convert.out_dir} - default is (#{opts[:convert]})" ) do |convert|
54
+ opts[:convert] = convert
53
55
  end
54
56
 
55
57
  parser.on( "--dry",
56
- "dry run / show league page meta info" ) do |dry|
58
+ "dry run; do NOT write - default is (#{opts[:dry]})" ) do |dry|
57
59
  opts[:dry] = dry
58
60
  end
61
+
62
+ parser.on( "-f FILE", "--file FILE",
63
+ "read leagues (and seasons) via .csv file") do |file|
64
+ opts[:file] = file
65
+ end
59
66
  end
60
67
 
61
68
 
@@ -90,62 +97,66 @@ if ['league', 'leagues', 'ls'].include?( args[0] || 'leagues' )
90
97
  end
91
98
 
92
99
 
100
+ ####
101
+ # assume leagues
93
102
 
94
- league_code = args[0].downcase
95
-
96
- league = find_league!( league_code ) ## league info lookup
97
-
98
- if opts[:dry]
99
- ## output more page meta info
100
- puts "league meta:"
101
- pp league
102
- end
103
-
104
-
105
- ## note - default to latest season of league
106
- ## might be 2024/25 or 2024 or
107
- # for world cup 2022 or such
108
- season = Season( args[1] || league.seasons.keys[0] )
109
-
110
- pages = league.pages!( season: season )
103
+ datasets = if opts[:file]
104
+ read_datasets( opts[:file] )
105
+ else
106
+ parse_datasets_args( args )
107
+ end
111
108
 
112
109
 
113
- puts
114
- pp [league.key, season.key]
115
- pp pages
116
- puts " #{pages.size} page(s)"
110
+ datasets.each do |league_key, seasons|
117
111
 
112
+ league = find_league!( league_key ) ## league info lookup
118
113
 
119
- if opts[:dry]
120
- ## stop here if dry run
121
- exit 0
122
- end
123
-
124
-
125
- if opts[:cached]
126
- # do nothing
127
- else ## download to cache
128
- pages.each_with_index do |(slug,_),i|
129
- puts "==> #{i+1}/#{pages.size} - #{league_code} @ #{slug}..."
130
- page = Metal.download_schedule( slug )
131
- end
132
- end
133
-
134
-
135
- pages.each_with_index do |(slug,_),i|
136
- puts "==> #{i+1}/#{pages.size} - #{league_code} @ #{slug}..."
137
- page = Page::Schedule.from_cache( slug )
138
- matches = page.matches
139
-
140
- puts " #{matches.size} match(es)"
141
- end
114
+ if opts[:dry]
115
+ ## output more page meta info
116
+ puts "league meta:"
117
+ pp league
118
+ end
142
119
 
120
+ ## note - default to latest season of league
121
+ ## might be 2024/25 or 2024 or
122
+ # for world cup 2022 or such
123
+ seasons = [Season(league.seasons.keys[0])] if seasons.empty?
124
+
125
+ seasons.each do |season|
126
+ pages = league.pages!( season: season )
127
+ puts
128
+ pp [league.key, season.key]
129
+ pp pages
130
+ puts " #{pages.size} page(s)"
131
+
132
+
133
+ next if opts[:dry] ## stop here if dry run
134
+
135
+ if opts[:cached]
136
+ # do nothing
137
+ else ## download to cache
138
+ pages.each_with_index do |(slug,_),i|
139
+ puts "==> #{i+1}/#{pages.size} - #{league_key} @ #{slug}..."
140
+ page = Metal.download_schedule( slug )
141
+ end
142
+ end
143
+
144
+ pages.each_with_index do |(slug,_),i|
145
+ puts "==> #{i+1}/#{pages.size} - #{league_key} @ #{slug}..."
146
+ page = Page::Schedule.from_cache( slug )
147
+ matches = page.matches
148
+
149
+ puts " #{matches.size} match(es)"
150
+ end
151
+
152
+ if opts[:convert]
153
+ ## write out (export to) comma-separated values (.csv) datafile
154
+ convert( league: league_key,
155
+ season: season )
156
+ end
157
+ end # each seasons
158
+ end # each league
143
159
 
144
- if opts[:convert]
145
- ## write out (export to) comma-separated values (.csv) datafile
146
- convert( league: league_code,
147
- season: season )
148
- end
149
160
  end # def self.main
150
161
  end # module Worldfootball
151
162
 
@@ -0,0 +1,70 @@
1
+ key, slug
2
+
3
+
4
+ # todo/fix: adjust date/time by -6 or 7 hours!!!
5
+ # /can-canadian-championship-2020/
6
+ # - Qual. 1. Runde
7
+ # - Qual. 2. Runde
8
+ # - Qual. 3. Runde
9
+ # todo/fix: check for leagues - premier league? championship? soccer league?
10
+ ca.1, can-premier-league-2024
11
+ ca.cup, can-canadian-championship-2024
12
+
13
+
14
+ # todo/fix: adjust date/time by -7 hours!!!
15
+ ## e.g. 25.07.2020 02:30 => 24.07.2020 19.30
16
+ # 11.01.2020 04:00 => 10.01.2020 21.00
17
+ #
18
+ # e.g. /mex-primera-division-2020-2021-apertura/
19
+ # /mex-primera-division-2019-2020-clausura/
20
+ # /mex-primera-division-2019-2020-apertura-playoffs/
21
+ # - Viertelfinale
22
+ # - Halbfinale
23
+ # - Finale
24
+ # /mex-primera-division-2018-2019-clausura-playoffs/
25
+ mx.1, mex-primera-division-2024-2025-apertura_2
26
+ mx.2, mex-liga-de-expansion-2024-2025-apertura
27
+ mx.cup, mex-copa-mx-2019-2020
28
+
29
+
30
+
31
+ ## change to mls - why? why not?
32
+ us.1, usa-major-league-soccer-2024
33
+ us.2, usa-usl-championship-2024
34
+ us.cup, usa-u-s-open-cup-2024
35
+
36
+
37
+
38
+ br.1, bra-serie-a-2024
39
+ br.2, bra-serie-b-2024
40
+ br.cup, bra-copa-do-brasil-2024
41
+
42
+
43
+ co.1, col-primera-a-2024-clausura
44
+ co.2, col-primera-b-2024-clausura
45
+ co.cup, col-copa-colombia-2024
46
+
47
+
48
+ cl.1, chi-primera-division-2024
49
+ cl.cup, chi-copa-chile-2024
50
+
51
+ ec.1, ecu-serie-a-2024-segunda-etapa
52
+ ec.2, ecu-serie-b-2024_2
53
+
54
+ bo.1, bol-liga-profesional-2024-clausura
55
+
56
+
57
+ ar.1, arg-primera-division-2024
58
+ ar.2.nacional, arg-primera-b-nacional-2024
59
+ ar.2.metro, arg-primera-b-metropolitana-2024-clausura
60
+ ar.cup, arg-copa-argentina-2024
61
+
62
+ py.1, par-primera-division-2024-clausura
63
+
64
+ pe.1, per-primera-division-2024-clausura_2
65
+
66
+ uy.1, uru-primera-division-2024-clausura
67
+ uy.2, uru-segunda-division-2024-fase-regular
68
+ uy.cup, uru-copa-2024
69
+
70
+ ve.1, ven-primera-division-2024-clausura
@@ -1,6 +1,10 @@
1
1
  key, slug
2
2
 
3
- cn.1, chn-super-league-2024
4
- jp.1, jpn-j1-league-2024
5
- kr.1, kor-k-league-1-2024
3
+ jp.1, jpn-j1-league-2024
4
+ jp.2, jpn-j2-league-2024
5
+ jp.cup, jpn-emperors-cup-2024
6
+
7
+ cn.1, chn-super-league-2024
8
+
9
+ kr.1, kor-k-league-1-2024
6
10
 
@@ -4,6 +4,10 @@ de.1, bundesliga-2024-2025
4
4
  de.2, 2-bundesliga-2024-2025
5
5
  de.3, 3-liga-2024-2025
6
6
  de.4.bayern, regionalliga-bayern-2024-2025
7
+ de.4.n, regionalliga-nord-2024-2025
8
+ de.4.no, regionalliga-nordost-2024-2025
9
+ de.4.w, regionalliga-west-2024-2025
10
+ de.4.sw, regionalliga-suedwest-2024-2025
7
11
  de.cup, dfb-pokal-2024-2025
8
12
 
9
13
  at.1, aut-bundesliga-2024-2025
@@ -20,6 +24,9 @@ ch.cup, sui-cup-2024-2025
20
24
  hu.1, hun-nb-i-2024-2025
21
25
 
22
26
  cz.1, cze-1-fotbalova-liga-2024-2025
27
+ cz.2, cze-2-fotbalova-liga-2024-2025
28
+ cz.3, cze-3-fotbalova-liga-2024-2025-cfl-a
29
+
23
30
  sk.1, svk-super-liga-2024-2025
24
31
 
25
32
  pl.1, pol-ekstraklasa-2024-2025
@@ -35,6 +42,7 @@ eng.cup, eng-fa-cup-2023-2024 ### update to 2024-2025 later!!!
35
42
  eng.cup.l, eng-league-cup-2024-2025
36
43
 
37
44
 
45
+
38
46
  sco.1, sco-premiership-2024-2025
39
47
 
40
48
  ie.1, irl-premier-division-2024
@@ -46,6 +54,7 @@ fr.cup, fra-coupe-de-france-2023-2024 ### update to 2024-2025 later!!!
46
54
 
47
55
 
48
56
  lu.1, lux-nationaldivision-2024-2025
57
+
49
58
  nl.1, ned-eredivisie-2024-2025
50
59
  nl.2, ned-eerste-divisie-2024-2025
51
60
  nl.cup, ned-knvb-beker-2024-2025
@@ -67,9 +76,47 @@ es.2, esp-segunda-division-2024-2025
67
76
  es.cup, esp-copa-del-rey-2023-2024 ## update to 2024-2025 later!!!
68
77
 
69
78
 
79
+ ro.1, rou-liga-1-2024-2025
80
+ ro.cup, rou-cupa-romaniei-2024-2025
81
+
82
+ ru.1, rus-premier-liga-2024-2025
83
+ ru.2, rus-premier-liga-2024-2025
84
+
85
+ ua.1, ukr-premyer-liga-2024-2025
86
+
87
+
88
+
70
89
  tr.1, tur-sueperlig-2024-2025
71
90
  tr.2, tur-1-lig-2024-2025
72
91
 
73
92
  gr.1, gre-super-league-2024-2025
74
93
 
75
94
  hr.1, cro-1-hnl-2024-2025
95
+ ba.1, bih-premier-liga-2024-2025
96
+
97
+ al.1, alb-kategoria-superiore-2024-2025
98
+
99
+
100
+ is.1, isl-urvalsdeild-2024
101
+
102
+ se.1, swe-allsvenskan-2024
103
+ se.2, swe-superettan-2024
104
+
105
+ no.1, nor-eliteserien-2024
106
+ fi.1, fin-veikkausliiga-2024-championship
107
+ dk.1, den-superliga-2024-2025
108
+
109
+
110
+
111
+
112
+ uefa.cl, champions-league-2024-2025
113
+ uefa.cl.q, champions-league-qual-2024-2025
114
+ uefa.el, europa-league-2024-2025
115
+ uefa.el.q, europa-league-qual-2024-2025
116
+ uefa.conf, conference-league-2024-2025
117
+ uefa.conf.q, europa-conference-league-qual-2024-2025
118
+
119
+ uefa.nl.a, nations-league-a-2024-2025
120
+ uefa.nl.b, nations-league-b-2024-2025
121
+ uefa.nl.c, nations-league-c-2024-2025
122
+ uefa.nl.d, nations-league-d-2024-2025
@@ -0,0 +1,5 @@
1
+ key, slug
2
+
3
+ il.1, isr-ligat-haal-2024-2025
4
+ il.2, isr-liga-leumit-2024-2025
5
+
@@ -0,0 +1,8 @@
1
+ key, slug
2
+
3
+
4
+ au.1, aus-a-league-2024-2025
5
+ au.cup, aus-australia-cup-2024
6
+
7
+ nz.1, nzl-national-league-2023
8
+
data/config/rounds.csv ADDED
@@ -0,0 +1,16 @@
1
+ key, name1, name2
2
+
3
+ *, 1. Runde, Round 1
4
+ *, 2. Runde, Round 2
5
+ *, 3. Runde, Round 3
6
+ *, 4. Runde, Round 4
7
+ *, 5. Runde, Round 5
8
+ *, 6. Runde, Round 6
9
+ *, 7. Runde, Round 7
10
+ *, 8. Runde, Round 8
11
+ *, 9. Runde, Round 9
12
+ *, Achtelfinale, Round of 16
13
+ *, Viertelfinale, Quarterfinals
14
+ *, Halbfinale, Semifinals
15
+ *, Finale, Final
16
+
data/config/stages.csv ADDED
@@ -0,0 +1,64 @@
1
+ key, name1, name2,
2
+
3
+ *, Meisterschaft, Playoffs - Championship
4
+ *, Abstieg, Playoffs - Relegation
5
+ *, Relegation, Playoffs - Relegation
6
+
7
+
8
+ sco.1, Championship, Playoffs - Championship
9
+ sco.1, Relegation', Playoffs - Relegation
10
+
11
+
12
+ at.1, Meistergruppe, Playoffs - Championship
13
+ at.1, Qualifikationsgruppe, Playoffs - Relegation
14
+ at.1, Playoff, Europa League Finals
15
+
16
+
17
+ pl.1, Playoffs, Playoffs - Championship
18
+ pl.2, Abstieg, Playoffs - Relegation
19
+
20
+
21
+ sk.1, Meisterschaft, Playoffs - Championship
22
+ sk.1, Abstieg, Playoffs - Relegation
23
+ sk.1, Europa League, Europa League Finals
24
+
25
+
26
+ ro.1, Championship, Playoffs - Championship
27
+ ro.1, Relegation, Playoffs - Relegation
28
+
29
+ ru.1, Meisterschaft, Playoffs - Championship
30
+ ru.1, Relegation, Playoffs - Relegation
31
+
32
+
33
+ ua.1, Meisterschaft, Playoffs - Championship
34
+ ua.1, Abstieg, Playoffs - Relegation
35
+ ua.1, Playoffs EL, Europa League Finals
36
+
37
+
38
+ fi.1, Meisterschaft, Playoffs - Championship
39
+ fi.1, Abstieg, Playoffs - Challenger
40
+ fi.1, Playoff EL, Europa League Finals
41
+
42
+ dk.1, Meisterschaft, Playoffs - Championship
43
+ dk.1, Abstieg, Playoffs - Relegation
44
+ dk.1, Europa League, Europa League Finals
45
+
46
+
47
+ gr.1, Meisterschaft, Playoffs - Championship
48
+ gr.1, Abstieg, Playoffs - Relegation
49
+ gr.1, Playoffs, Playoffs
50
+ gr.1, Spiel um Platz 6, Match 6th Place
51
+
52
+
53
+
54
+ mx.1, Apertura Playoffs, Apertura - Liguilla
55
+ mx.1, Clausura Playoffs, Clausura - Liguilla
56
+
57
+
58
+ kr.1, Meisterschaft, Playoffs - Championship
59
+ kr.1, Abstieg, Playoffs - Relegation
60
+
61
+
62
+ nz.1, Playoffs, Playoff Finals
63
+
64
+
@@ -2,23 +2,6 @@
2
2
  module Worldfootball
3
3
 
4
4
 
5
- ROUND_TO_EN = {
6
- '1. Runde' => 'Round 1',
7
- '2. Runde' => 'Round 2',
8
- '3. Runde' => 'Round 3',
9
- '4. Runde' => 'Round 4',
10
- '5. Runde' => 'Round 5',
11
- '6. Runde' => 'Round 6',
12
- '7. Runde' => 'Round 7',
13
- '8. Runde' => 'Round 8',
14
- '9. Runde' => 'Round 9',
15
- 'Achtelfinale' => 'Round of 16',
16
- 'Viertelfinale' => 'Quarterfinals',
17
- 'Halbfinale' => 'Semifinals',
18
- 'Finale' => 'Final',
19
- }
20
-
21
-
22
5
  ## todo/check: english league cup/trophy has NO ET - also support - make more flexible!!!
23
6
 
24
7
  ## build "standard" match records from "raw" table rows
@@ -69,36 +52,22 @@ def self.build( rows, season:, league:, stage: '' ) ## rename to fixup or such
69
52
 
70
53
  ## note - must start line e.g.
71
54
  ## do NOT match => Qual. 1. Runde (1. Runde)!!!
72
- elsif row[:round] =~ /^(
73
- [1-9]\.[ ]Runde|
74
- Achtelfinale|
75
- Viertelfinale|
76
- Halbfinale|
77
- Finale
78
- )$
79
- /x
55
+ else
80
56
  puts
81
57
  print '[%03d] ' % (i+1)
82
58
  print row[:round]
83
59
 
84
- round = ROUND_TO_EN[ row[:round] ]
85
- print " => #{round}"
86
- print "\n"
60
+ round_new = map_round( row[:round], league: league, season: season )
87
61
 
88
- if round.nil?
89
- puts "!! ERROR: no mapping for round to english (en) found >#{row[:round]}<:"
62
+ if round_new
63
+ round = round_new
64
+ print " => #{round}"
65
+ print "\n"
66
+ else
67
+ round = row[:round]
68
+ puts "!! WARN: unknown round >#{row[:round]}< for league >#{league} #{season}<:"
90
69
  pp row
91
- exit 1
92
70
  end
93
- else
94
- puts
95
- print '[%03d] ' % (i+1)
96
- print row[:round]
97
- print "\n"
98
-
99
- puts "!! WARN: unknown round >#{row[:round]}< for league >#{league}<:"
100
- pp row
101
- round = row[:round]
102
71
  end
103
72
 
104
73
 
@@ -168,7 +137,18 @@ def self.build( rows, season:, league:, stage: '' ) ## rename to fixup or such
168
137
  ## overwrite old with local
169
138
  date_str = local.strftime( '%Y-%m-%d' )
170
139
  time_str = local.strftime( '%H:%M' )
171
- timezone = local.strftime( '%Z/%z' )
140
+
141
+ ## pretty print timezone
142
+ ### todo/fix - bundle into fmt_timezone method or such for reuse
143
+ tz_abbr = local.strftime( '%Z' ) ## e.g. EEST or if not available +03 or such
144
+ tz_offset = local.strftime( '%z' ) ## e.g. +0300
145
+
146
+ timezone = if tz_abbr =~ /^[+-][0-9]+$/ ## only digits (no abbrev.)
147
+ tz_offset
148
+ else
149
+ "#{tz_abbr}/#{tz_offset}"
150
+ end
151
+
172
152
  utc = utc.strftime( '%Y-%m-%dT%H:%MZ' )
173
153
  end
174
154
 
@@ -15,6 +15,14 @@ def self.convert( league:, season: )
15
15
  ## todo/fix: report error/check if stage is nil!!!
16
16
  stage ||= ''
17
17
 
18
+ ## try to map stage name if new name defined/found
19
+ unless stage.empty?
20
+ stage_new = map_stage( stage, league: league.key,
21
+ season: season )
22
+ stage = stage_new if stage_new
23
+ end
24
+
25
+
18
26
  print " parsing #{slug}..."
19
27
 
20
28
  # unless File.exist?( path )
@@ -51,12 +51,16 @@ class LeagueItem # nested inside LeagueConfig
51
51
  ## ["2019-2021 Playoffs", "regionalliga-bayern-2019-2021-playoffs"],
52
52
  ## ["2019-2021", "regionalliga-bayern-2019-2021"],
53
53
  ##
54
-
54
+ ##
55
+ ## ["1955/1958", "europa-league-1955-1958"]]
56
+ ## ["1958/1960", "uefa-cup-1958-1960"],
55
57
 
56
58
  season, stage = text.split( ' ', 2 )
57
59
 
58
60
  ## todo/fix: add a waring here and auto log to logs.txt!!!!
59
61
  next if season == '2019-2021'
62
+ next if season == '1958/1960'
63
+ next if season == '1955/1958'
60
64
 
61
65
  season = Season.parse( season )
62
66
 
@@ -116,8 +120,11 @@ end # class LeagueConfig
116
120
 
117
121
 
118
122
  LEAGUES = LeagueConfig.new
119
- ['leagues_europe',
120
- 'leagues_asia',].each do |name|
123
+ ['leagues_america',
124
+ 'leagues_asia',
125
+ 'leagues_europe',
126
+ 'leagues_middle_east',
127
+ 'leagues_pacific'].each do |name|
121
128
  recs = read_csv( "#{Worldfootball.root}/config/#{name}.csv" )
122
129
  pp recs
123
130
  puts " #{recs.size} league(s) in #{name}"
@@ -11,6 +11,19 @@ def self.norm_team( team )
11
11
  ## clean team name and asciify (e.g. ’->' )
12
12
  team = team.sub( '(old)', '' ).strip
13
13
  team = team.gsub( '’', "'" ) ## e.g. Hawke’s Bay United FC
14
+
15
+ ## Criciúma - SC => Criciúma - SC
16
+ ## Bahia - BA => Bahia - BA
17
+ ## remove inline dash ( - ) with single space
18
+ team = team.gsub( /[ ]+[-][ ]+/, ' ' )
19
+
20
+
21
+ ## todo:
22
+ ## replace (A) with II
23
+ ## Austria Wien (A) => Austria Wien (A)
24
+ ## others too? - move to mods instead of generic rule - why? why not?
25
+ team = team.sub( /[ ]+\(A\)/, ' II' )
26
+
14
27
  team
15
28
  end
16
29
 
@@ -71,8 +84,8 @@ SCORE_ERRORS = {
71
84
  },
72
85
  'at.cup' => {
73
86
  ## 2023/24
74
- '2023-07-22' => [ 'SV Leobendorf', 'SV Horn', ['3-2 (2-0, 2-2, 3-2) n.V.', '3-2 (2-0, 2-2) n.V.']],
75
- },
87
+ '2023-07-22' => [ 'SV Leobendorf', 'SV Horn', ['3-2 (2-0, 2-2, 3-2) n.V.', '3-2 (2-0, 2-2) n.V.']],
88
+ },
76
89
  }
77
90
 
78
91
 
@@ -0,0 +1,47 @@
1
+
2
+
3
+ module Worldfootball
4
+
5
+ def self.map_stage( stage, league:, season: )
6
+ @stages ||= begin
7
+ stages = {}
8
+ recs = read_csv( "#{Worldfootball.root}/config/stages.csv" )
9
+ recs.each do |rec|
10
+ stages[ rec['key'] ] ||= Hash.new
11
+ stages[ rec['key'] ][ rec['name1'] ] = rec['name2']
12
+ end
13
+ stages
14
+ end
15
+
16
+ ## pp @stages
17
+
18
+ league_code = league.to_s.downcase
19
+
20
+ name = nil
21
+ name = @stages[league_code][ stage ] if @stages.has_key?( league_code )
22
+ name = @stages['*'][stage] if name.nil? ## try generic (*) lookup
23
+ name
24
+ end
25
+
26
+
27
+ def self.map_round( round, league:, season: )
28
+ @rounds ||= begin
29
+ rounds = {}
30
+ recs = read_csv( "#{Worldfootball.root}/config/rounds.csv" )
31
+ recs.each do |rec|
32
+ rounds[ rec['key'] ] ||= Hash.new
33
+ rounds[ rec['key'] ][ rec['name1'] ] = rec['name2']
34
+ end
35
+ rounds
36
+ end
37
+
38
+ ## pp @stages
39
+
40
+ league_code = league.to_s.downcase
41
+
42
+ name = nil
43
+ name = @rounds[league_code][ round ] if @rounds.has_key?( league_code )
44
+ name = @rounds['*'][round] if name.nil? ## try generic (*) lookup
45
+ name
46
+ end
47
+ end # module Worldfootball
@@ -2,7 +2,7 @@
2
2
  module Worldfootball
3
3
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
4
4
  MINOR = 2
5
- PATCH = 0
5
+ PATCH = 2
6
6
  VERSION = [MAJOR,MINOR,PATCH].join('.')
7
7
 
8
8
  def self.version
data/lib/worldfootball.rb CHANGED
@@ -8,8 +8,10 @@ require 'nokogiri'
8
8
  # our own code
9
9
  require_relative 'worldfootball/version'
10
10
  require_relative 'worldfootball/leagues'
11
+ require_relative 'worldfootball/stages'
12
+
13
+
11
14
 
12
- require_relative 'worldfootball/config' ## rename to setup/timezones/layouts or such?
13
15
  require_relative 'worldfootball/download'
14
16
  require_relative 'worldfootball/page'
15
17
  require_relative 'worldfootball/page_schedule'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worldfootball
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-11 00:00:00.000000000 Z
11
+ date: 2024-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: football-timezones
@@ -102,13 +102,17 @@ files:
102
102
  - README.md
103
103
  - Rakefile
104
104
  - bin/wfb
105
+ - config/leagues_america.csv
105
106
  - config/leagues_asia.csv
106
107
  - config/leagues_europe.csv
108
+ - config/leagues_middle_east.csv
109
+ - config/leagues_pacific.csv
110
+ - config/rounds.csv
111
+ - config/stages.csv
107
112
  - lib/worldfootball.rb
108
113
  - lib/worldfootball/build-parse_score.rb
109
114
  - lib/worldfootball/build.rb
110
115
  - lib/worldfootball/cache.rb
111
- - lib/worldfootball/config.rb
112
116
  - lib/worldfootball/convert.rb
113
117
  - lib/worldfootball/convert_reports.rb
114
118
  - lib/worldfootball/download.rb
@@ -117,6 +121,7 @@ files:
117
121
  - lib/worldfootball/page.rb
118
122
  - lib/worldfootball/page_report.rb
119
123
  - lib/worldfootball/page_schedule.rb
124
+ - lib/worldfootball/stages.rb
120
125
  - lib/worldfootball/vacuum.rb
121
126
  - lib/worldfootball/version.rb
122
127
  homepage: https://github.com/sportdb/sport.db
@@ -1,85 +0,0 @@
1
- module Worldfootball
2
-
3
-
4
- ####
5
- # config for slug to local basename / directories
6
- # e.g.
7
- # aut-bundesliga-2023-2024 => austria/2023-24/1_bundesliga.txt
8
-
9
- ## add (timezone) offset here too - why? why not?
10
- LEAGUE_SETUPS = {
11
- ## note - for now auto-generate path via name (downcased)
12
- ## e.g. Belgium => /belgium
13
-
14
- ## top five (europe)
15
- 'eng' => { code: 'eng', name: 'England' },
16
- 'es' => { code: 'esp', name: 'Spain' },
17
- # 'fr' => { code: 'fra', name: 'France' },
18
- # 'de' => { code: '???', name: 'Germany' },
19
- 'it' => { code: 'ita', name: 'Italy' },
20
-
21
-
22
- 'be' => { code: 'bel', name: 'Belgium' },
23
- 'at' => { code: 'aut', name: 'Austria' },
24
- 'hu' => { code: 'hun', name: 'Hungary' },
25
-
26
- 'tr' => { code: 'tur', name: 'Turkey' },
27
- 'nl' => { code: 'ned', name: 'Netherlands' },
28
- 'ch' => { code: 'sui', name: 'Switzerland' },
29
-
30
-
31
- 'cz' => { code: 'cze', name: 'Czech Republic' },
32
- 'dk' => { code: 'den', name: 'Denmark' },
33
- 'fi' => { code: 'fin', name: 'Finland' },
34
- 'gr' => { code: 'gre', name: 'Greece' },
35
-
36
- 'ie' => { code: 'irl', name: 'Ireland' },
37
- 'sco' => { code: 'sco', name: 'Scotland' },
38
-
39
- 'lu' => { code: 'lux', name: 'Luxembourg' },
40
- 'pl' => { code: 'pol', name: 'Poland' },
41
- 'pt' => { code: 'por', name: 'Portugal' },
42
- 'ro' => { code: 'rou', name: 'Romania' },
43
- 'ru' => { code: 'rus', name: 'Russia' },
44
- 'se' => { code: 'swe', name: 'Sweden' },
45
- 'ua' => { code: 'ukr', name: 'Ukraine' },
46
-
47
-
48
- 'eg' => { code: 'egy', name: 'Egypt' },
49
- 'jp' => { code: 'jpn', name: 'Japan' },
50
- 'cn' => { code: 'chn', name: 'China' },
51
-
52
- ## note - for now do NOT add United States to league name
53
- ## e.g. 1 - Major League Soccer
54
- ## 2 - USL Championship
55
- ## cup - U.S. Open Cup
56
- 'us' => { code: 'usa', name: nil, path: 'united-states' },
57
-
58
- 'mx' => { code: 'mex', name: 'Mexico' },
59
- 'ar' => { code: 'arg', name: 'Argentina' },
60
- 'br' => { code: 'bra', name: 'Brazil' },
61
-
62
- 'uy' => { code: 'uru', name: 'Uruguay' },
63
- 'pe' => { code: 'per', name: 'Peru' },
64
- 'ec' => { code: 'ecu', name: 'Ecuador' },
65
- 'bo' => { code: 'bol', name: 'Bolivia' },
66
- 'cl' => { code: 'chi', name: 'Chile' },
67
- 'co' => { code: 'col', name: 'Colombia' },
68
-
69
- 'cr' => { code: 'crc', name: 'Costa Rica' },
70
- 'gt' => { code: 'gua', name: 'Guatemala' },
71
- 'hn' => { code: 'hon', name: 'Honduras' },
72
- 'sv' => { code: 'slv', name: 'El Salvador' },
73
- 'ni' => { code: 'nca', name: 'Nicaragua' },
74
-
75
-
76
- ## int'l tournaments
77
- 'uefa.cl' => { code: nil, name: 'UEFA', path: 'europe' },
78
- 'uefa.el' => { code: nil, name: 'UEFA', path: 'europe' },
79
- 'concacaf.cl' => { code: nil, name: nil, path: 'north-america' },
80
- 'copa.l' => { code: nil, name: nil, path: 'south-america' },
81
- }
82
-
83
-
84
-
85
- end # module Worldfootball