sportdb-quick 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc074126897237cd4cdb59c160e6dd41fa5b9e1ec3581472eeb68f520e486a61
4
- data.tar.gz: 32112335ee74977ebd243e4ead540dabb49b291d837933315d57f7d3d86a47b4
3
+ metadata.gz: 743ddb45d7379bdcb351178da359316544e663307b5d96c34f6ac90b9752fce3
4
+ data.tar.gz: 86960f084c612aec1e04f183ba1f3a89959518355e498527734b23a265090fa9
5
5
  SHA512:
6
- metadata.gz: d0e23a4e07fa3e811c82eed4215d4229bc548e130d7e8bac70a85f8307928e50b28862e14b9a70c887166282c4efdb937d9533c1bfe0b1fddaced7b6b77d6729
7
- data.tar.gz: dd442c2ae016aad05d5aa5e21dcd4420bb45808bdc18cf5759e97a37849527dcd1a9ab89da7a8ecb48a5d5a52956d7f36ae1b506a170dae138234e61925520a1
6
+ metadata.gz: 6068e848f99a756b9de1d4012cda3d5c6750dc99c329f773cbd692ffa9004f2cfa5835ffdb329aae055eaa30f1ffafeab42adc1a627d05ca040261d71d5476a7
7
+ data.tar.gz: d143f15ecca6cc4bdf3c72e0d8883c94622198e9fd721ce14e93ebc882c127ef4300d865bb05d7c129e82e2f27d81ea25ca4894e0d254a0b80e6600911cd6ac5
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.2.0
1
+ ### 0.2.1
2
2
 
3
3
  ### 0.0.1 / 2024-08-27
4
4
 
data/Manifest.txt CHANGED
@@ -3,7 +3,6 @@ Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
5
  bin/fbt
6
- bin/fbtxt2json
7
6
  lib/sportdb/quick.rb
8
7
  lib/sportdb/quick/csv/goal.rb
9
8
  lib/sportdb/quick/csv/goal_parser_csv.rb
data/bin/fbt CHANGED
@@ -26,7 +26,6 @@ require 'optparse'
26
26
 
27
27
  args = ARGV
28
28
  opts = { debug: false,
29
- json: false,
30
29
  file: nil,
31
30
  }
32
31
 
@@ -36,19 +35,14 @@ require 'optparse'
36
35
  ##
37
36
  ## check if git has a offline option?? (use same)
38
37
  ## check for other tools - why? why not?
39
- parser.on( "-q", "--quiet",
40
- "less debug output/messages - default is (#{!opts[:debug]})" ) do |debug|
41
- opts[:debug] = false
42
- end
43
- # parser.on( "--verbose", "--debug",
44
- # "turn on verbose / debug output (default: #{opts[:debug]})" ) do |debug|
45
- # opts[:debug] = true
46
- # end
47
-
48
- parser.on( "-j", "--json",
49
- "print out in .json - default is (#{opts[:json]})" ) do |json|
50
- opts[:json] = true
51
- end
38
+ # parser.on( "-q", "--quiet",
39
+ # "less debug output/messages - default is (#{!opts[:debug]})" ) do |debug|
40
+ # opts[:debug] = false
41
+ # end
42
+ parser.on( "--verbose", "--debug",
43
+ "turn on verbose / debug output (default: #{opts[:debug]})" ) do |debug|
44
+ opts[:debug] = true
45
+ end
52
46
 
53
47
  parser.on( "-f FILE", "--file FILE",
54
48
  "read datafiles (pathspecs) via .csv file") do |file|
@@ -117,13 +111,6 @@ end
117
111
  errors << [ path, *err ] # note: use splat (*) to add extra values (starting with msg)
118
112
  end
119
113
  end
120
-
121
- ## pp matches
122
- ## try json for matches
123
- if opts[:json]
124
- data = matches.map {|match| match.as_json }
125
- pp data
126
- end
127
114
  puts " #{matches.size} match(es)"
128
115
  end
129
116
 
@@ -86,7 +86,8 @@ class QuickLeagueOutlineReader
86
86
  ## => Österr. Bundesliga 2018/19, Regular Season
87
87
  ## => Österr. Bundesliga 2018/19, Championship Round
88
88
  ## etc.
89
- values = str.split( /[,<>‹›]/ ) ## note: allow , > < or › ‹ for now
89
+ ## note limit split to two parts only!!!!
90
+ values = str.split( /[,<>‹›]/, 2 ) ## note: allow , > < or › ‹ for now
90
91
  values = values.map { |value| value.strip } ## remove all whitespaces
91
92
  values
92
93
  end
@@ -30,11 +30,31 @@ class QuickMatchReader
30
30
  attr_reader :errors
31
31
  def errors?() @errors.size > 0; end
32
32
 
33
+
34
+ ###
35
+ # helpers get matches & more after parse; all stored in data
36
+ #
37
+ ## change/rename to event - why? why not?
38
+ def league_name
39
+ league = @data.keys[0]
40
+ season = @data[ league ].keys[0]
41
+
42
+ "#{league} #{season}"
43
+ end
44
+
45
+ def matches
46
+ league = @data.keys[0]
47
+ season = @data[ league ].keys[0]
48
+ @data[league][season]
49
+ end
50
+
51
+
52
+
33
53
  def parse
34
54
  ## note: every (new) read call - resets errors list to empty
35
55
  @errors = []
36
56
 
37
- data = {} # return data hash with leagues
57
+ @data = {} # return data hash with leagues
38
58
  # and seasons
39
59
  # for now merge stage into matches
40
60
 
@@ -81,10 +101,10 @@ class QuickMatchReader
81
101
  end
82
102
  end
83
103
 
84
- data[ league ] ||= {}
85
- data[ league ][ season.key ] ||= []
104
+ @data[ league ] ||= {}
105
+ @data[ league ][ season.key ] ||= []
86
106
 
87
- data[ league ][ season.key ] += matches
107
+ @data[ league ][ season.key ] += matches
88
108
  ## note - skip teams, rounds, and groups for now
89
109
  end
90
110
 
@@ -92,21 +112,21 @@ class QuickMatchReader
92
112
  ## allowed in quick style
93
113
 
94
114
 
95
- leagues = data.keys
115
+ leagues = @data.keys
96
116
  if leagues.size != 1
97
117
  puts "!! (QUICK) PARSE ERROR - expected one league only; got #{leagues.size}:"
98
118
  pp leagues
99
119
  exit 1
100
120
  end
101
121
 
102
- seasons = data[ leagues[0] ].keys
122
+ seasons = @data[ leagues[0] ].keys
103
123
  if seasons.size != 1
104
124
  puts "!! (QUICK) PARSE ERROR - expected one #{leagues[0]} season only; got #{seasons.size}:"
105
125
  pp seasons
106
126
  exit 1
107
127
  end
108
128
 
109
- data[ leagues[0] ][ seasons[0] ]
129
+ @data[ leagues[0] ][ seasons[0] ]
110
130
  end # method parse
111
131
 
112
132
  end # class QuickMatchReader
@@ -4,7 +4,7 @@ module SportDb
4
4
  module Quick
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
6
  MINOR = 2
7
- PATCH = 0
7
+ PATCH = 1
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-quick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
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: 2024-09-19 00:00:00.000000000 Z
11
+ date: 2024-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sportdb-parser
@@ -90,7 +90,6 @@ description: sportdb-quick - football.txt (quick) match readers and more
90
90
  email: gerald.bauer@gmail.com
91
91
  executables:
92
92
  - fbt
93
- - fbtxt2json
94
93
  extensions: []
95
94
  extra_rdoc_files:
96
95
  - CHANGELOG.md
@@ -102,7 +101,6 @@ files:
102
101
  - README.md
103
102
  - Rakefile
104
103
  - bin/fbt
105
- - bin/fbtxt2json
106
104
  - lib/sportdb/quick.rb
107
105
  - lib/sportdb/quick/csv/goal.rb
108
106
  - lib/sportdb/quick/csv/goal_parser_csv.rb
data/bin/fbtxt2json DELETED
@@ -1,75 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- ## tip: to test run:
4
- ## ruby -I ./lib bin/fbtxt2json
5
-
6
-
7
- ## our own code
8
- require 'sportdb/quick'
9
-
10
-
11
-
12
- require 'optparse'
13
-
14
-
15
-
16
- args = ARGV
17
- opts = { debug: false,
18
- }
19
-
20
- parser = OptionParser.new do |parser|
21
- parser.banner = "Usage: #{$PROGRAM_NAME} [options]"
22
-
23
- ##
24
- ## check if git has a offline option?? (use same)
25
- ## check for other tools - why? why not?
26
- parser.on( "-q", "--quiet",
27
- "less debug output/messages - default is (#{!opts[:debug]})" ) do |debug|
28
- opts[:debug] = false
29
- end
30
- end
31
- parser.parse!( args )
32
-
33
- puts "OPTS:"
34
- p opts
35
- puts "ARGV:"
36
- p args
37
-
38
-
39
- path = if args.empty?
40
- '../../../openfootball/euro/2021--europe/euro.txt'
41
- elsif args.size == 1
42
- args[0]
43
- else
44
- puts "!! wrong number of args, got #{args.size} - #{args.inspect} - only one arg supported/expected"
45
- exit 1
46
- end
47
-
48
-
49
- if opts[:debug]
50
- SportDb::QuickMatchReader.debug = true
51
- SportDb::MatchParser.debug = true
52
- else
53
- SportDb::QuickMatchReader.debug = false
54
- SportDb::MatchParser.debug = false
55
- LogUtils::Logger.root.level = :info
56
- end
57
-
58
-
59
- puts "==> reading >#{path}<..."
60
- quick = SportDb::QuickMatchReader.new( read_text( path ) )
61
- matches = quick.parse
62
-
63
- data = matches.map {|match| match.as_json }
64
- pp data
65
- puts
66
- puts " #{matches.size} match(es)"
67
-
68
- if quick.errors?
69
- puts "!! #{quick.errors.size} parse error(s):"
70
- pp quick.errors
71
- end
72
-
73
-
74
- puts "bye"
75
-