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 +4 -4
- data/CHANGELOG.md +1 -1
- data/lib/sportdb/readers/match_reader.rb +61 -46
- data/lib/sportdb/readers/version.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9cd6dabbfbee07274abaffd4ff011043feeb59c3dd0b2f22f8e1ff0c0af5b50
|
4
|
+
data.tar.gz: f17cb3e392b861e8a7d41a5066e682976964fb97b6d17d4a18cd6ac4f8197642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20a4da1af9e2c22bcb2857b4fee74e25e595e05b884329ca3082e7a1577def93e57089d7e2a9790b0d3944730fdce2af7a46f086399d89acee693c5d7677b719
|
7
|
+
data.tar.gz: dac7327b7f1f6dac3fd9cd73f1fbf317bbaccd8674f48ef9bfd88fff4da6c824d02528f3a3ff731695a90ab5e500dc0e921113eb8c89ddb78d50d48b306dad55
|
data/CHANGELOG.md
CHANGED
@@ -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
|
-
@
|
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
|
-
|
42
|
-
|
35
|
+
## note: every (new) read call - resets errors list to empty
|
36
|
+
@errors = []
|
43
37
|
|
44
|
-
|
45
|
-
|
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
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
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 =
|
77
|
-
|
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
|
-
|
117
|
-
|
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
|
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.
|
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:
|
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.
|
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.
|
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.
|
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
|