sportdb-search 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 +4 -4
- data/CHANGELOG.md +1 -1
- data/lib/sportdb/search/sport-leagues.rb +55 -1
- data/lib/sportdb/search/sport-teams.rb +12 -2
- data/lib/sportdb/search/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e52e9d8288b15116dfeec9a2dd1255a10d52b478378040e6f503d314b21d63f2
|
4
|
+
data.tar.gz: 21d4c8335205ab2c38ebd7c5919500d1a4c4181edfc6a4dfb0ed5aa434eaf58e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac5ebf7ea6e41ab2466bb70dd96db6cb2ef07c92539d7c3131be57bdbd600120d6a41927e493ed5a5069276b876398058be3c10a09c804498f07e57d450832a3
|
7
|
+
data.tar.gz: 193911ab634b2435c63979a14164a1b5e46a1cd9288a7459dc5e1e54c0e7e81bb0001e494226878f25d98345157632f5d7c34baaf6a240de0b40a9d0d1bd9a63
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,60 @@
|
|
1
1
|
|
2
2
|
module Sports
|
3
3
|
|
4
|
+
|
5
|
+
class LeaguePeriod
|
6
|
+
def self._search() CatalogDb::Metal::LeaguePeriod; end
|
7
|
+
|
8
|
+
|
9
|
+
def self.match_by( name: nil, code: nil, season: )
|
10
|
+
## todo/fix upstream - remove "generic" match_by() - why? why not?
|
11
|
+
###
|
12
|
+
if code && name.nil?
|
13
|
+
_search.match_by_code( code, season: season )
|
14
|
+
elsif name && code.nil?
|
15
|
+
_search.match_by_name( name, season: season )
|
16
|
+
else
|
17
|
+
raise ArgumentError, "LeaguePeriod.match_by - one (and only one arg) required - code: or name:"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
## all-in-one query (name or code)
|
23
|
+
def self.match( q, season: )
|
24
|
+
_search.match_by_name_or_code( q, season: season )
|
25
|
+
end
|
26
|
+
|
27
|
+
###############
|
28
|
+
### more deriv support functions / helpers
|
29
|
+
def self.find!( q, season: )
|
30
|
+
period = find( q, season: season )
|
31
|
+
if period.nil?
|
32
|
+
puts "** !!! ERROR - no league period found for >#{q}+#{season}<, add to leagues table; sorry"
|
33
|
+
exit 1
|
34
|
+
end
|
35
|
+
period
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.find( q, season: )
|
39
|
+
period = nil
|
40
|
+
recs = match( q, season: season )
|
41
|
+
# pp m
|
42
|
+
|
43
|
+
if recs.empty?
|
44
|
+
## fall through/do nothing
|
45
|
+
elsif recs.size > 1
|
46
|
+
puts "** !!! ERROR - too many matches (#{recs.size}) for league period >#{q}+#{season}<:"
|
47
|
+
pp recs
|
48
|
+
exit 1
|
49
|
+
else
|
50
|
+
period = recs[0]
|
51
|
+
end
|
52
|
+
|
53
|
+
period
|
54
|
+
end
|
55
|
+
end # class LeaguePeriod
|
56
|
+
|
57
|
+
|
4
58
|
class League
|
5
59
|
def self._search() CatalogDb::Metal::League; end
|
6
60
|
|
@@ -14,7 +68,7 @@ class League
|
|
14
68
|
elsif name && code.nil?
|
15
69
|
_search.match_by_name( name, country: country )
|
16
70
|
else
|
17
|
-
raise ArgumentError, "
|
71
|
+
raise ArgumentError, "League.match_by - one (and only one arg) required - code: or name:"
|
18
72
|
end
|
19
73
|
end
|
20
74
|
|
@@ -65,8 +65,18 @@ end # class NationalTeam
|
|
65
65
|
## check for country code
|
66
66
|
if m=CLUB_NAME_RE.match( name )
|
67
67
|
if m[:code]
|
68
|
-
Club.find_by
|
69
|
-
|
68
|
+
rec = Club.find_by( name: m[:name],
|
69
|
+
country: m[:code] )
|
70
|
+
if rec.nil?
|
71
|
+
puts "auto-create (missing) club #{name}"
|
72
|
+
## todo/fix: add auto flag!!!!
|
73
|
+
### like in rounds!!!
|
74
|
+
## to track auto-created clubs
|
75
|
+
rec = Club.new( name: m[:name] )
|
76
|
+
rec.country = Country.find_by( code: m[:code] ) ## fix: country kwarg not yet supported!!
|
77
|
+
pp rec
|
78
|
+
end
|
79
|
+
rec
|
70
80
|
else
|
71
81
|
Club.find!( name )
|
72
82
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
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-10-
|
11
|
+
date: 2024-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-catalogs
|