sportdb-readers 2.1.1 → 2.3.0

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: 8b8a59dbab5255cf06addb3d061e308969d39f8a9a90106ee59006630bee4463
4
- data.tar.gz: 0e212bead4a0e408c639ad7e2a14a76c820a6822065c4c50bfa97f656513a3c1
3
+ metadata.gz: b9cd6dabbfbee07274abaffd4ff011043feeb59c3dd0b2f22f8e1ff0c0af5b50
4
+ data.tar.gz: f17cb3e392b861e8a7d41a5066e682976964fb97b6d17d4a18cd6ac4f8197642
5
5
  SHA512:
6
- metadata.gz: 8f23bbac50bd681fef79202831ad0094c88491abfc27c9f9ad3b7be00b090cbeb0f1045b1b9bfef4281a1e79e554e3e116e1a7d0984dbe7c9112110309fe381e
7
- data.tar.gz: f38162e554d9760bbaeb024724a842a907d57fb48ceaba727c539e7c1e08f843cd1c82e005d858912fa1e93d602352d4cdd934227312c96acacdf86a335fc08a
6
+ metadata.gz: 20a4da1af9e2c22bcb2857b4fee74e25e595e05b884329ca3082e7a1577def93e57089d7e2a9790b0d3944730fdce2af7a46f086399d89acee693c5d7677b719
7
+ data.tar.gz: dac7327b7f1f6dac3fd9cd73f1fbf317bbaccd8674f48ef9bfd88fff4da6c824d02528f3a3ff731695a90ab5e500dc0e921113eb8c89ddb78d50d48b306dad55
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 2.1.1
1
+ ### 2.3.0
2
2
 
3
3
  ### 0.0.1 / 2019-10-29
4
4
 
@@ -9,16 +9,6 @@ module SportDb
9
9
  class MatchReader ## todo/check: rename to MatchReaderV2 (use plural?) why? why not?
10
10
 
11
11
 
12
- ### fix - remove catalog reference!!!
13
- ## use classes with "augmented" static methods
14
- ## e.g. Club.match_by etc.
15
- def catalog
16
- puts "[deprecated] do NOT use catalog reference; use classes with enhanced search static methods!"
17
- Import.catalog
18
- end
19
-
20
-
21
-
22
12
  def self.read( path, season: nil ) ## use - rename to read_file or from_file etc. - why? why not?
23
13
  txt = File.open( path, 'r:utf-8' ) {|f| f.read }
24
14
  parse( txt, season: season )
@@ -29,53 +19,74 @@ class MatchReader ## todo/check: rename to MatchReaderV2 (use plural?) why? w
29
19
  end
30
20
 
31
21
 
22
+
32
23
  include Logging
33
24
 
34
25
  def initialize( txt )
35
- @txt = txt
26
+ @errors = []
27
+ @outline = QuickLeagueOutline.parse( txt )
36
28
  end
37
29
 
30
+ attr_reader :errors
31
+ def errors?() @errors.size > 0; end
38
32
 
39
33
 
40
34
  def parse( season: nil )
41
- secs = QuickLeagueOutlineReader.parse( @txt )
42
- ## pp secs
35
+ ## note: every (new) read call - resets errors list to empty
36
+ @errors = []
43
37
 
44
- ########
45
- # step 1 - prepare secs
38
+ ### todo/fix - add back season filter - maybe upstream to outline - why? why not?
39
+ ########
40
+ # step 1 - prepare secs
46
41
  # -- filter seasons if filter present
47
- secs = filter_secs( sec, season: season ) if season
48
-
49
- ## -- check & map; replace inline (string with data struct record)
50
- secs.each do |sec|
51
- sec[:season] = Season.parse( sec[:season ] )
52
- sec[:league] = Import::League.find!( sec[:league] )
53
-
42
+ #
43
+ # secs = filter_secs( sec, season: season ) if season
44
+
45
+
46
+ @outline.each_sec do |sec| ## sec(tion)s
47
+ ### move season parse into outline upstream - why? why not?
48
+ season = Season.parse( sec.season ) ## convert (str) to season obj!!!
49
+ lines = sec.lines
50
+
51
+ ## -- check & map; replace inline (string with data struct record)
52
+
53
+ ####
54
+ ## find leage_rec
55
+
56
+ ## first try by period
57
+ period = Import::LeaguePeriod.find_by( code: sec.league,
58
+ season: season )
59
+ league = if period
60
+ ## find league by qname (assumed to be unique!!)
61
+ ## todo/fix - use League.find_by!( name: ) !!!!
62
+ ## make more specifi
63
+ Import::League.find!( period.qname )
64
+ else
65
+ Import::League.find!( sec.league )
66
+ end
54
67
  ##
55
68
  ## quick hack - assume "Regular" or "Regular Season"
56
69
  ## as default stage (thus, no stage)
57
- if sec[:stage]
58
- sec[:stage] = nil if ['Regular',
59
- 'Regular Season',
60
- 'Regular Stage',
61
- ].include?( sec[:stage] )
62
- end
63
- end
70
+ stage = sec.stage ## check if returns nil or empty string?
71
+
72
+ stage = nil if stage && ['regular',
73
+ 'regular season',
74
+ 'regular stage',
75
+ ].include?( stage.downcase )
64
76
 
65
77
 
66
- ###
67
- # step 2 - handle secs
68
- secs.each do |sec| ## sec(tion)s
69
- season = sec[:season]
70
- league = sec[:league]
71
- stage = sec[:stage]
72
- lines = sec[:lines]
73
-
78
+ ### todo/fix - remove "legacy/old" requirement for start date!!!!
79
+ start = if season.year?
80
+ Date.new( season.start_year, 1, 1 )
81
+ else
82
+ Date.new( season.start_year, 7, 1 )
83
+ end
84
+
74
85
  ### check if event info available - use start_date;
75
86
  ## otherwise we have to guess (use a "synthetic" start_date)
76
- event_info = catalog.events.find_by( season: season,
77
- league: league )
78
-
87
+ ## event_info = Import::EventInfo.find_by( season: season,
88
+ ## league: league )
89
+ =begin
79
90
  start = if event_info && event_info.start_date
80
91
  puts "event info found:"
81
92
  puts " using start date from event: "
@@ -89,13 +100,16 @@ class MatchReader ## todo/check: rename to MatchReaderV2 (use plural?) why? w
89
100
  Date.new( season.start_year, 7, 1 )
90
101
  end
91
102
  end
92
-
103
+ =end
93
104
 
94
105
  parser = MatchParser.new( lines,
95
106
  start ) ## note: keep season start_at date for now (no need for more specific stage date need for now)
96
107
 
97
108
  auto_conf_teams, matches, rounds, groups = parser.parse
98
109
 
110
+ ## auto-add "upstream" errors from parser
111
+ @errors += parser.errors if parser.errors?
112
+
99
113
  puts ">>> #{auto_conf_teams.size} teams:"
100
114
  pp auto_conf_teams
101
115
  puts ">>> #{matches.size} matches:"
@@ -105,6 +119,10 @@ class MatchReader ## todo/check: rename to MatchReaderV2 (use plural?) why? w
105
119
  puts ">>> #{groups.size} groups:"
106
120
  pp groups
107
121
 
122
+ puts "league:"
123
+ pp league
124
+
125
+
108
126
 
109
127
  ##################################
110
128
  ## step 1: map/find teams
@@ -113,11 +131,8 @@ class MatchReader ## todo/check: rename to MatchReaderV2 (use plural?) why? w
113
131
  # puts " [debug] auto_conf_teams:"
114
132
  # pp auto_conf_teams
115
133
 
116
- puts "league:"
117
- pp league
118
-
119
- teams = catalog.teams.find_by!( name: auto_conf_teams,
120
- league: league )
134
+ teams = Import::Team.find_by!( name: auto_conf_teams,
135
+ league: league )
121
136
 
122
137
  puts " [debug] teams:"
123
138
  pp teams
@@ -4,8 +4,8 @@ module SportDb
4
4
  module Module
5
5
  module Readers
6
6
  MAJOR = 2 ## todo: namespace inside version or something - why? why not??
7
- MINOR = 1
8
- PATCH = 1
7
+ MINOR = 3
8
+ PATCH = 0
9
9
  VERSION = [MAJOR,MINOR,PATCH].join('.')
10
10
 
11
11
  def self.version
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: 2.1.1
4
+ version: 2.3.0
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-30 00:00:00.000000000 Z
11
+ date: 2025-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sportdb-formats
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '4.1'
67
+ version: '4.2'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '4.1'
74
+ version: '4.2'
75
75
  description: sportdb-readers - sport.db readers for leagues, seasons, clubs, match
76
76
  schedules and results, and more
77
77
  email: gerald.bauer@gmail.com
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  requirements: []
123
- rubygems_version: 3.4.10
123
+ rubygems_version: 3.5.22
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: sportdb-readers - sport.db readers for leagues, seasons, clubs, match schedules