sportdb-structs 0.2.1 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/Manifest.txt +12 -15
- data/README.md +0 -1
- data/Rakefile +2 -5
- data/lib/sportdb/structs/{structs/country.rb → country.rb} +9 -0
- data/lib/sportdb/structs/event_info.rb +65 -0
- data/lib/sportdb/structs/goal.rb +78 -0
- data/lib/sportdb/structs/{structs/group.rb → group.rb} +4 -4
- data/lib/sportdb/structs/{structs/league.rb → league.rb} +29 -0
- data/lib/sportdb/structs/version.rb +1 -1
- data/lib/sportdb/structs.rb +19 -113
- metadata +15 -60
- data/lib/sportdb/structs/config.rb +0 -39
- data/lib/sportdb/structs/goal_parser_csv.rb +0 -28
- data/lib/sportdb/structs/match_parser_csv.rb +0 -490
- data/lib/sportdb/structs/match_status_parser.rb +0 -90
- data/lib/sportdb/structs/structs/goal.rb +0 -231
- /data/lib/sportdb/structs/{structs/ground.rb → ground.rb} +0 -0
- /data/lib/sportdb/structs/{structs/match.rb → match.rb} +0 -0
- /data/lib/sportdb/structs/{structs/matchlist.rb → matchlist.rb} +0 -0
- /data/lib/sportdb/structs/{structs/round.rb → round.rb} +0 -0
- /data/lib/sportdb/structs/{structs/standings.rb → standings.rb} +0 -0
- /data/lib/sportdb/structs/{structs/team.rb → team.rb} +0 -0
- /data/lib/sportdb/structs/{structs/team_usage.rb → team_usage.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3fbeabfa958e34c5c809d3b923d528818f6fac42b7e72165e49d5d77d60314c
|
4
|
+
data.tar.gz: 746d77f86ac8f8e1b5f8c8a928ee43a34714707c3dc026627e7322d9db3752df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fa12c96f27937106ac161ff8377f7a9a3a1b9ed100d756b87e3cbac82c4f1574a14eb1149a54328368485932d18bb73aa98738a82a59e720c56ec47f5fb3087
|
7
|
+
data.tar.gz: 5271fbd2f5a510c44cf13520681397b541afa47481f33f475fe14ea910b5cc21bead7705838d4c0240ad2debab6fb489ae33e7b26e5c4c463e5120f009825203
|
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
@@ -3,20 +3,17 @@ Manifest.txt
|
|
3
3
|
README.md
|
4
4
|
Rakefile
|
5
5
|
lib/sportdb/structs.rb
|
6
|
-
lib/sportdb/structs/
|
7
|
-
lib/sportdb/structs/
|
8
|
-
lib/sportdb/structs/
|
9
|
-
lib/sportdb/structs/
|
6
|
+
lib/sportdb/structs/country.rb
|
7
|
+
lib/sportdb/structs/event_info.rb
|
8
|
+
lib/sportdb/structs/goal.rb
|
9
|
+
lib/sportdb/structs/ground.rb
|
10
|
+
lib/sportdb/structs/group.rb
|
11
|
+
lib/sportdb/structs/league.rb
|
12
|
+
lib/sportdb/structs/match.rb
|
13
|
+
lib/sportdb/structs/matchlist.rb
|
10
14
|
lib/sportdb/structs/name_helper.rb
|
11
|
-
lib/sportdb/structs/
|
12
|
-
lib/sportdb/structs/
|
13
|
-
lib/sportdb/structs/
|
14
|
-
lib/sportdb/structs/
|
15
|
-
lib/sportdb/structs/structs/league.rb
|
16
|
-
lib/sportdb/structs/structs/match.rb
|
17
|
-
lib/sportdb/structs/structs/matchlist.rb
|
18
|
-
lib/sportdb/structs/structs/round.rb
|
19
|
-
lib/sportdb/structs/structs/standings.rb
|
20
|
-
lib/sportdb/structs/structs/team.rb
|
21
|
-
lib/sportdb/structs/structs/team_usage.rb
|
15
|
+
lib/sportdb/structs/round.rb
|
16
|
+
lib/sportdb/structs/standings.rb
|
17
|
+
lib/sportdb/structs/team.rb
|
18
|
+
lib/sportdb/structs/team_usage.rb
|
22
19
|
lib/sportdb/structs/version.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
@@ -20,15 +20,12 @@ Hoe.spec 'sportdb-structs' do
|
|
20
20
|
self.licenses = ['Public Domain']
|
21
21
|
|
22
22
|
self.extra_deps = [
|
23
|
-
['alphabets', '>= 1.0.
|
24
|
-
['date-formats', '>= 1.0.2'],
|
23
|
+
['alphabets', '>= 1.0.2'],
|
25
24
|
['score-formats', '>= 0.1.1'],
|
26
25
|
['season-formats', '>= 0.0.1'],
|
27
|
-
['csvreader', '>= 1.2.4'],
|
28
|
-
['sportdb-langs', '>= 0.1.1'],
|
29
26
|
]
|
30
27
|
|
31
28
|
self.spec_extras = {
|
32
|
-
required_ruby_version: '>=
|
29
|
+
required_ruby_version: '>= 3.1.0'
|
33
30
|
}
|
34
31
|
end
|
@@ -47,6 +47,15 @@ class Country
|
|
47
47
|
@tags = tags
|
48
48
|
end
|
49
49
|
|
50
|
+
def pretty_print( printer )
|
51
|
+
buf = String.new
|
52
|
+
buf << "<Country: #{@key} - #{@name} (#{@code})"
|
53
|
+
buf << "|#{@alt_names.join('|')}" if @alt_names && !@alt_names.empty?
|
54
|
+
buf << ", #{@tags.join('|')})" if @tags && !@tags.empty?
|
55
|
+
buf << ">"
|
56
|
+
|
57
|
+
printer.text( buf )
|
58
|
+
end
|
50
59
|
end # class Country
|
51
60
|
|
52
61
|
end # module Sports
|
@@ -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,78 @@
|
|
1
|
+
|
2
|
+
module Sports
|
3
|
+
|
4
|
+
class Goal ### nested (non-freestanding) inside match (match is parent)
|
5
|
+
attr_reader :score1,
|
6
|
+
:score2,
|
7
|
+
:team,
|
8
|
+
:player,
|
9
|
+
:minute,
|
10
|
+
:offset,
|
11
|
+
:owngoal,
|
12
|
+
:penalty,
|
13
|
+
:notes
|
14
|
+
|
15
|
+
## add alias for player => name - why? why not?
|
16
|
+
alias_method :name, :player
|
17
|
+
|
18
|
+
|
19
|
+
def owngoal?() @owngoal==true; end
|
20
|
+
def penalty?() @penalty==true; end
|
21
|
+
def team1?() @team == 1; end
|
22
|
+
def team2?() @team == 2; end
|
23
|
+
|
24
|
+
|
25
|
+
## note: make score1,score2 optional for now !!!!
|
26
|
+
def initialize( team:,
|
27
|
+
player:,
|
28
|
+
minute:,
|
29
|
+
offset: nil,
|
30
|
+
owngoal: false,
|
31
|
+
penalty: false,
|
32
|
+
score1: nil,
|
33
|
+
score2: nil,
|
34
|
+
notes: nil
|
35
|
+
)
|
36
|
+
@score1 = score1
|
37
|
+
@score2 = score2
|
38
|
+
|
39
|
+
@team = team # 1 or 2
|
40
|
+
@player = player
|
41
|
+
@minute = minute
|
42
|
+
@offset = offset
|
43
|
+
@owngoal = owngoal
|
44
|
+
@penalty = penalty
|
45
|
+
@notes = notes
|
46
|
+
end
|
47
|
+
|
48
|
+
def state
|
49
|
+
[@score1, @score2,
|
50
|
+
@team,
|
51
|
+
@player, @minute, @offset, @owngoal, @penalty,
|
52
|
+
@notes
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
56
|
+
def ==(o)
|
57
|
+
o.class == self.class && o.state == state
|
58
|
+
end
|
59
|
+
|
60
|
+
def pretty_print( printer )
|
61
|
+
buf = String.new
|
62
|
+
buf << "<Goal: #{@score1 ? @score1 : '?'}-#{@score2 ? @score2 : '?'}"
|
63
|
+
buf << " #{@player} #{@minute}"
|
64
|
+
buf << "+#{@offset}" if @offset && @offset > 0
|
65
|
+
buf << "'"
|
66
|
+
buf << " (o.g.)" if @owngoal
|
67
|
+
buf << " (pen.)" if @penalty
|
68
|
+
buf << " for #{@team}" ### team 1 or 2 - use home/away
|
69
|
+
buf << " -- #{@notes}" if @notes
|
70
|
+
buf << ">"
|
71
|
+
|
72
|
+
printer.text( buf )
|
73
|
+
end
|
74
|
+
end # class Goal
|
75
|
+
|
76
|
+
|
77
|
+
end # module Sports
|
78
|
+
|
@@ -11,14 +11,14 @@ class Group
|
|
11
11
|
@teams = teams
|
12
12
|
end
|
13
13
|
|
14
|
-
def pretty_print( printer )
|
15
|
-
## todo/check - how to display/format key - use () or not - why? why not?
|
14
|
+
def pretty_print( printer )
|
15
|
+
## todo/check - how to display/format key - use () or not - why? why not?
|
16
16
|
buf = String.new
|
17
17
|
buf << "<Group: #{@key ? @key : '?'} - #{@name} "
|
18
18
|
buf << @teams.pretty_print_inspect
|
19
19
|
buf << ">"
|
20
|
-
|
21
|
-
printer.text( buf )
|
20
|
+
|
21
|
+
printer.text( buf )
|
22
22
|
end
|
23
23
|
end # class Group
|
24
24
|
end # module Sports
|
@@ -27,6 +27,35 @@ class League
|
|
27
27
|
alias_method :club?, :clubs?
|
28
28
|
alias_method :national_team?, :national_teams?
|
29
29
|
|
30
|
+
=begin
|
31
|
+
@alt_names=[],
|
32
|
+
@clubs=true,
|
33
|
+
@country=<Country: at - Austria (AUT)|Österreich [de], fifa|uefa)>,
|
34
|
+
@intl=false,
|
35
|
+
@key="at.1",
|
36
|
+
@name="Bundesliga">,
|
37
|
+
=end
|
38
|
+
|
39
|
+
def pretty_print( printer )
|
40
|
+
buf = String.new
|
41
|
+
buf << "<League"
|
42
|
+
buf << " INTL" if @intl
|
43
|
+
buf << if @clubs
|
44
|
+
" CLUBS"
|
45
|
+
else
|
46
|
+
" NATIONAL TEAMS"
|
47
|
+
end
|
48
|
+
buf << ": #{@key} - #{@name}"
|
49
|
+
buf << "|#{@alt_names.join('|')}" if @alt_names && !@alt_names.empty?
|
50
|
+
buf << ", #{@country.name} (#{@country.code})" if @country
|
51
|
+
buf << ">"
|
52
|
+
|
53
|
+
printer.text( buf )
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
30
59
|
end # class League
|
31
60
|
|
32
61
|
end # module Sports
|
data/lib/sportdb/structs.rb
CHANGED
@@ -1,85 +1,38 @@
|
|
1
1
|
## 3rd party gems
|
2
|
-
require 'alphabets' #
|
3
|
-
require 'date/formats' # DateFormats.parse, find!, ...
|
2
|
+
require 'alphabets' # unaccent, downcase_i18n, variants, ...
|
4
3
|
require 'season/formats' # Season.parse, ...
|
5
4
|
require 'score/formats'
|
6
|
-
require 'csvreader'
|
7
|
-
|
8
|
-
|
9
|
-
def read_csv( path, sep: nil,
|
10
|
-
symbolize_names: nil )
|
11
|
-
opts = {}
|
12
|
-
opts[:sep] = sep if sep
|
13
|
-
opts[:header_converters] = :symbol if symbolize_names
|
14
|
-
|
15
|
-
CsvHash.read( path, **opts )
|
16
|
-
end
|
17
|
-
|
18
|
-
def parse_csv( txt, sep: nil,
|
19
|
-
symbolize_names: nil )
|
20
|
-
opts = {}
|
21
|
-
opts[:sep] = sep if sep
|
22
|
-
opts[:header_converters] = :symbol if symbolize_names
|
23
|
-
|
24
|
-
CsvHash.parse( txt, **opts )
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
## more sportdb libs/gems
|
30
|
-
require 'sportdb/langs'
|
31
|
-
|
32
|
-
|
33
|
-
## todo/fix: move shortcut up to sportdb/langs!!!
|
34
|
-
module SportDb
|
35
|
-
Logging = LogUtils::Logging ## logging machinery shortcut; use LogUtils for now
|
36
|
-
end
|
37
|
-
|
38
|
-
## let's put test configuration in its own namespace / module
|
39
|
-
module SportDb
|
40
|
-
class Test ## todo/check: works with module too? use a module - why? why not?
|
41
|
-
|
42
|
-
####
|
43
|
-
# todo/fix: find a better way to configure shared test datasets - why? why not?
|
44
|
-
# note: use one-up (..) directory for now as default - why? why not?
|
45
|
-
def self.data_dir() @data_dir ||= '../test'; end
|
46
|
-
def self.data_dir=( path ) @data_dir = path; end
|
47
|
-
end
|
48
|
-
end # module SportDb
|
49
|
-
|
50
|
-
|
51
|
-
## todo/check: move up config to langs too - why? why not?
|
52
|
-
|
53
|
-
|
54
5
|
|
55
6
|
|
56
7
|
###
|
57
8
|
# our own code
|
58
|
-
|
59
|
-
|
9
|
+
require_relative 'structs/version' # let version always go first
|
10
|
+
|
11
|
+
require_relative 'structs/country'
|
12
|
+
require_relative 'structs/league'
|
13
|
+
require_relative 'structs/team'
|
14
|
+
require_relative 'structs/ground'
|
15
|
+
require_relative 'structs/round'
|
16
|
+
require_relative 'structs/group'
|
17
|
+
require_relative 'structs/goal'
|
18
|
+
require_relative 'structs/match'
|
60
19
|
|
20
|
+
require_relative 'structs/matchlist'
|
21
|
+
require_relative 'structs/standings'
|
22
|
+
require_relative 'structs/team_usage'
|
61
23
|
|
62
|
-
|
24
|
+
require_relative 'structs/event_info'
|
63
25
|
|
64
|
-
require 'sportdb/structs/structs/country'
|
65
|
-
require 'sportdb/structs/structs/league'
|
66
|
-
require 'sportdb/structs/structs/team'
|
67
|
-
require 'sportdb/structs/structs/round'
|
68
|
-
require 'sportdb/structs/structs/group'
|
69
|
-
require 'sportdb/structs/structs/goal'
|
70
|
-
require 'sportdb/structs/structs/match'
|
71
|
-
require 'sportdb/structs/structs/matchlist'
|
72
|
-
require 'sportdb/structs/structs/standings'
|
73
|
-
require 'sportdb/structs/structs/team_usage'
|
74
26
|
|
75
|
-
|
27
|
+
## shared support helpers/machinery
|
28
|
+
require_relative 'structs/name_helper'
|
76
29
|
|
77
30
|
|
78
31
|
##
|
79
32
|
## todo/fix - move "inline" player to structs/player file !!!!
|
80
33
|
|
81
34
|
module Sports
|
82
|
-
### note - own classes for National(Squad)Player and
|
35
|
+
### note - own classes for National(Squad)Player and
|
83
36
|
## Club(Squad)Player and such in use
|
84
37
|
|
85
38
|
class Player
|
@@ -94,7 +47,7 @@ class Player
|
|
94
47
|
|
95
48
|
def initialize( name:,
|
96
49
|
pos: nil,
|
97
|
-
nat: nil,
|
50
|
+
nat: nil,
|
98
51
|
height: nil,
|
99
52
|
birthdate: nil,
|
100
53
|
birthplace: nil )
|
@@ -112,51 +65,6 @@ end # module Sports
|
|
112
65
|
|
113
66
|
|
114
67
|
|
115
|
-
require 'sportdb/structs/match_status_parser'
|
116
|
-
require 'sportdb/structs/match_parser_csv'
|
117
|
-
require 'sportdb/structs/goal_parser_csv'
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
### add convenience shortcut helpers
|
123
|
-
module Sports
|
124
|
-
class Match
|
125
|
-
def self.read_csv( path, headers: nil, filters: nil, converters: nil, sep: nil )
|
126
|
-
SportDb::CsvMatchParser.read( path,
|
127
|
-
headers: headers,
|
128
|
-
filters: filters,
|
129
|
-
converters: converters,
|
130
|
-
sep: sep )
|
131
|
-
end
|
132
|
-
|
133
|
-
def self.parse_csv( txt, headers: nil, filters: nil, converters: nil, sep: nil )
|
134
|
-
SportDb::CsvMatchParser.parse( txt,
|
135
|
-
headers: headers,
|
136
|
-
filters: filters,
|
137
|
-
converters: converters,
|
138
|
-
sep: sep )
|
139
|
-
end
|
140
|
-
end # class Match
|
141
|
-
end # module Sports
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
module Sports
|
146
|
-
## lets you use
|
147
|
-
## Sports.configure do |config|
|
148
|
-
## config.lang = 'it'
|
149
|
-
## end
|
150
|
-
|
151
|
-
## note: just forward to SportDb::Import configuration!!!!!
|
152
|
-
## keep Sports module / namespace "clean"
|
153
|
-
## that is, only include data structures (e.g. Match,League,etc) for now - why? why not?
|
154
|
-
def self.configure() yield( config ); end
|
155
|
-
def self.config() SportDb::Import.config; end
|
156
|
-
end # module Sports
|
157
|
-
|
158
|
-
|
159
|
-
|
160
68
|
#####
|
161
69
|
# note: add Sport and Football convenience alias - why? why not?
|
162
70
|
Sport = Sports
|
@@ -165,7 +73,5 @@ Football = Sports
|
|
165
73
|
|
166
74
|
|
167
75
|
|
168
|
-
|
169
76
|
puts SportDb::Module::Structs.banner # say hello
|
170
77
|
|
171
|
-
|
metadata
CHANGED
@@ -1,31 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-structs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 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-
|
11
|
+
date: 2024-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alphabets
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.0
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 1.0.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: date-formats
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
17
|
- - ">="
|
@@ -66,34 +52,6 @@ dependencies:
|
|
66
52
|
- - ">="
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: 0.0.1
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: csvreader
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 1.2.4
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 1.2.4
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: sportdb-langs
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.1.1
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.1.1
|
97
55
|
- !ruby/object:Gem::Dependency
|
98
56
|
name: rdoc
|
99
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,22 +101,19 @@ files:
|
|
143
101
|
- README.md
|
144
102
|
- Rakefile
|
145
103
|
- lib/sportdb/structs.rb
|
146
|
-
- lib/sportdb/structs/
|
147
|
-
- lib/sportdb/structs/
|
148
|
-
- lib/sportdb/structs/
|
149
|
-
- lib/sportdb/structs/
|
104
|
+
- lib/sportdb/structs/country.rb
|
105
|
+
- lib/sportdb/structs/event_info.rb
|
106
|
+
- lib/sportdb/structs/goal.rb
|
107
|
+
- lib/sportdb/structs/ground.rb
|
108
|
+
- lib/sportdb/structs/group.rb
|
109
|
+
- lib/sportdb/structs/league.rb
|
110
|
+
- lib/sportdb/structs/match.rb
|
111
|
+
- lib/sportdb/structs/matchlist.rb
|
150
112
|
- lib/sportdb/structs/name_helper.rb
|
151
|
-
- lib/sportdb/structs/
|
152
|
-
- lib/sportdb/structs/
|
153
|
-
- lib/sportdb/structs/
|
154
|
-
- lib/sportdb/structs/
|
155
|
-
- lib/sportdb/structs/structs/league.rb
|
156
|
-
- lib/sportdb/structs/structs/match.rb
|
157
|
-
- lib/sportdb/structs/structs/matchlist.rb
|
158
|
-
- lib/sportdb/structs/structs/round.rb
|
159
|
-
- lib/sportdb/structs/structs/standings.rb
|
160
|
-
- lib/sportdb/structs/structs/team.rb
|
161
|
-
- lib/sportdb/structs/structs/team_usage.rb
|
113
|
+
- lib/sportdb/structs/round.rb
|
114
|
+
- lib/sportdb/structs/standings.rb
|
115
|
+
- lib/sportdb/structs/team.rb
|
116
|
+
- lib/sportdb/structs/team_usage.rb
|
162
117
|
- lib/sportdb/structs/version.rb
|
163
118
|
homepage: https://github.com/sportdb/sport.db
|
164
119
|
licenses:
|
@@ -174,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
174
129
|
requirements:
|
175
130
|
- - ">="
|
176
131
|
- !ruby/object:Gem::Version
|
177
|
-
version:
|
132
|
+
version: 3.1.0
|
178
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
134
|
requirements:
|
180
135
|
- - ">="
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module SportDb
|
2
|
-
module Import
|
3
|
-
|
4
|
-
class Configuration
|
5
|
-
##
|
6
|
-
## todo: allow configure of countries_dir like clubs_dir
|
7
|
-
## "fallback" and use a default built-in world/countries.txt
|
8
|
-
|
9
|
-
## note: catalog defined/added in sports-catalogs gem!!!
|
10
|
-
## attr_accessor :catalog
|
11
|
-
|
12
|
-
attr_reader :lang
|
13
|
-
def lang=(value)
|
14
|
-
## check/todo: always use to_sym - why? needed?
|
15
|
-
DateFormats.lang = value
|
16
|
-
ScoreFormats.lang = value
|
17
|
-
SportDb.lang.lang = value
|
18
|
-
|
19
|
-
## todo/fix: change SportDb.lang to SportDb.parser.lang
|
20
|
-
## or lang_parser or utils or someting !!!!
|
21
|
-
## use Sport.lang only as a read-only shortcut
|
22
|
-
# a la catalog for config.lang!!!!
|
23
|
-
end
|
24
|
-
|
25
|
-
end # class Configuration
|
26
|
-
|
27
|
-
|
28
|
-
## lets you use
|
29
|
-
## SportDb::Import.configure do |config|
|
30
|
-
## config.lang = 'it'
|
31
|
-
## end
|
32
|
-
def self.configure() yield( config ); end
|
33
|
-
|
34
|
-
def self.config() @config ||= Configuration.new; end
|
35
|
-
|
36
|
-
|
37
|
-
end # module Import
|
38
|
-
end # module SportDb
|
39
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
|
2
|
-
module SportDb
|
3
|
-
class CsvGoalParser
|
4
|
-
|
5
|
-
|
6
|
-
def self.read( path )
|
7
|
-
txt = File.open( path, 'r:utf-8' ) {|f| f.read } ## note: make sure to use (assume) utf-8
|
8
|
-
parse( txt )
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.parse( txt )
|
12
|
-
new( txt ).parse
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
def initialize( txt )
|
17
|
-
@txt = txt
|
18
|
-
end
|
19
|
-
|
20
|
-
def parse
|
21
|
-
rows = parse_csv( @txt )
|
22
|
-
recs = rows.map { |row| Sports::GoalEvent.build( row ) }
|
23
|
-
## pp recs[0]
|
24
|
-
recs
|
25
|
-
end
|
26
|
-
|
27
|
-
end # class CsvGoalParser
|
28
|
-
end # module Sports
|