leagues 0.1.1 → 0.2.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: 51f3a37d90c06b3b6fb5237d9a83b8f01d045be5f07f8854ece891e58c1d58ae
4
- data.tar.gz: bb4ce11c4cba0efb9718516428eac848089a275ab12bfab1e951c77d5b89d93f
3
+ metadata.gz: 1b61c5794e4e1aa3657c553c73bdb0d912b909097ce06aabe098fb013b142113
4
+ data.tar.gz: cac21b539d073c7061f7138c2a0935771ee81d7dd4321362c524e2a9953c14e8
5
5
  SHA512:
6
- metadata.gz: 1b36074ee4903210002c28b7e440464ac95c5415dc76dbd71081d6966a665d81a67bd8915cc2d4d1d9f15a4af7a7f063aa0419076950d7b7b5341747cc32cfdd
7
- data.tar.gz: 96b993022a5b071393cb569c49ec99b0c57d0e30e7cf7a54858f3570c79ccd38f807bb8522a222aec94b7301a2ec13a6c137a3caa02358fe575a71cc2d56e13b
6
+ metadata.gz: 1af29b03971fa6708f9ca33ae6072a0b11899a544d7fc0d72e6198f80ec1fbcca87a9fcc28483bf3c52895064680e70af126ccba2127cc0bdd6b12dad76cf30c
7
+ data.tar.gz: 5843bc59ba35cafce9c095008d6501e43630284c26b742aaa429260ef71224c921c0bfeb39344bb1999a5e47a46997ce5950b2ddc00a495ba2c5d2c14ce2c7c8
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.1.1
1
+ ### 0.2.1
2
2
 
3
3
  ### 0.0.1 / 2025-04-01
4
4
 
data/Manifest.txt CHANGED
@@ -2,6 +2,7 @@ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
+ bin/fbok
5
6
  config/codes_alt.csv
6
7
  config/leagues.csv
7
8
  config/leagues_more.csv
data/Rakefile CHANGED
@@ -18,8 +18,8 @@ Hoe.spec 'leagues' do
18
18
  self.history_file = 'CHANGELOG.md'
19
19
 
20
20
  self.extra_deps = [
21
- ['tzinfo'],
22
- ['season-formats'],
21
+ ['tzinfo'], ## note - check if tzinfo-data or such is required too???
22
+ ['season-formats', '>= 0.1.0'],
23
23
  ['cocos'],
24
24
  ]
25
25
 
data/bin/fbok ADDED
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ## tip: to test run:
4
+ ## ruby -I ./lib bin/fbok
5
+
6
+ require 'leagues'
7
+
8
+
9
+ def read_raw_leagueset( path )
10
+ ## no - normalize and autofill etc.
11
+ datasets = []
12
+ recs = read_csv( path )
13
+ recs.each do |rec|
14
+ key = rec['league']
15
+ seasons = Season.parse_line( rec['seasons'] )
16
+
17
+ datasets << [key, seasons]
18
+ end
19
+ datasets
20
+ end
21
+
22
+ args = ARGV
23
+
24
+ args = ['/sports/tmp/classic.csv' ] if args.size == 0
25
+
26
+
27
+
28
+ def check_leagueset( path )
29
+ datasets = read_raw_leagueset( path )
30
+ pp datasets
31
+
32
+ puts "==> #{path} - #{datasets.size} record(s)"
33
+
34
+ ## pass 1 - league code quick check
35
+ errors = []
36
+ datasets.each do |league_query, _|
37
+ if LeagueCodes.valid?( league_query )
38
+ puts "OK #{league_query}"
39
+ else
40
+ puts "!! #{league_query}"
41
+ errors << "league code #{league_query} NOT valid"
42
+ end
43
+ end
44
+
45
+ if errors.size > 0
46
+ puts "#{errors.size} error(s):"
47
+ pp errors
48
+ exit 1
49
+ end
50
+
51
+ ## pass 2 - league code check by season
52
+ datasets.each_with_index do |(league_query, seasons),i|
53
+ puts "-- [#{i+1}/#{datasets.size}] #{league_query}, #{seasons.size} seasons(s)"
54
+
55
+ last_league_info = nil
56
+ seasons.each_with_index do |season,j|
57
+ league_info = LeagueCodes.find_by( code: league_query, season: season )
58
+
59
+ if league_info.nil?
60
+ puts "!! #{season}"
61
+ errors << "no league info for #{league_query} #{season} found"
62
+ next
63
+ end
64
+
65
+ ## only print league info (if changed from last season)
66
+ if last_league_info.nil? ||
67
+ last_league_info['code'] != league_info['code'] ||
68
+ last_league_info['name'] != league_info['name'] ||
69
+ last_league_info['tz'] != league_info['tz']
70
+ print "\n" if j != 0 ## if new league info MUST start new line
71
+ pp league_info
72
+ end
73
+ print " #{season}"
74
+
75
+ last_league_info = league_info
76
+ end
77
+ print "\n"
78
+ end
79
+
80
+ if errors.size > 0
81
+ puts "#{errors.size} error(s):"
82
+ pp errors
83
+ else
84
+ puts
85
+ puts "OK no error(s) found"
86
+ end
87
+ end
88
+
89
+
90
+
91
+ path = args[0]
92
+ check_leagueset( path )
93
+
94
+ puts 'bye'
data/config/codes_alt.csv CHANGED
@@ -62,5 +62,5 @@ se.2, swe.2,,,
62
62
  il.1, isr.1,,,
63
63
  ro.1, rou.1,,,
64
64
 
65
- br.1, bra.1,,,
65
+ br.1, bra.1,,,
66
66
 
@@ -38,3 +38,9 @@ eng.efl.cup,English EFL Cup,eflcup,,
38
38
  ### fix - upstream uses world.club !!!
39
39
  world.clubs,Club World Cup,clubworldcup,2000,
40
40
 
41
+
42
+ ### quick hack
43
+ ### alternate codes (duplicates); use/settle on one canonical league code!!!
44
+ br.cup,Copa do Brasil,cup,, ## br.copa
45
+
46
+
@@ -1,5 +1,4 @@
1
1
  key, zone
2
2
 
3
3
  il, Asia/Jerusalem
4
-
5
-
4
+ sa, Asia/Riyadh
@@ -139,6 +139,9 @@ def find_by( code:, season: )
139
139
 
140
140
  if rec ## (quick hack for now) auto-add timezone
141
141
  ## use canoncial (league) code
142
+ ## note - if timezone changes MUST auto-create a NEW record
143
+ ## thus, for now always create a new copy (via dup)!!!
144
+ rec = rec.dup
142
145
  rec['tz'] = find_zone!( league: rec['code'], season: season )
143
146
  end
144
147
 
@@ -70,35 +70,19 @@ def self.parse_args( args, autofill: nil )
70
70
  end
71
71
 
72
72
 
73
+
73
74
  def self.parse( txt, autofill: nil )
74
75
  ### split args in datasets with leagues and seasons
75
76
  datasets = []
76
77
  recs = parse_csv( txt )
77
78
  recs.each do |rec|
78
79
  key = rec['league'].downcase
79
- datasets << [key, []]
80
-
80
+
81
81
  seasons_str = rec['seasons']
82
- seasons = seasons_str.split( /[ ]+/ )
83
-
84
- seasons.each do |season_str|
85
- ## note - add support for ranges e.g. 2001/02..2010/11
86
- if season_str.index( '..' )
87
- fst,snd = season_str.split( '..' )
88
- # pp [fst,snd]
89
- fst = Season.parse( fst )
90
- snd = Season.parse( snd )
91
- if fst < snd && fst.year? == snd.year?
92
- datasets[-1][1] += (fst..snd).to_a
93
- else
94
- raise ArgumentError, "parse error - invalid season range >#{str}<, 1) two seasons required, 2) first < second, 3) same (year/academic) type"
95
- end
96
- else
97
- season = Season.parse( season_str ) ## check season
98
- datasets[-1][1] << season
99
- end
100
- end
101
- end
82
+ seasons = Season.parse_line( seasons_str )
83
+
84
+ datasets << [key, seasons]
85
+ end
102
86
 
103
87
  new(datasets, autofill: autofill)
104
88
  end
@@ -3,7 +3,7 @@ module SportDb
3
3
  module Module
4
4
  module Leagues
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
- MINOR = 1
6
+ MINOR = 2
7
7
  PATCH = 1
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
data/lib/leagues.rb CHANGED
@@ -41,7 +41,9 @@ end
41
41
 
42
42
 
43
43
 
44
-
44
+ ##
45
+ ## todo/check
46
+ ## note - move FileHelper upstream to cocos (code commons) - why? why not?
45
47
  module FileHelper
46
48
  def find_file( filename, path: )
47
49
  path.each do |src_dir|
@@ -56,6 +58,7 @@ end
56
58
 
57
59
 
58
60
 
61
+
59
62
  ####
60
63
  ### note - make find_zone! public/global by default - why? why not?
61
64
  module Kernel
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leagues
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.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: 2025-04-02 00:00:00.000000000 Z
11
+ date: 2025-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: cocos
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -88,7 +88,8 @@ dependencies:
88
88
  version: '4.2'
89
89
  description: leagues - football leagues & timezone helpers
90
90
  email: gerald.bauer@gmail.com
91
- executables: []
91
+ executables:
92
+ - fbok
92
93
  extensions: []
93
94
  extra_rdoc_files:
94
95
  - CHANGELOG.md
@@ -99,6 +100,7 @@ files:
99
100
  - Manifest.txt
100
101
  - README.md
101
102
  - Rakefile
103
+ - bin/fbok
102
104
  - config/codes_alt.csv
103
105
  - config/leagues.csv
104
106
  - config/leagues_more.csv