footty 2025.4.9 → 2025.4.28
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/Manifest.txt +0 -1
- data/README.md +1 -1
- data/lib/footty/dataset.rb +17 -0
- data/lib/footty/openfootball.rb +26 -5
- data/lib/footty/version.rb +1 -1
- data/lib/footty.rb +59 -1
- metadata +2 -3
- data/lib/footty/datalib.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 620119829b1dbd891a01c374c8996a264e347f329e0211387e18fdc12add6fe6
|
4
|
+
data.tar.gz: cc1f485cc3bbfc12ab5f3846823df6c63f7295912045996a08c2ccb4e50eb7a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0394d72327b87ad90e207e48883bf90acace8e1183d85f9175b9a6484ab8c62e3e12759f77a3eac1e59cc526e0eeacdd70183418a29a920e47c10732f28e51e
|
7
|
+
data.tar.gz: a0e274e21d9ca9620cbdda59ebdec84e92f5b8a99a4e747a177b076de6b830c94b66064c5b89c7ae6ae989b47803558aa7720fd51a321c089705987ad5196f52
|
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
data/README.md
CHANGED
@@ -81,7 +81,7 @@ More
|
|
81
81
|
- `world` => World Cup
|
82
82
|
- `euro` => "Euro" - European Championship
|
83
83
|
|
84
|
-
See [footty/openfootball](https://github.com/sportdb/footty/blob/master/lib/footty/openfootball.rb) for the complete built-in list of data sources (and league codes).
|
84
|
+
See [footty/openfootball](https://github.com/sportdb/footty/blob/master/footty/lib/footty/openfootball.rb) for the complete built-in list of data sources (and league codes).
|
85
85
|
|
86
86
|
|
87
87
|
|
data/lib/footty/dataset.rb
CHANGED
@@ -47,6 +47,23 @@ module Footty
|
|
47
47
|
end
|
48
48
|
|
49
49
|
|
50
|
+
def query( q )
|
51
|
+
## query/check for team name match for now
|
52
|
+
rx = /#{Regexp.escape(q)}/i ## use case-insensitive regex match
|
53
|
+
|
54
|
+
matches = select_matches do |match|
|
55
|
+
if rx.match( match['team1'] ) ||
|
56
|
+
rx.match( match['team2'] )
|
57
|
+
true
|
58
|
+
else
|
59
|
+
false
|
60
|
+
end
|
61
|
+
end
|
62
|
+
matches
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
|
50
67
|
def upcoming_matches( date: Date.today,
|
51
68
|
limit: nil )
|
52
69
|
## note: includes todays matches for now
|
data/lib/footty/openfootball.rb
CHANGED
@@ -11,11 +11,23 @@ module Footty
|
|
11
11
|
'euro' => { '2024' => 'euro/2024--germany/euro.txt',
|
12
12
|
'2021' => 'euro/2021--europe/euro.txt'
|
13
13
|
},
|
14
|
-
'de'
|
15
|
-
'de2'
|
16
|
-
|
17
|
-
'
|
18
|
-
|
14
|
+
'de' => 'deutschland/$season$/1-bundesliga.txt',
|
15
|
+
'de2' => 'deutschland/$season$/2-bundesliga2.txt',
|
16
|
+
'de3' => 'deutschland/$season$/3-liga3.txt',
|
17
|
+
'decup' => 'deutschland/$season$/cup.txt',
|
18
|
+
|
19
|
+
|
20
|
+
'en' => 'england/$season$/1-premierleague.txt',
|
21
|
+
'en2' => 'england/$season$/2-championship.txt',
|
22
|
+
## add alternate codes!!!
|
23
|
+
## use eflcup, facup - why? why not?
|
24
|
+
'eneflcup' => 'england/$season$/eflcup.txt',
|
25
|
+
'enfacup' => 'england/$season$/facup.txt',
|
26
|
+
|
27
|
+
|
28
|
+
'es' => 'espana/$season$/1-liga.txt',
|
29
|
+
'escup' => 'espana/$season$/cup.txt',
|
30
|
+
|
19
31
|
'it'=> 'italy/$season$/1-seriea.txt',
|
20
32
|
|
21
33
|
'at'=> 'austria/$season$/1-bundesliga.txt',
|
@@ -32,13 +44,20 @@ module Footty
|
|
32
44
|
'br' => 'south-america/brazil/$year$_br1.txt',
|
33
45
|
'ar' => 'south-america/argentina/$year$_ar1.txt',
|
34
46
|
'co' => 'south-america/colombia/$year$_co1.txt',
|
47
|
+
|
35
48
|
## use a different code for copa libertadores? why? why not?
|
36
49
|
'copa' => 'south-america/copa-libertadores/$year$_copal.txt',
|
37
50
|
|
38
51
|
'mx' => 'world/north-america/mexico/$season$_mx1.txt',
|
52
|
+
'mls' => 'world/north-america/major-league-soccer/$year$_mls.txt',
|
39
53
|
|
40
54
|
'eg' => 'world/africa/egypt/$season$_eg1.txt',
|
41
55
|
'ma' => 'world/africa/morocco/$season$_ma1.txt',
|
56
|
+
|
57
|
+
'au' => 'world/pacific/australia/$season$_au1.txt',
|
58
|
+
'jp' => 'world/asia/japan/$year$_jp1.txt',
|
59
|
+
'cn' => 'world/asia/china/$year$_cn1.txt',
|
60
|
+
|
42
61
|
}
|
43
62
|
|
44
63
|
|
@@ -51,6 +70,8 @@ module Footty
|
|
51
70
|
def self.latest_season( league: )
|
52
71
|
spec = SOURCES[ league.downcase ]
|
53
72
|
|
73
|
+
raise ArgumentError, "no dataset (source) for league #{league} found" if spec.nil?
|
74
|
+
|
54
75
|
## todo/fix - report error if no spec found
|
55
76
|
season = if spec.is_a?( Hash ) ## assume lookup by year
|
56
77
|
spec.keys[0]
|
data/lib/footty/version.rb
CHANGED
data/lib/footty.rb
CHANGED
@@ -10,7 +10,6 @@ require 'optparse'
|
|
10
10
|
require_relative 'footty/version' # let version always go first
|
11
11
|
require_relative 'footty/dataset'
|
12
12
|
require_relative 'footty/openfootball'
|
13
|
-
## require_relative 'footty/datalib'
|
14
13
|
|
15
14
|
require_relative 'footty/print'
|
16
15
|
|
@@ -31,6 +30,8 @@ module Footty
|
|
31
30
|
verbose: false, ## add more details
|
32
31
|
## add cache/cache_dir - why? why not?
|
33
32
|
|
33
|
+
query: nil,
|
34
|
+
|
34
35
|
## display format/mode - week/window/upcoming/past (default is today)
|
35
36
|
yesterday: nil,
|
36
37
|
tomorrow: nil,
|
@@ -50,6 +51,11 @@ module Footty
|
|
50
51
|
opts[:verbose] = true
|
51
52
|
end
|
52
53
|
|
54
|
+
parser.on( "-q NAME", "--query",
|
55
|
+
"query mode; display matches where team name matches query" ) do |query|
|
56
|
+
opts[:query] = query
|
57
|
+
end
|
58
|
+
|
53
59
|
|
54
60
|
parser.on( "-y", "--yesterday" ) do |yesterday|
|
55
61
|
opts[:yesterday] = true
|
@@ -72,6 +78,35 @@ module Footty
|
|
72
78
|
puts "ARGV:"
|
73
79
|
p args
|
74
80
|
|
81
|
+
|
82
|
+
###
|
83
|
+
## use simple norm(alize) args (that is,) league codes for now
|
84
|
+
## - downcase, strip dot (.) etc.)
|
85
|
+
## e.g. en.facup => enfacup
|
86
|
+
## at.cup => atcup etc.
|
87
|
+
args = args.map { |arg| arg.downcase.gsub( /[._-]/, '' ) }
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
######################
|
92
|
+
## note - first check for buil-in "magic" commands
|
93
|
+
## e.g. leagues / codes - dump built-in league codes
|
94
|
+
|
95
|
+
if args.include?( 'leagues' )
|
96
|
+
puts "==> openfootball dataset sources:"
|
97
|
+
pp OpenfootballDataset::SOURCES
|
98
|
+
|
99
|
+
## pretty print keys/codes only
|
100
|
+
puts
|
101
|
+
puts OpenfootballDataset::SOURCES.keys.join( ' ' )
|
102
|
+
puts " #{OpenfootballDataset::SOURCES.keys.size} league code(s)"
|
103
|
+
|
104
|
+
exit 1
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
75
110
|
|
76
111
|
top = [['world', '2022'],
|
77
112
|
['euro', '2024'],
|
@@ -108,6 +143,28 @@ module Footty
|
|
108
143
|
|
109
144
|
|
110
145
|
|
146
|
+
###################
|
147
|
+
## check for query option to filter matches by query (team)
|
148
|
+
if opts[:query]
|
149
|
+
q = opts[:query]
|
150
|
+
puts
|
151
|
+
puts
|
152
|
+
datasets.each do |dataset|
|
153
|
+
matches = dataset.query( q )
|
154
|
+
|
155
|
+
if matches.size == 0
|
156
|
+
## siltently skip for now
|
157
|
+
else ## assume matches found
|
158
|
+
print "==> #{dataset.league_name}"
|
159
|
+
print " #{dataset.start_date} - #{dataset.end_date}"
|
160
|
+
print " -- #{dataset.matches.size} match(es)"
|
161
|
+
print "\n"
|
162
|
+
print_matches( matches )
|
163
|
+
end
|
164
|
+
end
|
165
|
+
exit 1
|
166
|
+
end
|
167
|
+
|
111
168
|
|
112
169
|
# Dataset.new( league: 'euro', year: 2024 )
|
113
170
|
# dataset = Dataset.new( league: league, year: year )
|
@@ -128,6 +185,7 @@ module Footty
|
|
128
185
|
'today'
|
129
186
|
end
|
130
187
|
|
188
|
+
|
131
189
|
## start with two empty lines - assume (massive) debug output before ;-)
|
132
190
|
puts
|
133
191
|
puts
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: footty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2025.4.
|
4
|
+
version: 2025.4.28
|
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-
|
11
|
+
date: 2025-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-quick
|
@@ -91,7 +91,6 @@ files:
|
|
91
91
|
- bin/footty
|
92
92
|
- bin/ftty
|
93
93
|
- lib/footty.rb
|
94
|
-
- lib/footty/datalib.rb
|
95
94
|
- lib/footty/dataset.rb
|
96
95
|
- lib/footty/openfootball.rb
|
97
96
|
- lib/footty/print.rb
|
data/lib/footty/datalib.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
module Footty
|
2
|
-
|
3
|
-
class Datalib ## Library (Selection) of datasets
|
4
|
-
## nameing - use datasel(ection) or datacol(lection)
|
5
|
-
## or databox or dataman(ger) or
|
6
|
-
## or datacache or
|
7
|
-
## or datacomposite/view
|
8
|
-
## or dtataportal or ???
|
9
|
-
|
10
|
-
|
11
|
-
def initialize( datasets=[] )
|
12
|
-
@datasets = datasets
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end # class Datalib
|
20
|
-
end # module Footty
|