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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c135a538a3ebe251b9506a6a31e0dcad7b3a456ed863a1a56ae3235a00129fd5
4
- data.tar.gz: 145edb5ec66df797b8361f82da6c493417354ab408e19fa1a74fbb6f39d87d1f
3
+ metadata.gz: e52e9d8288b15116dfeec9a2dd1255a10d52b478378040e6f503d314b21d63f2
4
+ data.tar.gz: 21d4c8335205ab2c38ebd7c5919500d1a4c4181edfc6a4dfb0ed5aa434eaf58e
5
5
  SHA512:
6
- metadata.gz: 8e6604db8b3fb94a5fd1aa6656bb074ea6486765c0018eab262af941ec294323a3dd496d3782c8a735ce36b25650ef56e39bf7b536c8f059159a82c3d54e4ad6
7
- data.tar.gz: 4dddf10fd601263a12f4ea7845e61261e6983a8d9c8f7420bc927d2149081c1420bd7e2793ab1a8e50a8b3aab18a9d21f411c135caab09ce1c72d0a9035c8270
6
+ metadata.gz: ac5ebf7ea6e41ab2466bb70dd96db6cb2ef07c92539d7c3131be57bdbd600120d6a41927e493ed5a5069276b876398058be3c10a09c804498f07e57d450832a3
7
+ data.tar.gz: 193911ab634b2435c63979a14164a1b5e46a1cd9288a7459dc5e1e54c0e7e81bb0001e494226878f25d98345157632f5d7c34baaf6a240de0b40a9d0d1bd9a63
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-25
4
4
 
@@ -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, "LeagueSearch#match_by - one (and only one arg) required - code: or name:"
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!( name: m[:name],
69
- country: m[:code] )
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
@@ -3,7 +3,7 @@ module Module
3
3
  module Search
4
4
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
5
5
  MINOR = 2
6
- PATCH = 0
6
+ PATCH = 1
7
7
  VERSION = [MAJOR,MINOR,PATCH].join('.')
8
8
 
9
9
  def self.version
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.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-10-01 00:00:00.000000000 Z
11
+ date: 2024-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sportdb-catalogs