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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3101d3bc2cbc21aae12dcc1a108f7972211d55c86415a06c48e0a8db945ac3f
4
- data.tar.gz: afaa93ffb303fd4205acdaa1aee1c80ec810a7bf723dabb99960025edb03076b
3
+ metadata.gz: 620119829b1dbd891a01c374c8996a264e347f329e0211387e18fdc12add6fe6
4
+ data.tar.gz: cc1f485cc3bbfc12ab5f3846823df6c63f7295912045996a08c2ccb4e50eb7a5
5
5
  SHA512:
6
- metadata.gz: 8d23098b1142d238c5f18bec351b6aff504682cb21e724df04dace6a9e40294267463037313c0fafae9a51e46ae80f88e976b681fb6d79fd51832282610957b7
7
- data.tar.gz: 3906e217d2f73536b52295c6502eed1b96af0d4cd436a331c075ecc1780ab8c005ebbad260ef3856a70009cd5a4befd037f700e4a3f1d050b7bc3842b70a5b90
6
+ metadata.gz: a0394d72327b87ad90e207e48883bf90acace8e1183d85f9175b9a6484ab8c62e3e12759f77a3eac1e59cc526e0eeacdd70183418a29a920e47c10732f28e51e
7
+ data.tar.gz: a0e274e21d9ca9620cbdda59ebdec84e92f5b8a99a4e747a177b076de6b830c94b66064c5b89c7ae6ae989b47803558aa7720fd51a321c089705987ad5196f52
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 2025.4.9
1
+ ### 2025.4.28
2
2
  ### 1.0.0 / 2018-06-09
3
3
 
4
4
  * Everything is new (again). First release.
data/Manifest.txt CHANGED
@@ -5,7 +5,6 @@ Rakefile
5
5
  bin/footty
6
6
  bin/ftty
7
7
  lib/footty.rb
8
- lib/footty/datalib.rb
9
8
  lib/footty/dataset.rb
10
9
  lib/footty/openfootball.rb
11
10
  lib/footty/print.rb
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
 
@@ -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
@@ -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' => 'deutschland/$season$/1-bundesliga.txt',
15
- 'de2' => 'deutschland/$season$/2-bundesliga2.txt',
16
-
17
- 'en'=> 'england/$season$/1-premierleague.txt',
18
- 'es'=> 'espana/$season$/1-liga.txt',
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]
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Footty
3
- VERSION = '2025.4.9'
3
+ VERSION = '2025.4.28'
4
4
 
5
5
  def self.banner
6
6
  "footty/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
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.9
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-09 00:00:00.000000000 Z
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
@@ -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