sportdb-formats 2.1.2 → 2.1.4

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: 2ec79f151992c1c7a16a8a500b60771a0babaf81a546c61ce54bdc0e644f6b6c
4
- data.tar.gz: c8b1510c899407477b8799a21982ffa7c7fa72db708e83af3d9ac7d3007df366
3
+ metadata.gz: 41f3c7bf36eb0670146a99afc2b5d64bc08908519a5ec36814c2418af4e32a63
4
+ data.tar.gz: 3261bec4d966da877da33978a3feb6c2433ddc9cbe26ed7ecbd7b3080dd20a1e
5
5
  SHA512:
6
- metadata.gz: f2e036967bdf35d73d1f93e1f1cb754058fb167a228785b9fbef4b21c8377b6bce9a9764bce2f9d79ed3629bb4202c6d344630bafdf187e53ec20e65c49ff32a
7
- data.tar.gz: 95a64a731197e54d333ee931f31e9f6aae0691c09ad2494b80508b9db08e87b6be74520d8ce261667fa8df78aa8b5ce4ed9b13f343d598e6ee250811f284ff5f
6
+ metadata.gz: 81090e3dd2909aaf7655f61d51447a455bb71ff93f27f958934ba0c12a7ca2ca1eb6ee913756921762258111c953ce5fdec7ee62c71123fcae4f10c800b36375
7
+ data.tar.gz: 70fec4a289b64373025385516ab608acedc806f0cf9ced07c90db698a0a2e5a4c3bbb519f1c48356058705d10a43aa8ff634dc92f737090c855c6db8152aeba2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,4 @@
1
- ### 2.1.2
2
-
1
+ ### 2.1.4
3
2
  ### 0.0.1 / 2019-10-28
4
3
 
5
4
  * Everything is new. First release.
data/Manifest.txt CHANGED
@@ -2,7 +2,6 @@ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
- bin/fbchk
6
5
  lib/sportdb/formats.rb
7
6
  lib/sportdb/formats/datafile_package.rb
8
7
  lib/sportdb/formats/package.rb
@@ -58,14 +58,12 @@ class QuickMatchLinter
58
58
  # and seasons
59
59
  # for now merge stage into matches
60
60
 
61
- secs = QuickLeagueOutlineReader.parse( @txt )
62
- pp secs if debug?
63
-
64
- secs.each do |sec| ## sec(tion)s
65
- season = Season.parse( sec[:season] ) ## convert (str) to season obj!!!
66
- league = sec[:league]
67
- stage = sec[:stage]
68
- lines = sec[:lines]
61
+ outline = QuickLeagueOutline.parse( @txt )
62
+ outline.each_sec do |sec| ## sec(tion)s
63
+ season = Season.parse( sec.season ) ## convert (str) to season obj!!!
64
+ league = sec.league
65
+ stage = sec.stage
66
+ lines = sec.lines
69
67
 
70
68
  start = if season.year?
71
69
  Date.new( season.start_year, 1, 1 )
@@ -73,24 +71,43 @@ class QuickMatchLinter
73
71
  Date.new( season.start_year, 7, 1 )
74
72
  end
75
73
 
76
- ###
77
- ## db check - check league
78
- ## fix/fix - add season to match_by !!!!!!!
79
- ## note - changed to match (incl. code) from match_by(name:) only!!!
80
- recs = Import::League.match( league )
81
- league_rec = nil
82
- if recs.size == 1
83
- league_rec = recs[0]
84
- puts " OK #{league} => #{league_rec.name}"
85
- elsif recs.size == 0
86
- msg = "NAME ERROR - no league match found for >#{league}<"
87
- @errors << [msg]
88
- puts "!! #{msg}"
89
- else
90
- msg = "NAME ERROR - ambigous; too many league matches (#{recs.size}) found for >#{league}<"
91
- @errors << [msg]
92
- puts "!! #{msg}"
93
- end
74
+ league_rec = nil
75
+
76
+
77
+ ## if all upcase or digits - assume/try code first
78
+ ## todo/fix - change to find_by( code: ) !!!!
79
+ period = Import::LeaguePeriod.find_by( code: league, season: season )
80
+ if period
81
+ ## find league by qname (assumed to be unique!!)
82
+ ## todo/fix - use League.find_by!( name: ) !!!!
83
+ ## make more specifi
84
+ league_rec = Import::League.find!( period.qname )
85
+ puts " #{period.pretty_inspect}"
86
+ puts " OK #{league}+#{season} => #{league_rec.pretty_inspect}"
87
+ else
88
+ ## try "generic" match by name (& more alt codes)
89
+ ###
90
+ ## db check - check league
91
+ ## fix/fix - add season to match_by !!!!!!!
92
+ ## note - changed to match (incl. code) from match_by(name:) only!!!
93
+ recs = Import::League.match( league )
94
+ if recs.size == 1
95
+ league_rec = recs[0]
96
+ ## note - use pp (pretty_inspect) instead of league_rec.name
97
+ puts " OK #{league} => #{league_rec.pretty_inspect}"
98
+ elsif recs.size == 0
99
+ msg = "NAME ERROR - no league match found for >#{league}<"
100
+ @errors << [msg]
101
+ puts "!! #{msg}"
102
+ else
103
+ msg = "NAME ERROR - ambigous; too many league matches (#{recs.size}) found for >#{league}<"
104
+ @errors << [msg]
105
+ puts "!! #{msg}"
106
+ end
107
+ end
108
+
109
+ ### note - skip section if no lines !!!!!
110
+ next if lines.empty? ## or use lines.size == 0
94
111
 
95
112
 
96
113
  parser = MatchParser.new( lines,
@@ -147,7 +164,7 @@ class QuickMatchLinter
147
164
  team_rec = nil
148
165
  if recs.size == 1
149
166
  team_rec = recs[0]
150
- puts " OK #{team} => #{team_rec.name}, #{team_rec.country.name}"
167
+ puts " OK #{team} => #{team_rec.pretty_inspect}"
151
168
  elsif recs.size == 0
152
169
  msg = "NAME ERROR - no team match found for >#{team}<"
153
170
  @errors << [msg]
@@ -4,7 +4,7 @@ module Formats
4
4
 
5
5
  MAJOR = 2 ## todo: namespace inside version or something - why? why not??
6
6
  MINOR = 1
7
- PATCH = 2
7
+ PATCH = 4
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-formats
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.4
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-10-09 00:00:00.000000000 Z
11
+ date: 2025-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sportdb-search
@@ -78,18 +78,17 @@ dependencies:
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '4.1'
81
+ version: '4.2'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '4.1'
88
+ version: '4.2'
89
89
  description: sportdb-formats - sport.db format and text utilities
90
90
  email: gerald.bauer@gmail.com
91
- executables:
92
- - fbchk
91
+ executables: []
93
92
  extensions: []
94
93
  extra_rdoc_files:
95
94
  - CHANGELOG.md
@@ -100,7 +99,6 @@ files:
100
99
  - Manifest.txt
101
100
  - README.md
102
101
  - Rakefile
103
- - bin/fbchk
104
102
  - lib/sportdb/formats.rb
105
103
  - lib/sportdb/formats/datafile_package.rb
106
104
  - lib/sportdb/formats/package.rb
@@ -128,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
126
  - !ruby/object:Gem::Version
129
127
  version: '0'
130
128
  requirements: []
131
- rubygems_version: 3.4.10
129
+ rubygems_version: 3.5.22
132
130
  signing_key:
133
131
  specification_version: 4
134
132
  summary: sportdb-formats - sport.db format and text utilities
data/bin/fbchk DELETED
@@ -1,173 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- ## tip: to test run:
4
- ## ruby -I ./lib bin/fbchk
5
-
6
- ## our own code
7
- require 'sportdb/formats'
8
-
9
-
10
-
11
- require 'optparse'
12
-
13
-
14
-
15
- ## local hack
16
- ## if exists up-to-date catalog db (use local version NOT built-in)
17
- catalog_path = '../catalog/catalog.db'
18
- if File.exist?( catalog_path )
19
- SportDb::Import.config.catalog_path = catalog_path
20
- end
21
-
22
-
23
- args = ARGV
24
- opts = { debug: false,
25
- file: nil,
26
- teams: true, ## check/lint teams (name errros etc.)
27
- }
28
-
29
- parser = OptionParser.new do |parser|
30
- parser.banner = "Usage: #{$PROGRAM_NAME} [options]"
31
-
32
- ##
33
- ## check if git has a offline option?? (use same)
34
- ## check for other tools - why? why not?
35
- # parser.on( "-q", "--quiet",
36
- # "less debug output/messages - default is (#{!opts[:debug]})" ) do |debug|
37
- # opts[:debug] = false
38
- # end
39
- parser.on( "--verbose", "--debug",
40
- "turn on verbose / debug output (default: #{opts[:debug]})" ) do |debug|
41
- opts[:debug] = true
42
- end
43
-
44
- parser.on( "-f FILE", "--file FILE",
45
- "read datafiles (pathspecs) via .csv file") do |file|
46
- opts[:file] = file
47
- end
48
-
49
- parser.on( "--[no-]teams",
50
- "turn on/off team name checks (default: #{opts[:teams]})") do |teams|
51
- opts[:teams] = teams
52
- end
53
- end
54
- parser.parse!( args )
55
-
56
-
57
- puts "OPTS:"
58
- p opts
59
- puts "ARGV:"
60
- p args
61
-
62
-
63
- ## todo/check - use packs or projects or such
64
- ## instead of specs - why? why not?
65
- specs = []
66
- if opts[:file]
67
- recs = read_csv( opts[:file] )
68
- pp recs
69
- ## note - make pathspecs relative to passed in file arg!!!
70
- basedir = File.dirname( opts[:file] )
71
- recs.each do |rec|
72
- paths = SportDb::Parser::Opts.find( rec['path'], dir: basedir )
73
- specs << [paths, rec]
74
- end
75
- else
76
- paths = if args.empty?
77
- []
78
- else
79
- ## check for directories
80
- ## and auto-expand
81
- SportDb::Parser::Opts.expand_args( args )
82
- end
83
- specs << [paths, {}]
84
- end
85
-
86
-
87
- if opts[:debug]
88
- SportDb::QuickMatchLinter.debug = true
89
- SportDb::QuickMatchReader.debug = true
90
- SportDb::MatchParser.debug = true
91
- else
92
- SportDb::QuickMatchLinter.debug = false
93
- SportDb::QuickMatchReader.debug = false
94
- SportDb::MatchParser.debug = false
95
- LogUtils::Logger.root.level = :info
96
- end
97
-
98
-
99
- specs.each_with_index do |(paths, rec),i|
100
- errors = []
101
- paths.each_with_index do |path,j|
102
- puts "==> [#{j+1}/#{paths.size}] reading >#{path}<..."
103
- quick = SportDb::QuickMatchLinter.new( read_text( path ),
104
- check_teams: opts[:teams] )
105
- matches = quick.parse
106
-
107
-
108
- if quick.errors?
109
- puts "!! #{quick.errors.size} error(s):"
110
- pp quick.errors
111
-
112
- quick.errors.each do |err|
113
- errors << [ path, *err ] # note: use splat (*) to add extra values (starting with msg)
114
- end
115
- end
116
- puts " #{matches.size} match(es)"
117
- end
118
-
119
- if errors.size > 0
120
- puts
121
- puts "!! #{errors.size} PARSE ERRORS in #{paths.size} datafile(s)"
122
- pp errors
123
- else
124
- puts
125
- puts " OK - no parse errors in #{paths.size} datafile(s)"
126
- end
127
-
128
- ## add errors to rec via rec['errors'] to allow
129
- ## for further processing/reporting
130
- rec['errors'] = errors
131
- end
132
-
133
-
134
-
135
- ###
136
- ## generate a report if --file option used
137
- if opts[:file]
138
-
139
- buf = String.new
140
-
141
- buf << "# fbchk summary report - #{specs.size} dataset(s)\n\n"
142
-
143
- specs.each_with_index do |(paths, rec),i|
144
- errors = rec['errors']
145
-
146
- if errors.size > 0
147
- buf << "!! #{errors.size} ERROR(S) "
148
- else
149
- buf << " OK "
150
- end
151
- buf << "%-20s" % rec['path']
152
- buf << " - #{paths.size} datafile(s)"
153
- buf << "\n"
154
-
155
- if errors.size > 0
156
- buf << errors.pretty_inspect
157
- buf << "\n"
158
- end
159
- end
160
-
161
- puts
162
- puts "SUMMARY:"
163
- puts buf
164
-
165
- basedir = File.dirname( opts[:file] )
166
- basename = File.basename( opts[:file], File.extname( opts[:file] ))
167
- outpath = "#{basedir}/fbcheck.#{basename}.txt"
168
- write_text( outpath, buf )
169
- end
170
-
171
-
172
- puts "bye"
173
-