sportdb-search 0.2.1 → 0.2.2

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: e52e9d8288b15116dfeec9a2dd1255a10d52b478378040e6f503d314b21d63f2
4
- data.tar.gz: 21d4c8335205ab2c38ebd7c5919500d1a4c4181edfc6a4dfb0ed5aa434eaf58e
3
+ metadata.gz: 7d33c1d67c3bd9e033532f8d1cbc35496205d5893f45cb994a8979477cf27f98
4
+ data.tar.gz: ba689181ec0c9891a9c19c2c863357982a2457bf49fcfb132371c6db6539bf66
5
5
  SHA512:
6
- metadata.gz: ac5ebf7ea6e41ab2466bb70dd96db6cb2ef07c92539d7c3131be57bdbd600120d6a41927e493ed5a5069276b876398058be3c10a09c804498f07e57d450832a3
7
- data.tar.gz: 193911ab634b2435c63979a14164a1b5e46a1cd9288a7459dc5e1e54c0e7e81bb0001e494226878f25d98345157632f5d7c34baaf6a240de0b40a9d0d1bd9a63
6
+ metadata.gz: 1e15e6f286ff215fda7c30303acda75a5d142958602ac5860d59880717bd56677738e629c853af0932efd8cc76751b52051830e4b2a2e352ebca5720dd7d520f
7
+ data.tar.gz: 4f5dbd8d358d9faffe627b058852ac4522b41dbb7b9aab22b47e52a22e1cf8c2d5e06e74917a3be6a46be914d4804e9d3b2e1e03025468762fad5231dabf2ef3
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.2.1
1
+ ### 0.2.2
2
2
 
3
3
  ### 0.0.1 / 2024-08-25
4
4
 
@@ -1,6 +1,13 @@
1
1
 
2
2
  module Sports
3
3
 
4
+ ###
5
+ ## todo - move LeaguePeriod to its own file!!!
6
+ ## add note - do NOT use match/find_by_name for now
7
+ ## might get romoved? why? why not?
8
+ ## for name lookup use League.find_by( name: ) !!!
9
+ ## use find_by( code:, season: ) !!!
10
+
4
11
 
5
12
  class LeaguePeriod
6
13
  def self._search() CatalogDb::Metal::LeaguePeriod; end
@@ -18,23 +25,61 @@ class LeaguePeriod
18
25
  end
19
26
  end
20
27
 
21
-
22
28
  ## all-in-one query (name or code)
23
29
  def self.match( q, season: )
24
30
  _search.match_by_name_or_code( q, season: season )
25
31
  end
26
32
 
33
+
27
34
  ###############
28
35
  ### 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"
36
+ def self.find_by_code( code, season: )
37
+ period = nil
38
+ recs = _search.match_by_code( code, season: season )
39
+ # pp m
40
+
41
+ if recs.empty?
42
+ ## fall through/do nothing
43
+ elsif recs.size > 1
44
+ puts "** !!! ERROR - too many (code) matches (#{recs.size}) for league period >#{code}+#{season}<:"
45
+ pp recs
33
46
  exit 1
47
+ else
48
+ period = recs[0]
34
49
  end
50
+
35
51
  period
36
52
  end
37
53
 
54
+ def self.find_by_name( name, season: )
55
+ period = nil
56
+ recs = _search.match_by_name( name, season: season )
57
+ # pp m
58
+
59
+ if recs.empty?
60
+ ## fall through/do nothing
61
+ elsif recs.size > 1
62
+ puts "** !!! ERROR - too many (name) matches (#{recs.size}) for league period >#{name}+#{season}<:"
63
+ pp recs
64
+ exit 1
65
+ else
66
+ period = recs[0]
67
+ end
68
+
69
+ period
70
+ end
71
+
72
+ def self.find_by( name: nil, code: nil, season: )
73
+ if code && name.nil?
74
+ find_by_code( code, season: season )
75
+ elsif name && code.nil?
76
+ find_by_name( name, season: season )
77
+ else
78
+ raise ArgumentError, "LeaguePeriod.find_by - one (and only one arg) required - code: or name:"
79
+ end
80
+ end
81
+
82
+
38
83
  def self.find( q, season: )
39
84
  period = nil
40
85
  recs = match( q, season: season )
@@ -52,6 +97,15 @@ class LeaguePeriod
52
97
 
53
98
  period
54
99
  end
100
+
101
+ def self.find!( q, season: )
102
+ period = find( q, season: season )
103
+ if period.nil?
104
+ puts "** !!! ERROR - no league period found for >#{q}+#{season}<, add to leagues table; sorry"
105
+ exit 1
106
+ end
107
+ period
108
+ end
55
109
  end # class LeaguePeriod
56
110
 
57
111
 
@@ -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 = 1
6
+ PATCH = 2
7
7
  VERSION = [MAJOR,MINOR,PATCH].join('.')
8
8
 
9
9
  def self.version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer