sportdb-search 0.2.1 → 0.2.3

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: d4032ac46170ffc3f434ccc3682f94b8668bf0b64c7106fde1a07283ebc181a0
4
+ data.tar.gz: 65682e318410b6c3ca88814463e1650a18480a19de61c0b3cabd5b50ae30f9bc
5
5
  SHA512:
6
- metadata.gz: ac5ebf7ea6e41ab2466bb70dd96db6cb2ef07c92539d7c3131be57bdbd600120d6a41927e493ed5a5069276b876398058be3c10a09c804498f07e57d450832a3
7
- data.tar.gz: 193911ab634b2435c63979a14164a1b5e46a1cd9288a7459dc5e1e54c0e7e81bb0001e494226878f25d98345157632f5d7c34baaf6a240de0b40a9d0d1bd9a63
6
+ metadata.gz: cd189b4381573306de40eec4047288f6ee1b1ee560211759c68c91a6ad93c327bec54fc328922c1a182423184a895c59d3df881cc96a95fda190055490cd7a6d
7
+ data.tar.gz: f368f483bf43acb2faf2454008fdcc164d83948fdc286876c07888f1e2580d5f0c4b9d1eb5a20daec145a98c350200c46fdf588500ba6652e1c783570f7ccc03
data/CHANGELOG.md CHANGED
@@ -1,5 +1,4 @@
1
- ### 0.2.1
2
-
1
+ ### 0.2.3
3
2
  ### 0.0.1 / 2024-08-25
4
3
 
5
4
  * Everything is new. First release.
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ Hoe.spec 'sportdb-search' do
20
20
  self.licenses = ['Public Domain']
21
21
 
22
22
  self.extra_deps = [
23
- ['sportdb-catalogs', '>= 1.2.3'],
23
+ ['sportdb-catalogs', '>= 1.2.6'],
24
24
  ]
25
25
 
26
26
  self.spec_extras = {
data/bin/fbq CHANGED
@@ -14,7 +14,7 @@ require 'optparse'
14
14
 
15
15
  ## local hack
16
16
  ## if exists up-to-date catalog db (use local version NOT built-in)
17
- catalog_path = '../catalog/catalog.db'
17
+ catalog_path = '/sports/sportdb/sport.db/catalog/catalog.db'
18
18
  if File.exist?( catalog_path )
19
19
  SportDb::Import.config.catalog_path = catalog_path
20
20
  end
@@ -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
 
@@ -60,12 +114,25 @@ class League
60
114
 
61
115
  ###################
62
116
  ## core required delegates - use delegate generator - why? why not?
63
- def self.match_by( name: nil, code: nil, country: nil )
64
- ## todo/fix upstream - remove "generic" match_by() - why? why not?
65
- ###
66
- if code && name.nil?
67
- _search.match_by_code( code, country: country )
68
- elsif name && code.nil?
117
+ def self.match_by( name: nil, code: nil,
118
+ country: nil,
119
+ season: nil )
120
+ ## todo/fix upstream - remove "generic" match_by() - why? why not?
121
+ ##
122
+ if code && name.nil?
123
+ ### todo/fix - simplify - why? why not?
124
+ ## remove country from code match query
125
+ ## assume use country prefixes or are unique
126
+ ## e.g. Premier Leaguge is eng.1 or eng.pl etc. not just pl
127
+ ## Bundesliga is de.1 or de.bl etc not just bl
128
+ ## and so on
129
+ if country
130
+ ## add deprecated warning - why? why not?
131
+ puts "[deprecated] do NOT use country param for League.match_by_code; will get reomved"
132
+ end
133
+ _search.match_by_code( code, country: country,
134
+ season: season )
135
+ elsif name && code.nil? && season.nil? # note - season only supported for code for now
69
136
  _search.match_by_name( name, country: country )
70
137
  else
71
138
  raise ArgumentError, "League.match_by - one (and only one arg) required - code: or name:"
@@ -55,8 +55,18 @@ end # class NationalTeam
55
55
  if mods && mods[ league.key ] && mods[ league.key ][ name ]
56
56
  mods[ league.key ][ name ]
57
57
  else
58
+ ### quick hack
59
+ ## rename more placeholder teams to N.N.
60
+ name = 'N.N.' if ['Verlierer HF 1',
61
+ 'Verlierer HF 2'].include?(name)
62
+
58
63
  if league.clubs?
59
- if league.intl? ## todo/fix: add intl? to ActiveRecord league!!!
64
+
65
+ ## check for placeholder/global dummy clubs first
66
+ if ['N.N.', 'N. N.'].include?( name )
67
+ Club.find!( name )
68
+ else
69
+ if league.intl? ## todo/fix: add intl? to ActiveRecord league!!!
60
70
  ###
61
71
  ## get country code from name
62
72
  ## e.g. Liverpool FC (ENG) or
@@ -72,7 +82,7 @@ end # class NationalTeam
72
82
  ## todo/fix: add auto flag!!!!
73
83
  ### like in rounds!!!
74
84
  ## to track auto-created clubs
75
- rec = Club.new( name: m[:name] )
85
+ rec = Club.new( name: m[:name], auto: true )
76
86
  rec.country = Country.find_by( code: m[:code] ) ## fix: country kwarg not yet supported!!
77
87
  pp rec
78
88
  end
@@ -93,11 +103,12 @@ end # class NationalTeam
93
103
  ## todo/fix: add auto flag!!!!
94
104
  ### like in rounds!!!
95
105
  ## to track auto-created clubs
96
- rec = Club.new( name: name )
106
+ rec = Club.new( name: name, auto: true )
97
107
  rec.country = league.country ## fix: country kwarg not yet supported!!
98
108
  pp rec
99
109
  end
100
110
  rec
111
+ end
101
112
  end
102
113
  else ## assume national teams (not clubs)
103
114
  NationalTeam.find!( name )
@@ -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 = 3
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.1
4
+ version: 0.2.3
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-21 00:00:00.000000000 Z
11
+ date: 2025-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sportdb-catalogs
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.3
19
+ version: 1.2.6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.3
26
+ version: 1.2.6
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rdoc
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '4.1'
53
+ version: '4.2'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '4.1'
60
+ version: '4.2'
61
61
  description: sportdb-search - find national teams, clubs, leagues & more
62
62
  email: gerald.bauer@gmail.com
63
63
  executables:
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubygems_version: 3.4.10
106
+ rubygems_version: 3.5.22
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: sportdb-search - find national teams, clubs, leagues & more