sportdb-structs 0.3.0 → 0.3.1

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: c966a814cdade0a21ea6453fc1900bfc8c384a8ceecaa34dc158e6d60bfd39b5
4
- data.tar.gz: 5086fb02b42d15da5f93780121de2ba77012de34be0ff51134a06b97136c5f00
3
+ metadata.gz: a3fbeabfa958e34c5c809d3b923d528818f6fac42b7e72165e49d5d77d60314c
4
+ data.tar.gz: 746d77f86ac8f8e1b5f8c8a928ee43a34714707c3dc026627e7322d9db3752df
5
5
  SHA512:
6
- metadata.gz: fb26346fb4a76ced79e7bbb4518e5bcdb26b7128583a17ff963e3b1bc8c2198d41115babfadb06fc9331fb21c5b06059162510961f330cce58dee96aa7e16c17
7
- data.tar.gz: b2d9c498d7cd119637e71b546e84d586329dd6e9186ffaaf8c93d27d5a9e3b2f4b8e1c37a69f09cbdfbc98f94ffb695b632c91c81c35c6c6dddae3c0d60e3c06
6
+ metadata.gz: 0fa12c96f27937106ac161ff8377f7a9a3a1b9ed100d756b87e3cbac82c4f1574a14eb1149a54328368485932d18bb73aa98738a82a59e720c56ec47f5fb3087
7
+ data.tar.gz: 5271fbd2f5a510c44cf13520681397b541afa47481f33f475fe14ea910b5cc21bead7705838d4c0240ad2debab6fb489ae33e7b26e5c4c463e5120f009825203
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.3.0
1
+ ### 0.3.1
2
2
 
3
3
  ### 0.0.1 / 2020-08-24
4
4
 
data/Manifest.txt CHANGED
@@ -4,12 +4,14 @@ README.md
4
4
  Rakefile
5
5
  lib/sportdb/structs.rb
6
6
  lib/sportdb/structs/country.rb
7
+ lib/sportdb/structs/event_info.rb
7
8
  lib/sportdb/structs/goal.rb
8
9
  lib/sportdb/structs/ground.rb
9
10
  lib/sportdb/structs/group.rb
10
11
  lib/sportdb/structs/league.rb
11
12
  lib/sportdb/structs/match.rb
12
13
  lib/sportdb/structs/matchlist.rb
14
+ lib/sportdb/structs/name_helper.rb
13
15
  lib/sportdb/structs/round.rb
14
16
  lib/sportdb/structs/standings.rb
15
17
  lib/sportdb/structs/team.rb
data/README.md CHANGED
@@ -5,7 +5,6 @@
5
5
  * bugs :: [github.com/sportdb/sport.db/issues](https://github.com/sportdb/sport.db/issues)
6
6
  * gem :: [rubygems.org/gems/sportdb-structs](https://rubygems.org/gems/sportdb-structs)
7
7
  * rdoc :: [rubydoc.info/gems/sportdb-structs](http://rubydoc.info/gems/sportdb-structs)
8
- * forum :: [opensport](http://groups.google.com/group/opensport)
9
8
 
10
9
 
11
10
 
data/Rakefile CHANGED
@@ -26,6 +26,6 @@ Hoe.spec 'sportdb-structs' do
26
26
  ]
27
27
 
28
28
  self.spec_extras = {
29
- required_ruby_version: '>= 2.2.2'
29
+ required_ruby_version: '>= 3.1.0'
30
30
  }
31
31
  end
@@ -0,0 +1,65 @@
1
+ module Sports
2
+
3
+ class EventInfo
4
+ ## "high level" info (summary) about event
5
+ ## (like a "wikipedia infobox")
6
+ ## use for checking dataset imports; lets you check e.g.
7
+ ## - dates within range
8
+ ## - number of teams e.g. 20
9
+ ## - matches played e.g. 380
10
+ ## - goals scored e.g. 937
11
+ ## etc.
12
+
13
+ attr_reader :league,
14
+ :season,
15
+ :teams,
16
+ :matches,
17
+ :goals,
18
+ :start_date,
19
+ :end_date
20
+
21
+ def initialize( league:, season:,
22
+ start_date: nil, end_date: nil,
23
+ teams: nil,
24
+ matches: nil,
25
+ goals: nil )
26
+
27
+ @league = league
28
+ @season = season
29
+
30
+ @start_date = start_date
31
+ @end_date = end_date
32
+
33
+ @teams = teams ## todo/check: rename/use teams_count ??
34
+ @matches = matches ## todo/check: rename/use match_count ??
35
+ @goals = goals
36
+ end
37
+
38
+ def include?( date )
39
+ ## todo/fix: add options e.g.
40
+ ## - add delta/off_by_one or such?
41
+ ## - add strict (for) only return true if date range (really) defined (no generic auto-rules)
42
+
43
+ ### note: for now allow off by one error (via timezone/local time errors)
44
+ ## todo/fix: issue warning if off by one!!!!
45
+ if @start_date && @end_date
46
+ date >= (@start_date-1) &&
47
+ date <= (@end_date+1)
48
+ else
49
+ if @season.year?
50
+ # assume generic rule
51
+ ## same year e.g. Jan 1 - Dec 31; always true for now
52
+ date.year == @season.start_year
53
+ else
54
+ # assume generic rule
55
+ ## July 1 - June 30 (Y+1)
56
+ ## - todo/check -start for some countries/leagues in June 1 or August 1 ????
57
+ date >= Date.new( @season.start_year, 7, 1 ) &&
58
+ date <= Date.new( @season.end_year, 6, 30 )
59
+ end
60
+ end
61
+ end # method include?
62
+ alias_method :between?, :include?
63
+ end # class EventInfo
64
+
65
+ end # module Sports
@@ -0,0 +1,87 @@
1
+
2
+ module SportDb
3
+ module NameHelper
4
+
5
+
6
+ ## note: allow placeholder years to e.g. (-___) or (-????)
7
+ ## for marking missing (to be filled in) years
8
+ ## e.g. (1887-1911), (-2013),
9
+ ## (1946-2001, 2013-) etc.
10
+ ## todo/check: make more strict e.g. only accept 4-digit years? - why? why not?
11
+ YEAR_RE = %r{\(
12
+ [0-9, ?_-]+? # note: non-greedy (minimum/first) match
13
+ \)}x
14
+
15
+ def strip_year( name )
16
+ ## check for year(s) e.g. (1887-1911), (-2013),
17
+ ## (1946-2001, 2013-) etc.
18
+ ## todo/check: only sub once (not global) - why? why not?
19
+ name.gsub( YEAR_RE, '' ).strip
20
+ end
21
+
22
+ def has_year?( name ) name =~ YEAR_RE; end
23
+
24
+
25
+ LANG_RE = %r{\[
26
+ [a-z]{1,2} # note also allow single-letter [a] or [d] or [e] - why? why not?
27
+ \]}x
28
+ def strip_lang( name )
29
+ name.gsub( LANG_RE, '' ).strip
30
+ end
31
+
32
+ def has_lang?( name ) name =~ LANG_RE; end
33
+
34
+
35
+ def sanitize( name )
36
+ ## check for year(s) e.g. (1887-1911), (-2013),
37
+ ## (1946-2001,2013-) etc.
38
+ name = strip_year( name )
39
+ ## check lang codes e.g. [en], [fr], etc.
40
+ name = strip_lang( name )
41
+ name
42
+ end
43
+
44
+
45
+ ## note: also add (),’,− etc. e.g.
46
+ ## Estudiantes (LP) => Estudiantes LP
47
+ ## Saint Patrick’s Athletic FC => Saint Patricks Athletic FC
48
+ ## Myllykosken Pallo −47 => Myllykosken Pallo 47
49
+ ##
50
+ ## add & too!!
51
+ ## e.g. Brighton & Hove Albion => Brighton Hove Albion -- and others in England
52
+
53
+ NORM_RE = %r{
54
+ [.'’º/()&_−-]
55
+ }x # note: in [] dash (-) if last doesn't need to get escaped
56
+ ## note: remove all dots (.), dash (-), ', º, /, etc.
57
+ # . U+002E (46) - FULL STOP
58
+ # ' U+0027 (39) - APOSTROPHE
59
+ # ’ U+2019 (8217) - RIGHT SINGLE QUOTATION MARK
60
+ # º U+00BA (186) - MASCULINE ORDINAL INDICATOR
61
+ # / U+002F (47) - SOLIDUS
62
+ # ( U+0028 (40) - LEFT PARENTHESIS
63
+ # ) U+0029 (41) - RIGHT PARENTHESIS
64
+ # − U+2212 (8722) - MINUS SIGN
65
+ # - U+002D (45) - HYPHEN-MINUS
66
+
67
+ ## for norm(alizing) names
68
+ def strip_norm( name )
69
+ name.gsub( NORM_RE, '' )
70
+ end
71
+
72
+ def normalize( name )
73
+ # note: do NOT call sanitize here (keep normalize "atomic" for reuse)
74
+ name = strip_norm( name )
75
+ name = name.gsub( ' ', '' ) # note: also remove all spaces!!!
76
+
77
+ ## todo/check: use our own downcase - why? why not?
78
+ name = downcase_i18n( name ) ## do NOT care about upper and lowercase for now
79
+ name
80
+ end
81
+
82
+
83
+ def variants( name ) Variant.find( name ); end
84
+
85
+ end # module NameHelper
86
+ end # module SportDb
87
+
@@ -4,7 +4,7 @@ module SportDb
4
4
  module Structs
5
5
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
6
6
  MINOR = 3
7
- PATCH = 0
7
+ PATCH = 1
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -21,6 +21,12 @@ require_relative 'structs/matchlist'
21
21
  require_relative 'structs/standings'
22
22
  require_relative 'structs/team_usage'
23
23
 
24
+ require_relative 'structs/event_info'
25
+
26
+
27
+ ## shared support helpers/machinery
28
+ require_relative 'structs/name_helper'
29
+
24
30
 
25
31
  ##
26
32
  ## todo/fix - move "inline" player to structs/player file !!!!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-structs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.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-08-22 00:00:00.000000000 Z
11
+ date: 2024-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alphabets
@@ -102,12 +102,14 @@ files:
102
102
  - Rakefile
103
103
  - lib/sportdb/structs.rb
104
104
  - lib/sportdb/structs/country.rb
105
+ - lib/sportdb/structs/event_info.rb
105
106
  - lib/sportdb/structs/goal.rb
106
107
  - lib/sportdb/structs/ground.rb
107
108
  - lib/sportdb/structs/group.rb
108
109
  - lib/sportdb/structs/league.rb
109
110
  - lib/sportdb/structs/match.rb
110
111
  - lib/sportdb/structs/matchlist.rb
112
+ - lib/sportdb/structs/name_helper.rb
111
113
  - lib/sportdb/structs/round.rb
112
114
  - lib/sportdb/structs/standings.rb
113
115
  - lib/sportdb/structs/team.rb
@@ -127,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
129
  requirements:
128
130
  - - ">="
129
131
  - !ruby/object:Gem::Version
130
- version: 2.2.2
132
+ version: 3.1.0
131
133
  required_rubygems_version: !ruby/object:Gem::Requirement
132
134
  requirements:
133
135
  - - ">="