footballdata-api 0.5.0 → 0.5.1

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
  SHA256:
3
- metadata.gz: 15d56d22fbf3bfd0f2587ff63f2f3b33b5915ad8122569843f31b99ab21d5f1c
4
- data.tar.gz: e52ee8e33aab078d5c131da9ecd043930a63d638c9e67480f91ea336e2159eb6
3
+ metadata.gz: 1f57e1559b42ee3e85f0ebeca5f1886110fe4964e48b0c58c2f7bd6713c167b7
4
+ data.tar.gz: 1e2e40dd8ab8b2cb4c33f10331e9019116ef5453bec5d6f58a64567947f9121b
5
5
  SHA512:
6
- metadata.gz: ff181881d6b90957a8ee865853458b81ae1f6ff3fbb7ae1a3b15d3397a9e94262a21ea9d74d54069fd1a2ca73727fc5dcc4ea407cbfd7ff8cc39c899d20751ec
7
- data.tar.gz: 49ceaa1d080dcd95f7eba336487de96ad7c90a249192e864b822a2a2fd933f6b426c43912b7dcfb365a98be7b40417c395340d0d4fe4ea3250164cdc55170d3c
6
+ metadata.gz: 84d991d2f3a18b440da187df5ac140db10a763f51a07b42a6d7f0c120976ce7db64b155f33c02d0901eb81b788ff6dfb163c1076840261ca1a46aa30b41b93b1
7
+ data.tar.gz: aafab943f237494592d78238acdb44f84cd66f48170463a5a624f195eed0f8954770963334e287de5262390578abc6110abe3c89b75f4024418f580ff70de88b
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.5.0
1
+ ### 0.5.1
2
2
  ### 0.0.1 / 2024-07-03
3
3
 
4
4
  * Everything is new. First release.
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ Hoe.spec 'footballdata-api' do
18
18
  self.history_file = 'CHANGELOG.md'
19
19
 
20
20
  self.extra_deps = [
21
- ['football-timezones'],
21
+ ['leagues'],
22
22
  ['fifa'],
23
23
  ['webget'],
24
24
  ]
data/bin/fbdat CHANGED
@@ -190,34 +190,20 @@ end
190
190
  ## note - only use "generic" uniform league codes for now!!
191
191
 
192
192
 
193
+ autofiller = ->(league_query) {
194
+ seasons = find_league_seasons!( league_query ) || []
195
+ seasons[ 0 ] ## assume first is latest season
196
+ }
197
+
198
+
199
+
193
200
  datasets = if opts[:file]
194
- read_leagueset( opts[:file] )
201
+ read_leagueset( opts[:file], autofill: autofiller )
195
202
  else
196
- parse_leagueset_args( args )
203
+ parse_leagueset_args( args, autofill: autofiller )
197
204
  end
198
205
 
199
206
 
200
- ## step 0 - validate and fill-up seasons etc.
201
- datasets.each do |league_key, seasons|
202
- ## todo - find a better name
203
- ## use internal_league_code or such - why? why not?
204
- ### convenience helpers - lets you use eng.1, euro, etc.
205
- ## check if mapping for league_code
206
- metal_league_code = find_league!( league_key )
207
-
208
- ## note - default to latest season of league
209
- ## might be 2024/25 or 2024 or
210
- # for world cup 2022 or such
211
- if seasons.empty?
212
- season = case league_key
213
- when 'world' then Season('2022')
214
- when 'euro' then Season('2024')
215
- when 'br.1', 'copa.l' then Season('2024')
216
- else Season('2024/25')
217
- end
218
- seasons << season
219
- end
220
- end
221
207
 
222
208
  ## step 1 - download
223
209
  datasets.each do |league_key, seasons|
@@ -24,7 +24,7 @@ fr.1, FL1, 2024/25 2023/24 2022/23 2021/22 2020/21
24
24
  it.1, SA, 2024/25 2023/24 2022/23 2021/22 2020/21
25
25
  # SA - Serie A, Italy 15 seasons | 2019-08-24 - 2020-08-02 / matchday 27
26
26
 
27
- br.1, BSA, 2024 2023 2022 2021 2020
27
+ br.1, BSA, 2025 2024 2023 2022 2021 2020
28
28
 
29
29
 
30
30
  ########
@@ -34,7 +34,7 @@ uefa.cl, CL, 2024/25 2023/24 2022/23 2021/22 2020/21
34
34
  ## was europe.cl / cl
35
35
  ## todo/check: use champs and NOT cl - why? why not?
36
36
 
37
- copa.l, CLI, 2024 2023 2022 2021
37
+ copa.l, CLI, 2025 2024 2023 2022 2021
38
38
  ## Copa Libertadores
39
39
 
40
40
 
@@ -67,6 +67,7 @@ def self.convert( league:, season: )
67
67
 
68
68
  season = Season( season ) ## cast (ensure) season class (NOT string, integer, etc.)
69
69
 
70
+ ### note - find_league returns the metal_league_code
70
71
  league_code = find_league!( league )
71
72
 
72
73
  matches_url = Metal.competition_matches_url( league_code, season.start_year )
@@ -76,7 +77,14 @@ def self.convert( league:, season: )
76
77
  data_teams = Webcache.read_json( teams_url )
77
78
 
78
79
 
79
- ## note - for internation club tournaments
80
+ ###
81
+ ## todo/fix - use find_by! - add upstream!!!
82
+ league_info = LeagueCodes.find_by( code: league, season: season )
83
+ ## check for time zone
84
+ tz = league_info['tz']
85
+ pp tz
86
+
87
+ ## note - for international club tournaments
80
88
  ## auto-add (fifa) country code e.g.
81
89
  ## Liverpool FC => Liverpool FC (ENG)
82
90
  ##
@@ -85,10 +93,6 @@ def self.convert( league:, season: )
85
93
  'copa.l'].include?(league.downcase) ? true : false
86
94
 
87
95
 
88
- ## check for time zone
89
- tz = find_zone!( league: league,
90
- season: season )
91
- pp tz
92
96
 
93
97
  ## build a (reverse) team lookup by name
94
98
  puts "#{data_teams['teams'].size} teams"
@@ -20,5 +20,32 @@ module Footballdata
20
20
  end
21
21
  code
22
22
  end
23
+
24
+ ###
25
+ # quick (and dirty) hack - return seasons by league code
26
+ # - todo/fix - use one find_league_info method for all or such
27
+ def self.find_league_seasons!( league )
28
+ @league_seasons ||= begin
29
+ recs = read_csv( "#{FootballdataApi.root}/config/leagues_tier1.csv" )
30
+ leagues = {}
31
+ recs.each do |rec|
32
+ leagues[ rec['key'] ] = rec['seasons']
33
+ end
34
+ leagues
35
+ end
36
+
37
+ key = league.downcase
38
+ seasons = @league_seasons[ key ]
39
+ if seasons.nil?
40
+ puts "!! ERROR - no code/mapping found for league >#{league}<"
41
+ puts " mappings include:"
42
+ pp @league_seasons
43
+ exit 1
44
+ end
45
+
46
+ ### split string into array
47
+ seasons = seasons.split( /[ ]+/ )
48
+ seasons
49
+ end
23
50
  end # module Footballdata
24
51
 
@@ -2,7 +2,7 @@
2
2
  module FootballdataApi
3
3
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
4
4
  MINOR = 5
5
- PATCH = 0
5
+ PATCH = 1
6
6
  VERSION = [MAJOR,MINOR,PATCH].join('.')
7
7
 
8
8
  def self.version
data/lib/footballdata.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  ## 3rd party (our own)
2
- require 'football/timezones' # note - pulls in season/formats, cocos & tzinfo
2
+ require 'leagues' # note - pulls in season/formats, cocos & tzinfo
3
3
  require 'webget' ## incl. webget, webcache, webclient, etc.
4
4
  require 'fifa'
5
5
 
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: footballdata-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
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-12-30 00:00:00.000000000 Z
11
+ date: 2025-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: football-timezones
14
+ name: leagues
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="