sportdb-formats 0.3.0 → 0.4.0

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
  SHA1:
3
- metadata.gz: 4ebc60eb9651185cf5aa0ba1c7707fc8678f7803
4
- data.tar.gz: 67d24f30f4a8586f54ea73135fd58239420e1e22
3
+ metadata.gz: 7bd2657cda87fd1024bec068f79453d73b0bbac5
4
+ data.tar.gz: 7c35301f832b66bf691c9d1964de00c9a9b2371d
5
5
  SHA512:
6
- metadata.gz: 6c2fdcdf34f4ea95ee765d1b1cfedd9aef84787836fb7fb2c21c10d4000e3b8417109f5ec9ce4d5ae552a0a63d5e91a9c976847fd33b175cccad5aa4d5ea4762
7
- data.tar.gz: 4ef8c4ba7538c738e2c44b6f16aafbdc11d640485ecf99a603a764c069b038e290ea320918ec16ecd3405f321e6b4bba5f8b350c6835c5f3a70808954da93350
6
+ metadata.gz: 90ef6ad29934fc9bb692045d9f5e2a447a2dcaf80ab8ca0a3e1b50ae34e95bae7a139e88ef454314c0a26bc978784abb6abd117bf1961e71c65a95046d21efe1
7
+ data.tar.gz: 73e55608b287d974d40c4529c3f104496acde866dc3908509adcee6ed8a40dc0f10f8e48f193cd6184ef29c31bdfa3ebd9eb38a38c85924dde207cc0433ea318
data/Manifest.txt CHANGED
@@ -10,8 +10,11 @@ lib/sportdb/formats/package.rb
10
10
  lib/sportdb/formats/scores.rb
11
11
  lib/sportdb/formats/season_utils.rb
12
12
  lib/sportdb/formats/structs/club.rb
13
+ lib/sportdb/formats/structs/country.rb
14
+ lib/sportdb/formats/structs/league.rb
13
15
  lib/sportdb/formats/structs/match.rb
14
16
  lib/sportdb/formats/structs/matchlist.rb
17
+ lib/sportdb/formats/structs/round.rb
15
18
  lib/sportdb/formats/structs/season.rb
16
19
  lib/sportdb/formats/structs/standings.rb
17
20
  lib/sportdb/formats/structs/team_usage.rb
@@ -3,18 +3,10 @@
3
3
  module SportDb
4
4
  module Import
5
5
 
6
- ##
7
- # note: use our own (internal) club struct for now - why? why not?
8
- # - check that shape/structure/fields/attributes match
9
- # the Team struct in sportdb-text (in SportDb::Struct::Team) !!!!
10
-
11
-
12
- ## more attribs - todo/fix - also add "upstream" to struct & model!!!!!
6
+ ########
7
+ # more attribs - todo/fix - also add "upstream" to struct & model!!!!!
13
8
  # district, geos, year_end, country, etc.
14
9
 
15
-
16
-
17
-
18
10
  class Club
19
11
 
20
12
  def self.create( **kwargs )
@@ -22,9 +14,9 @@ class Club
22
14
  end
23
15
 
24
16
  def update( **kwargs )
25
- @name = kwargs[:name] if kwargs.has_key?( :name )
26
- @alt_names = kwargs[:alt_names] if kwargs.has_key?( :alt_names )
27
- @city = kwargs[:city] if kwargs.has_key?( :city )
17
+ @name = kwargs[:name] if kwargs.has_key? :name
18
+ @alt_names = kwargs[:alt_names] if kwargs.has_key? :alt_names
19
+ @city = kwargs[:city] if kwargs.has_key? :city
28
20
  ## todo/fix: use city struct - why? why not?
29
21
  ## todo/fix: add country too or report unused keywords / attributes - why? why not?
30
22
 
@@ -0,0 +1,70 @@
1
+ # encoding: utf-8
2
+
3
+ module SportDb
4
+ module Import
5
+
6
+ ##
7
+ # note: check that shape/structure/fields/attributes match
8
+ # the ActiveRecord model !!!!
9
+
10
+ class Country
11
+
12
+ ## note: is read-only/immutable for now - why? why not?
13
+ ## add cities (array/list) - why? why not?
14
+ attr_reader :key, :name, :fifa, :tags
15
+ attr_accessor :alt_names
16
+
17
+ def initialize( key:, name:, fifa:, tags: [] )
18
+ @key, @name, @fifa = key, name, fifa
19
+ @alt_names = []
20
+ @tags = tags
21
+ end
22
+
23
+ ## add csv-like access by hash key for compatibility - why? why not? - check where used? remove!!!
24
+ def []( key ) send( key ); end
25
+
26
+
27
+ ###################################
28
+ # "global" helper - move to ___ ? why? why not?
29
+ ## todo/fix: use shared helpers for country, club, etc. (do NOT duplicate)!!!
30
+ YEAR_REGEX = /\([0-9,\- ]+?\)/
31
+ def self.strip_year( name )
32
+ ## check for year(s) e.g. (1887-1911), (-2013),
33
+ ## (1946-2001, 2013-) etc.
34
+ name.gsub( YEAR_REGEX, '' ).strip
35
+ end
36
+
37
+ def self.has_year?( name ) name =~ YEAR_REGEX; end
38
+
39
+ LANG_REGEX = /\[[a-z]{1,2}\]/ ## note also allow [a] or [d] or [e] - why? why not?
40
+ def self.strip_lang( name )
41
+ name.gsub( LANG_REGEX, '' ).strip
42
+ end
43
+
44
+ def self.has_lang?( name ) name =~ LANG_REGEX; end
45
+
46
+
47
+ NORM_REGEX = /[.'º\-\/]/
48
+ ## note: remove all dots (.), dash (-), ', º, /, etc.
49
+ ## for norm(alizing) names
50
+ def self.strip_norm( name )
51
+ name.gsub( NORM_REGEX, '' )
52
+ end
53
+
54
+ def self.normalize( name )
55
+ # note: do NOT call sanitize here (keep normalize "atomic" for reuse)
56
+
57
+ ## remove all dots (.), dash (-), º, /, etc.
58
+ name = strip_norm( name )
59
+ name = name.gsub( ' ', '' ) # note: also remove all spaces!!!
60
+
61
+ ## todo/fix: use our own downcase - why? why not?
62
+ name = downcase_i18n( name ) ## do NOT care about upper and lowercase for now
63
+ name
64
+ end
65
+ end # class Country
66
+
67
+
68
+ end # module Import
69
+ end # module SportDb
70
+
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+
3
+ module SportDb
4
+ module Import
5
+
6
+ class League
7
+ attr_reader :key, :name, :country, :intl
8
+ attr_accessor :alt_names
9
+
10
+ ## special import only attribs
11
+ attr_accessor :alt_names_auto ## auto-generated alt names
12
+
13
+ def initialize( key:, name:, alt_names: [], alt_names_auto: [],
14
+ country: nil, intl: false )
15
+ @key = key
16
+ @name = name
17
+ @alt_names = alt_names
18
+ @alt_names_auto = alt_names_auto
19
+ @country = country
20
+ @intl = intl
21
+ end
22
+
23
+ def intl?() @intl == true; end
24
+ def national?() @intl == false; end
25
+ alias_method :domestic?, :national?
26
+
27
+
28
+
29
+ ## todo/fix: (re)use helpers from clubs - how? why? why not?
30
+ LANG_REGEX = /\[[a-z]{1,2}\]/ ## note also allow [a] or [d] or [e] - why? why not?
31
+ def self.strip_lang( name )
32
+ name.gsub( LANG_REGEX, '' ).strip
33
+ end
34
+
35
+ NORM_REGEX = /[.'º\-\/]/
36
+ ## note: remove all dots (.), dash (-), ', º, /, etc.
37
+ ## for norm(alizing) names
38
+ def self.strip_norm( name )
39
+ name.gsub( NORM_REGEX, '' )
40
+ end
41
+
42
+ def self.normalize( name )
43
+ # note: do NOT call sanitize here (keep normalize "atomic" for reuse)
44
+
45
+ ## remove all dots (.), dash (-), º, /, etc.
46
+ name = strip_norm( name )
47
+ name = name.gsub( ' ', '' ) # note: also remove all spaces!!!
48
+
49
+ ## todo/fix: use our own downcase - why? why not?
50
+ name = downcase_i18n( name ) ## do NOT care about upper and lowercase for now
51
+ name
52
+ end
53
+ end # class League
54
+
55
+ end # module Import
56
+ end # module SportDb
@@ -1,8 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- ##
4
- # note: add all "former" structs to the SportDb::Import module / namespace
5
-
6
3
  module SportDb
7
4
  module Import
8
5
 
@@ -16,8 +13,11 @@ class Match
16
13
  def update( **kwargs )
17
14
  ## note: check with has_key? because value might be nil!!!
18
15
  @date = kwargs[:date] if kwargs.has_key? :date
16
+
17
+ ## todo/fix: use team1_name, team2_name or similar - for compat with db activerecord version? why? why not?
19
18
  @team1 = kwargs[:team1] if kwargs.has_key? :team1
20
19
  @team2 = kwargs[:team2] if kwargs.has_key? :team2
20
+
21
21
  @conf1 = kwargs[:conf1] if kwargs.has_key? :conf1
22
22
  @conf2 = kwargs[:conf2] if kwargs.has_key? :conf2
23
23
  @country1 = kwargs[:country1] if kwargs.has_key? :country1
@@ -124,8 +124,7 @@ class Match
124
124
  def scorei_str # pretty print (half time) scores; convenience method
125
125
  "#{@score1i}-#{@score2i}"
126
126
  end
127
-
128
127
  end # class Match
129
- end # module Import
130
128
 
129
+ end # module Import
131
130
  end # module SportDb
@@ -1,9 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
 
4
- ##
5
- # note: add all "former" structs to the SportDb::Import module / namespace
6
-
7
4
  module SportDb
8
5
  module Import
9
6
 
@@ -0,0 +1,22 @@
1
+ module SportDb
2
+ module Import
3
+
4
+ class Round
5
+ attr_reader :pos, :title
6
+
7
+ ##
8
+ ## todo: change db schema
9
+ ## make start and end date optional
10
+ ## change pos to num - why? why not?
11
+ ## make pos/num optional too
12
+ ##
13
+ ## sort round by scheduled/planed start date
14
+ def initialize( pos:, title: )
15
+ @pos = pos
16
+ @title = title
17
+ end
18
+ end # class Round
19
+
20
+ end # module Import
21
+ end # module SportDb
22
+
@@ -1,9 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
 
4
- ##
5
- # note: add all "former" structs to the SportDb::Import module / namespace
6
-
7
4
  module SportDb
8
5
  module Import
9
6
 
@@ -6,9 +6,6 @@
6
6
  ## do NOT duplicate
7
7
 
8
8
 
9
- ##
10
- # note: add all "former" structs to the SportDb::Import module / namespace
11
-
12
9
  module SportDb
13
10
  module Import
14
11
 
@@ -1,9 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
 
4
- ##
5
- # note: add all "former" structs to the SportDb::Import module / namespace
6
-
7
4
  module SportDb
8
5
  module Import
9
6
 
@@ -5,7 +5,7 @@ module SportDb
5
5
  module Formats
6
6
 
7
7
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
8
- MINOR = 3
8
+ MINOR = 4
9
9
  PATCH = 0
10
10
  VERSION = [MAJOR,MINOR,PATCH].join('.')
11
11
 
@@ -31,8 +31,11 @@ require 'sportdb/formats/datafile'
31
31
  require 'sportdb/formats/package'
32
32
  require 'sportdb/formats/season_utils'
33
33
 
34
+ require 'sportdb/formats/structs/country'
34
35
  require 'sportdb/formats/structs/season'
36
+ require 'sportdb/formats/structs/league'
35
37
  require 'sportdb/formats/structs/club'
38
+ require 'sportdb/formats/structs/round'
36
39
  require 'sportdb/formats/structs/match'
37
40
  require 'sportdb/formats/structs/matchlist'
38
41
  require 'sportdb/formats/structs/standings'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-formats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-18 00:00:00.000000000 Z
11
+ date: 2020-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alphabets
@@ -129,8 +129,11 @@ files:
129
129
  - lib/sportdb/formats/scores.rb
130
130
  - lib/sportdb/formats/season_utils.rb
131
131
  - lib/sportdb/formats/structs/club.rb
132
+ - lib/sportdb/formats/structs/country.rb
133
+ - lib/sportdb/formats/structs/league.rb
132
134
  - lib/sportdb/formats/structs/match.rb
133
135
  - lib/sportdb/formats/structs/matchlist.rb
136
+ - lib/sportdb/formats/structs/round.rb
134
137
  - lib/sportdb/formats/structs/season.rb
135
138
  - lib/sportdb/formats/structs/standings.rb
136
139
  - lib/sportdb/formats/structs/team_usage.rb