sportdb 1.9.7 → 1.9.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +7 -2
- data/lib/sportdb.rb +2 -1
- data/lib/sportdb/reader.rb +9 -2
- data/lib/sportdb/readers/squad_club.rb +194 -0
- data/lib/sportdb/readers/{squad.rb → squad_national_team.rb} +2 -4
- data/lib/sportdb/utils.rb +38 -2
- data/lib/sportdb/utils_map.rb +20 -4
- data/lib/sportdb/version.rb +1 -1
- data/test/data/at-austria/2013_14/squads/austria.txt +40 -0
- data/test/data/at-austria/2013_14/squads/salzburg.txt +35 -0
- data/test/data/players/europe/at-austria/players.txt +45 -0
- data/test/helper.rb +9 -8
- data/test/test_squad_club_reader.rb +76 -0
- data/test/{test_squad_reader.rb → test_squad_national_team_reader.rb} +7 -7
- metadata +43 -37
data/Manifest.txt
CHANGED
@@ -60,7 +60,8 @@ lib/sportdb/readers/game.rb
|
|
60
60
|
lib/sportdb/readers/ground.rb
|
61
61
|
lib/sportdb/readers/league.rb
|
62
62
|
lib/sportdb/readers/season.rb
|
63
|
-
lib/sportdb/readers/
|
63
|
+
lib/sportdb/readers/squad_club.rb
|
64
|
+
lib/sportdb/readers/squad_national_team.rb
|
64
65
|
lib/sportdb/readers/team.rb
|
65
66
|
lib/sportdb/schema.rb
|
66
67
|
lib/sportdb/standings.rb
|
@@ -79,6 +80,8 @@ test/data/at-austria/2013_14/bl.yml
|
|
79
80
|
test/data/at-austria/2013_14/bl_ii.txt
|
80
81
|
test/data/at-austria/2013_14/el.txt
|
81
82
|
test/data/at-austria/2013_14/el.yml
|
83
|
+
test/data/at-austria/2013_14/squads/austria.txt
|
84
|
+
test/data/at-austria/2013_14/squads/salzburg.txt
|
82
85
|
test/data/at-austria/leagues.txt
|
83
86
|
test/data/at-austria/teams.txt
|
84
87
|
test/data/at-austria/teams_2.txt
|
@@ -88,6 +91,7 @@ test/data/national-teams/europe/teams.txt
|
|
88
91
|
test/data/national-teams/north-america/assocs.txt
|
89
92
|
test/data/national-teams/north-america/teams.txt
|
90
93
|
test/data/national-teams/teams.txt
|
94
|
+
test/data/players/europe/at-austria/players.txt
|
91
95
|
test/data/players/europe/de-deutschland/players.txt
|
92
96
|
test/data/players/south-america/br-brazil/players.txt
|
93
97
|
test/data/world-cup/1930/cup.txt
|
@@ -131,7 +135,8 @@ test/test_round_auto.rb
|
|
131
135
|
test/test_round_def.rb
|
132
136
|
test/test_round_header.rb
|
133
137
|
test/test_scores.rb
|
134
|
-
test/
|
138
|
+
test/test_squad_club_reader.rb
|
139
|
+
test/test_squad_national_team_reader.rb
|
135
140
|
test/test_standings.rb
|
136
141
|
test/test_standings_ii.rb
|
137
142
|
test/test_utils.rb
|
data/lib/sportdb.rb
CHANGED
@@ -95,7 +95,8 @@ require 'sportdb/readers/game'
|
|
95
95
|
require 'sportdb/readers/ground'
|
96
96
|
require 'sportdb/readers/league'
|
97
97
|
require 'sportdb/readers/season'
|
98
|
-
require 'sportdb/readers/
|
98
|
+
require 'sportdb/readers/squad_club' # roster
|
99
|
+
require 'sportdb/readers/squad_national_team'
|
99
100
|
require 'sportdb/readers/team'
|
100
101
|
require 'sportdb/reader'
|
101
102
|
|
data/lib/sportdb/reader.rb
CHANGED
@@ -42,6 +42,12 @@ class Reader
|
|
42
42
|
reader = PersonDb::PersonReader.new( include_path )
|
43
43
|
reader.read( name, country_id: country.id )
|
44
44
|
end
|
45
|
+
elsif name =~ /\/squads\/([a-z0-9]{3,})$/ # e.g. ajax.txt bayern.txt etc.
|
46
|
+
## note: for now assume club (e.g. no dash (-) allowed for country code e.g. br-brazil etc.)
|
47
|
+
team = Team.find_by_key!( $1 )
|
48
|
+
## note: pass in @event.id - that is, last seen event (e.g. parsed via GameReader/MatchReader)
|
49
|
+
reader = ClubSquadReader.new( include_path )
|
50
|
+
reader.read( name, team_id: team.id, event_id: @event.id )
|
45
51
|
elsif name =~ /\/squads\/([a-z]{2,3})-[^\/]+$/
|
46
52
|
## fix: add to country matcher new format
|
47
53
|
## name is country! and parent folder is type name e.g. /squads/br-brazil
|
@@ -54,16 +60,17 @@ class Reader
|
|
54
60
|
## not country code (allows multiple teams per country)
|
55
61
|
|
56
62
|
if $1.length == 2
|
63
|
+
## get national team via country
|
57
64
|
country = Country.find_by_key!( $1 )
|
58
65
|
### for now assume country code matches team for now (do NOT forget to downcase e.g. BRA==bra)
|
59
66
|
logger.info " assume country code == team code for #{country.code}"
|
60
67
|
team = Team.find_by_key!( country.code.downcase )
|
61
68
|
else # assume length == 3
|
69
|
+
## get national team directly (use three letter fifa code)
|
62
70
|
team = Team.find_by_key!( $1 )
|
63
71
|
end
|
64
|
-
|
65
|
-
reader = SquadReader.new( include_path )
|
66
72
|
## note: pass in @event.id - that is, last seen event (e.g. parsed via GameReader/MatchReader)
|
73
|
+
reader = NationalTeamSquadReader.new( include_path )
|
67
74
|
reader.read( name, team_id: team.id, event_id: @event.id )
|
68
75
|
elsif name =~ /(?:^|\/)seasons/ # NB: ^seasons or also possible at-austria!/seasons
|
69
76
|
reader = SeasonReader.new( include_path )
|
@@ -0,0 +1,194 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
|
4
|
+
module SportDb
|
5
|
+
|
6
|
+
###
|
7
|
+
# todo/fix: use one squad reader for
|
8
|
+
# national teams and clubs? possible? why? why not?
|
9
|
+
|
10
|
+
|
11
|
+
class ClubSquadReader
|
12
|
+
|
13
|
+
include LogUtils::Logging
|
14
|
+
|
15
|
+
## make models available by default with namespace
|
16
|
+
# e.g. lets you use Usage instead of Model::Usage
|
17
|
+
include Models
|
18
|
+
|
19
|
+
## value helpers e.g. is_year?, is_taglist? etc.
|
20
|
+
include TextUtils::ValueHelper
|
21
|
+
|
22
|
+
include FixtureHelpers
|
23
|
+
|
24
|
+
|
25
|
+
attr_reader :include_path
|
26
|
+
|
27
|
+
|
28
|
+
def initialize( include_path, opts = {} )
|
29
|
+
@include_path = include_path
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def read( name, more_attribs={} )
|
34
|
+
## note:
|
35
|
+
# event_id and team_id required!!
|
36
|
+
|
37
|
+
## todo: move name_real_path code to LineReaderV2 ????
|
38
|
+
pos = name.index( '!/')
|
39
|
+
if pos.nil?
|
40
|
+
name_real_path = name # not found; real path is the same as name
|
41
|
+
else
|
42
|
+
# cut off everything until !/ e.g.
|
43
|
+
# at-austria!/w-wien/beers becomes
|
44
|
+
# w-wien/beers
|
45
|
+
name_real_path = name[ (pos+2)..-1 ]
|
46
|
+
end
|
47
|
+
|
48
|
+
path = "#{include_path}/#{name_real_path}.txt"
|
49
|
+
|
50
|
+
logger.info "parsing data '#{name}' (#{path})..."
|
51
|
+
|
52
|
+
# event
|
53
|
+
@event = Event.find( more_attribs[:event_id] )
|
54
|
+
pp @event
|
55
|
+
|
56
|
+
## note: use @team - share/use in worker method
|
57
|
+
@team = Team.find( more_attribs[:team_id] )
|
58
|
+
pp @team
|
59
|
+
|
60
|
+
### SportDb.lang.lang = LangChecker.new.analyze( name, include_path )
|
61
|
+
|
62
|
+
## mapping tables for persons per country (indexed by country code); reset
|
63
|
+
@country_persons_cache = {}
|
64
|
+
|
65
|
+
reader = LineReader.new( path )
|
66
|
+
|
67
|
+
read_worker( reader )
|
68
|
+
|
69
|
+
Prop.create_from_fixture!( name, path )
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def read_worker( reader )
|
74
|
+
##
|
75
|
+
## fix: use num (optional) for offical jersey number
|
76
|
+
# use pos for internal use only (ordering)
|
77
|
+
|
78
|
+
pos_counter = 999000 # pos counter for undefined players w/o pos
|
79
|
+
|
80
|
+
reader.each_line do |line|
|
81
|
+
logger.debug " line: >#{line}<"
|
82
|
+
|
83
|
+
cut_off_end_of_line_comment!( line )
|
84
|
+
|
85
|
+
pos = find_leading_num!( line )
|
86
|
+
|
87
|
+
if pos.nil?
|
88
|
+
pos_counter+=1 ## e.g. 999001,999002 etc.
|
89
|
+
pos = pos_counter
|
90
|
+
end
|
91
|
+
|
92
|
+
nationality = find_nationality!( line ) # e.g. ARG,AUT,USA,MEX etc. (three-letter country code)
|
93
|
+
|
94
|
+
if nationality.nil?
|
95
|
+
## note: use/assume team's nationality is player's nationality
|
96
|
+
nationality = @team.country.code
|
97
|
+
end
|
98
|
+
|
99
|
+
## note: for now allow lines w/ missing country records in db (used in unit tests)
|
100
|
+
country = Country.find_by_code( nationality )
|
101
|
+
if country.nil?
|
102
|
+
logger.warn "*** no country found for code >#{nationality}< in line: >#{line}<"
|
103
|
+
person_key = nil ## no country, no mapping table - canNOT map person
|
104
|
+
else
|
105
|
+
## try mapping person using country table
|
106
|
+
## cache mapping table by country code
|
107
|
+
|
108
|
+
country_persons = @country_persons_cache[ country.code ]
|
109
|
+
if country_persons.nil?
|
110
|
+
logger.info " persons count for country (#{country.code}): #{country.persons.count}"
|
111
|
+
country_persons = TextUtils.build_title_table_for( country.persons )
|
112
|
+
@country_persons_cache[ country.code ] = country_persons # cache mapping table
|
113
|
+
end
|
114
|
+
|
115
|
+
map_person!( line, country_persons )
|
116
|
+
person_key = find_person!( line )
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
logger.debug " line2: >#{line}<"
|
121
|
+
|
122
|
+
if person_key.nil?
|
123
|
+
## no person match found; try auto-add person
|
124
|
+
logger.info " !! no player match found; try auto-create player"
|
125
|
+
|
126
|
+
buf = line.clone
|
127
|
+
# remove (single match) if line starts w/ - (allow spaces) e.g. | - or |- note: must start line e.g. anchor ^ used
|
128
|
+
buf = buf.sub( /^[ ]*-[ ]*/, '' ) # remove leading dash - for jersey number n/a
|
129
|
+
buf = buf.gsub( /\[[^\]]+\]/, '' ) # remove [POS] or similar
|
130
|
+
buf = buf.sub( '(c)', '' ) # remove captain marker
|
131
|
+
buf = buf.sub( '(vc)', '' ) # remove vice-captain marker
|
132
|
+
### note: uses sub; assumes one pos marker per line
|
133
|
+
buf = buf.sub( /\b(GK|DF|MF|FW)\b/, '' ) # remove position marker
|
134
|
+
# since year/date e.g. 2011- assume one per line
|
135
|
+
# note: use (?= |$) lookahead e.g. must be followed by space or end-of-line
|
136
|
+
buf = buf.sub( /\b\d{4}-?(?= |$)/, '' )
|
137
|
+
buf = buf.strip # remove leading and trailing spaces
|
138
|
+
|
139
|
+
## assume what's left is player name
|
140
|
+
logger.info " player_name >#{buf}<"
|
141
|
+
|
142
|
+
## fix: add auto flag (for auto-created persons/players)
|
143
|
+
## fix: move title_to_key logic to person model etc.
|
144
|
+
person_attribs = {
|
145
|
+
key: TextUtils.title_to_key( buf ),
|
146
|
+
title: buf
|
147
|
+
}
|
148
|
+
|
149
|
+
# note: add country from team or nationality marker
|
150
|
+
if country
|
151
|
+
person_attribs[ :country_id ] = country.id
|
152
|
+
person_attribs[ :nationality_id ] = country.id
|
153
|
+
end
|
154
|
+
|
155
|
+
logger.info " using attribs: #{person_attribs.inspect}"
|
156
|
+
|
157
|
+
person = Person.create!( person_attribs )
|
158
|
+
else
|
159
|
+
person = Person.find_by_key( person_key )
|
160
|
+
|
161
|
+
if person.nil?
|
162
|
+
logger.error " !!!!!! no mapping found for player in line >#{line}< for team #{@team.code} - #{@team.title}"
|
163
|
+
next ## skip further processing of line; can NOT save w/o person; continue w/ next record
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
|
168
|
+
### check if roster record exists
|
169
|
+
roster = Roster.find_by_event_id_and_team_id_and_person_id( @event.id, @team.id, person.id )
|
170
|
+
|
171
|
+
if roster.present?
|
172
|
+
logger.debug "update Roster #{roster.id}:"
|
173
|
+
else
|
174
|
+
logger.debug "create Roster:"
|
175
|
+
roster = Roster.new
|
176
|
+
end
|
177
|
+
|
178
|
+
roster_attribs = {
|
179
|
+
pos: pos,
|
180
|
+
person_id: person.id,
|
181
|
+
team_id: @team.id,
|
182
|
+
event_id: @event.id # NB: reuse/fallthrough from races - make sure load_races goes first (to setup event)
|
183
|
+
}
|
184
|
+
|
185
|
+
logger.debug roster_attribs.to_json
|
186
|
+
|
187
|
+
roster.update_attributes!( roster_attribs )
|
188
|
+
end # lines.each
|
189
|
+
|
190
|
+
end # method read_worker
|
191
|
+
|
192
|
+
|
193
|
+
end # class ClubSquadReader
|
194
|
+
end # module SportDb
|
@@ -1,13 +1,11 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
### fix: change/rename file to squads.rb !!!
|
4
|
-
|
5
3
|
|
6
4
|
module SportDb
|
7
5
|
|
8
6
|
### squad/roster reader for national teams for now
|
9
7
|
|
10
|
-
class
|
8
|
+
class NationalTeamSquadReader
|
11
9
|
|
12
10
|
include LogUtils::Logging
|
13
11
|
|
@@ -165,5 +163,5 @@ class SquadReader
|
|
165
163
|
end # method read_worker
|
166
164
|
|
167
165
|
|
168
|
-
end # class
|
166
|
+
end # class NationTeamSquadReader
|
169
167
|
end # module SportDb
|
data/lib/sportdb/utils.rb
CHANGED
@@ -16,15 +16,51 @@ module SportDb
|
|
16
16
|
|
17
17
|
def cut_off_end_of_line_comment!( line )
|
18
18
|
# cut off (that is, remove) optional end of line comment starting w/ #
|
19
|
-
|
19
|
+
|
20
20
|
line.sub!( /#.*$/ ) do |_|
|
21
21
|
logger.debug " cutting off end of line comment - >>#{$&}<<"
|
22
22
|
''
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
# NB: line = line.sub will NOT work - thus, lets use line.sub!
|
26
26
|
end
|
27
27
|
|
28
|
+
|
29
|
+
def find_nationality!( line )
|
30
|
+
# extract optional nationality - three-letter country code from line e.g. Lionel Messi (ARG)
|
31
|
+
# and return it
|
32
|
+
# NB: side effect - removes num from line string
|
33
|
+
|
34
|
+
regex = /\(([A-Z]{3})\)/ # e.g. (ARG)
|
35
|
+
if line =~ regex
|
36
|
+
logger.debug " nationality: >#{$1}<"
|
37
|
+
|
38
|
+
line.sub!( regex, '[NATIONALITY]' )
|
39
|
+
return $1.to_s
|
40
|
+
else
|
41
|
+
return nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
def find_leading_num!( line )
|
47
|
+
# extract optional leading num from line e.g. 9 Lionel Messi
|
48
|
+
# and return it
|
49
|
+
# NB: side effect - removes num from line string
|
50
|
+
|
51
|
+
# e.g. 9 Lionel Messi - must start line
|
52
|
+
## note: use lookahead (?=) for trailing spaces - do NOT cosume
|
53
|
+
regex = /^[ \t]*(\d{1,3})(?=[ \t]+)/
|
54
|
+
if line =~ regex
|
55
|
+
logger.debug " num: >#{$1}<"
|
56
|
+
|
57
|
+
line.sub!( regex, '[NUM]' )
|
58
|
+
return $1.to_i
|
59
|
+
else
|
60
|
+
return nil
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
28
64
|
def find_leading_pos!( line )
|
29
65
|
# extract optional game pos from line
|
30
66
|
# and return it
|
data/lib/sportdb/utils_map.rb
CHANGED
@@ -9,17 +9,33 @@ module SportDb
|
|
9
9
|
end
|
10
10
|
|
11
11
|
## todo/fix: pass in known_grounds as a parameter? why? why not?
|
12
|
-
|
13
|
-
|
12
|
+
### todo/fix:
|
13
|
+
## remove =nil in para - make param required w/o fallback
|
14
|
+
|
15
|
+
def map_ground!( line, known_grounds=nil )
|
16
|
+
if known_grounds.nil?
|
17
|
+
puts "depreciated API call map_ground! (pass in mapping table as 2nd param)"
|
18
|
+
known_grounds = @known_grounds
|
19
|
+
end
|
20
|
+
|
21
|
+
TextUtils.map_titles_for!( 'ground', line, known_grounds )
|
14
22
|
end
|
15
23
|
|
16
24
|
|
25
|
+
|
17
26
|
def find_person!( line )
|
18
27
|
TextUtils.find_key_for!( 'person', line )
|
19
28
|
end
|
20
29
|
|
21
|
-
|
22
|
-
|
30
|
+
### todo/fix:
|
31
|
+
## remove =nil in para - make param required w/o fallback
|
32
|
+
def map_person!( line, known_persons=nil )
|
33
|
+
if known_persons.nil?
|
34
|
+
puts "depreciated API call map_person! (pass in mapping table as 2nd param)"
|
35
|
+
known_persons = @known_persons
|
36
|
+
end
|
37
|
+
|
38
|
+
TextUtils.map_titles_for!( 'person', line, known_persons )
|
23
39
|
end
|
24
40
|
|
25
41
|
|
data/lib/sportdb/version.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
#################
|
2
|
+
# Austria Wien
|
3
|
+
|
4
|
+
#
|
5
|
+
# sources:
|
6
|
+
# de.wikipedia.org/wiki/FK_Austria_Wien#Bundesligamannschaft
|
7
|
+
|
8
|
+
|
9
|
+
13 Heinz Lindner GK 2009- ## AKA Austria Wien
|
10
|
+
31 Osman Hadzikić (BIH) GK 2014- ## Schwechat
|
11
|
+
77 Tino Casali GK 2014- ## AKA Kärnten
|
12
|
+
|
13
|
+
4 Vanče Šikov (MKD) DF 2014- ## Volyn Lutsk
|
14
|
+
5 Philipp Koblischek DF 2014- ## Austria Amat.
|
15
|
+
8 Jens Stryger Larsen (DEN) DF 2014- ## FC Nordsjælland
|
16
|
+
14 Manuel Ortlechner DF 2009- ## Austria Kärnten
|
17
|
+
15 Christian Ramsebner DF 2013- ## Wr Neustadt
|
18
|
+
18 Sebastian Wimmer DF 2014- ## LASK Linz
|
19
|
+
29 Markus Suttner DF 2008- ## Austria Amat.
|
20
|
+
30 Fabian Koch DF 2011- ## Wacker Innsbruck
|
21
|
+
39 Petar Gluhaković DF ## First Vienna -- check missing ???????
|
22
|
+
|
23
|
+
6 Mario Leitgeb MF 2014- ## Grödig
|
24
|
+
7 Marco Meilinger MF 2014- ## RB Salzburg
|
25
|
+
10 Alexander Grünwald MF 2011- ## Wr Neustadt
|
26
|
+
17 Florian Mader MF 2010- ## SV Ried
|
27
|
+
20 Alexander Gorgon MF 2010- ## Austria Amat.
|
28
|
+
21 Sascha Horvath MF 2013- ## Austria Amat.
|
29
|
+
22 Bernhard Luxbacher MF 2013- ## Stadlau
|
30
|
+
23 David de Paula (ESP) MF 2014- ## Wolfsberger AC
|
31
|
+
25 James Holland (AUS) MF 2012- ## AZ Alkmaar
|
32
|
+
28 Daniel Royer MF 2013- ## Hannover 96 -- check -- 1. FC Köln ??
|
33
|
+
34 Peter Michorl MF 2014- ## Austria Amat.
|
34
|
+
35 Thomas Salamon MF 2014- ## SV Grödig
|
35
|
+
36 Tarkan Serbest MF ## Donau -- check missing ???????
|
36
|
+
|
37
|
+
9 Martin Harrer FW 2014- ## Köflach -- check SCR Altach
|
38
|
+
11 Ola Kamara (NOR) FW 2014- ## SV Ried -- check Strömsgodset IF
|
39
|
+
24 Roman Kienast FW 2012- ## Sturm Graz
|
40
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#############################
|
2
|
+
# FC RB Salzburg
|
3
|
+
|
4
|
+
|
5
|
+
31 Péter Gulácsi (HUN) GK 2013- ## Liverpool
|
6
|
+
33 Alexander Walke (GER) GK 2011- ## Hansa Rostock
|
7
|
+
40 Fabian Bredlow (GER) GK 2014- ## RB Leipzig
|
8
|
+
|
9
|
+
2 Benno Schmitz (GER) DF 2014- ## Bayern München
|
10
|
+
4 Peter Ankersen (DEN) DF 2014- ## Esbjerg Esbjerg
|
11
|
+
5 André Ramalho (BRA) DF 2011- ## RB Brasil
|
12
|
+
6 Christian Schwegler (SUI) DF 2009- ## Young Boys
|
13
|
+
15 Franz Schiemer DF 2009- ## Austria Vienna
|
14
|
+
17 Andreas Ulmer DF 2009- ## SV Ried
|
15
|
+
25 Isaac Vorsah (GHA) DF 2012- ## 1899 Hoffenheim
|
16
|
+
28 Asger Sørensen (DEN) DF 2014- ## FC Midtjylland
|
17
|
+
29 Rodnei (BRA) DF 2012- ## Kaiserslautern
|
18
|
+
36 Martin Hinteregger DF 2010- ## RB Juniors
|
19
|
+
|
20
|
+
10 Sadio Mané (SEN) MF 2012- ## Metz ## check not FW ???
|
21
|
+
13 Stefan Ilsanker MF 2012- ## Mattersburg
|
22
|
+
14 Valon Berisha (NOR) MF 2012- ## Viking
|
23
|
+
21 Taxiarchis Fountas (GRE) MF 2013- ## AEK
|
24
|
+
24 Christoph Leitgeb MF 2007- ## Sturm Graz
|
25
|
+
30 Jodel Dossou (BEN) MF ## Club Africain -- check missing ??
|
26
|
+
37 Valentino Lazaro MF 2012- ## Grazer AK
|
27
|
+
44 Kevin Kampl (SVN) MF 2012- ## VfR Aalen
|
28
|
+
77 Massimo Bruno (BEL) MF 2014- ## RSC Anderlecht
|
29
|
+
|
30
|
+
7 Marcel Sabitzer FW 2014- ## RB Leipzig
|
31
|
+
19 Yordi Reyna (PER) FW ## Alianza Lima -- check missing ??
|
32
|
+
23 Robert Žulj FW ## SV Ried -- check missing ??
|
33
|
+
26 Jonathan Soriano (ESP) FW 2012- ## Barcelona B
|
34
|
+
27 Alan (BRA) FW 2010- ## Fluminense
|
35
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
###################################
|
2
|
+
# Austria / Österreich
|
3
|
+
|
4
|
+
|
5
|
+
### GK Goalkeepers
|
6
|
+
|
7
|
+
Heinz Lindner, 8 Jan 1988
|
8
|
+
Tino Casali, 8 Jan 1988
|
9
|
+
|
10
|
+
### DF Defenders
|
11
|
+
|
12
|
+
Philipp Koblischek, 8 Jan 1988
|
13
|
+
Manuel Ortlechner, 8 Jan 1988
|
14
|
+
Christian Ramsebner, 8 Jan 1988
|
15
|
+
Sebastian Wimmer, 8 Jan 1988
|
16
|
+
Markus Suttner, 8 Jan 1988
|
17
|
+
Fabian Koch, 8 Jan 1988
|
18
|
+
Petar Gluhakovićsing, 8 Jan 1988
|
19
|
+
Franz Schiemer, 8 Jan 1988
|
20
|
+
Andreas Ulmer, 8 Jan 1988
|
21
|
+
Martin Hinteregger, 8 Jan 1988
|
22
|
+
|
23
|
+
### MF Midfielders
|
24
|
+
|
25
|
+
Mario Leitgeb, 8 Jan 1988
|
26
|
+
Marco Meilinger, 8 Jan 1988
|
27
|
+
Alexander Grünwald, 8 Jan 1988
|
28
|
+
Florian Mader, 8 Jan 1988
|
29
|
+
Alexander Gorgon, 8 Jan 1988
|
30
|
+
Sascha Horvath, 8 Jan 1988
|
31
|
+
Bernhard Luxbacher, 8 Jan 1988
|
32
|
+
Daniel Royer, 8 Jan 1988
|
33
|
+
Peter Michorl, 8 Jan 1988
|
34
|
+
Thomas Salamon, 8 Jan 1988
|
35
|
+
Tarkan Serbest, 8 Jan 1988
|
36
|
+
Stefan Ilsanker, 8 Jan 1988
|
37
|
+
Christoph Leitgeb, 8 Jan 1988
|
38
|
+
Valentino Lazaro, 8 Jan 1988
|
39
|
+
|
40
|
+
### FM Forwards
|
41
|
+
|
42
|
+
Martin Harrer, 8 Jan 1988
|
43
|
+
Roman Kienast, 8 Jan 1988
|
44
|
+
Marcel Sabitzer, 8 Jan 1988
|
45
|
+
Robert Žulj, 8 Jan 1988
|
data/test/helper.rb
CHANGED
@@ -45,14 +45,15 @@ AlltimeStandingEntry = SportDb::Model::AlltimeStandingEntry
|
|
45
45
|
####################
|
46
46
|
# Reader shortcuts
|
47
47
|
|
48
|
-
Reader
|
49
|
-
TeamReader
|
50
|
-
AssocReader
|
51
|
-
SeasonReader
|
52
|
-
LeagueReader
|
53
|
-
EventReader
|
54
|
-
GameReader
|
55
|
-
|
48
|
+
Reader = SportDb::Reader
|
49
|
+
TeamReader = SportDb::TeamReader
|
50
|
+
AssocReader = SportDb::AssocReader
|
51
|
+
SeasonReader = SportDb::SeasonReader
|
52
|
+
LeagueReader = SportDb::LeagueReader
|
53
|
+
EventReader = SportDb::EventReader
|
54
|
+
GameReader = SportDb::GameReader
|
55
|
+
NationalTeamSquadReader = SportDb::NationalTeamSquadReader
|
56
|
+
ClubSquadReader = SportDb::ClubSquadReader
|
56
57
|
|
57
58
|
## moved to racing.db - remove/delete!!
|
58
59
|
## RaceTeamReader = SportDb::RaceTeamReader
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_squad_club_reader.rb
|
6
|
+
# or better
|
7
|
+
# rake -I ./lib test
|
8
|
+
|
9
|
+
|
10
|
+
require 'helper'
|
11
|
+
|
12
|
+
class TestSquadClubReader < MiniTest::Unit::TestCase
|
13
|
+
|
14
|
+
def setup
|
15
|
+
WorldDb.delete!
|
16
|
+
SportDb.delete!
|
17
|
+
PersonDb.delete!
|
18
|
+
|
19
|
+
add_bl
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_bl
|
23
|
+
SportDb.read_builtin # add 2013/14 season
|
24
|
+
|
25
|
+
at = Country.create!( key: 'at', name: 'Austria', code: 'AUT', pop: 1, area: 1)
|
26
|
+
|
27
|
+
teamreader = TeamReader.new( SportDb.test_data_path )
|
28
|
+
teamreader.read( 'at-austria/teams', country_id: at.id )
|
29
|
+
|
30
|
+
leaguereader = LeagueReader.new( SportDb.test_data_path )
|
31
|
+
leaguereader.read( 'at-austria/leagues', country_id: at.id )
|
32
|
+
|
33
|
+
gamereader = GameReader.new( SportDb.test_data_path )
|
34
|
+
## check/fix: is country_id more_attribs needed? why? why not?
|
35
|
+
gamereader.read( 'at-austria/2013_14/bl', country_id: at.id )
|
36
|
+
|
37
|
+
bl = Event.find_by_key!( 'at.2013/14' )
|
38
|
+
|
39
|
+
assert_equal 10, bl.teams.count
|
40
|
+
assert_equal 36, bl.rounds.count
|
41
|
+
assert_equal 180, bl.games.count # 36x5 = 180
|
42
|
+
|
43
|
+
## add players
|
44
|
+
## -- read persons
|
45
|
+
personreader = PersonReader.new( SportDb.test_data_path )
|
46
|
+
personreader.read( 'players/europe/at-austria/players', country_id: at.id )
|
47
|
+
|
48
|
+
assert_equal 30, Person.count
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def test_austria
|
53
|
+
austria = Team.find_by_key!( 'austria' )
|
54
|
+
|
55
|
+
event = Event.find_by_key!( 'at.2013/14' )
|
56
|
+
|
57
|
+
reader = ClubSquadReader.new( SportDb.test_data_path )
|
58
|
+
reader.read( 'at-austria/2013_14/squads/austria', team_id: austria.id, event_id: event.id )
|
59
|
+
|
60
|
+
assert_equal 28, Roster.count
|
61
|
+
end # method test_br
|
62
|
+
|
63
|
+
|
64
|
+
def test_salzburg
|
65
|
+
salzburg = Team.find_by_key!( 'salzburg' )
|
66
|
+
|
67
|
+
event = Event.find_by_key!( 'at.2013/14' )
|
68
|
+
|
69
|
+
reader = ClubSquadReader.new( SportDb.test_data_path )
|
70
|
+
reader.read( 'at-austria/2013_14/squads/salzburg', team_id: salzburg.id, event_id: event.id )
|
71
|
+
|
72
|
+
assert_equal 27, Roster.count
|
73
|
+
end # method test_salzburg
|
74
|
+
|
75
|
+
|
76
|
+
end # class TestSquadClubReader
|
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
###
|
4
4
|
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/
|
5
|
+
# ruby -I ./lib -I ./test test/test_squad_national_team_reader.rb
|
6
6
|
# or better
|
7
7
|
# rake -I ./lib test
|
8
8
|
|
9
9
|
|
10
10
|
require 'helper'
|
11
11
|
|
12
|
-
class
|
12
|
+
class TestSquadNationalTeamReader < MiniTest::Unit::TestCase
|
13
13
|
|
14
14
|
def setup
|
15
15
|
WorldDb.delete!
|
@@ -50,7 +50,7 @@ class TestSquadReader < MiniTest::Unit::TestCase
|
|
50
50
|
|
51
51
|
event = Event.find_by_key!( 'world.2014' )
|
52
52
|
|
53
|
-
reader =
|
53
|
+
reader = NationalTeamSquadReader.new( SportDb.test_data_path )
|
54
54
|
reader.read( 'world-cup/2014/squads/br-brazil', team_id: bra.id, event_id: event.id )
|
55
55
|
|
56
56
|
assert_equal 23, Roster.count
|
@@ -70,7 +70,7 @@ class TestSquadReader < MiniTest::Unit::TestCase
|
|
70
70
|
|
71
71
|
event = Event.find_by_key!( 'world.2014' )
|
72
72
|
|
73
|
-
reader =
|
73
|
+
reader = NationalTeamSquadReader.new( SportDb.test_data_path )
|
74
74
|
reader.read( 'world-cup/2014/squads/de-deutschland', team_id: ger.id, event_id: event.id )
|
75
75
|
|
76
76
|
assert_equal 3, Roster.count
|
@@ -87,7 +87,7 @@ class TestSquadReader < MiniTest::Unit::TestCase
|
|
87
87
|
|
88
88
|
event = Event.find_by_key!( 'world.2014' )
|
89
89
|
|
90
|
-
reader =
|
90
|
+
reader = NationalTeamSquadReader.new( SportDb.test_data_path )
|
91
91
|
reader.read( 'world-cup/2014/squads/uy-uruguay', team_id: uru.id, event_id: event.id )
|
92
92
|
|
93
93
|
assert_equal 23, Roster.count
|
@@ -105,7 +105,7 @@ class TestSquadReader < MiniTest::Unit::TestCase
|
|
105
105
|
|
106
106
|
event = Event.find_by_key!( 'world.2014' )
|
107
107
|
|
108
|
-
reader =
|
108
|
+
reader = NationalTeamSquadReader.new( SportDb.test_data_path )
|
109
109
|
reader.read( 'world-cup/2014/squads/jp-japan', team_id: jpn.id, event_id: event.id )
|
110
110
|
|
111
111
|
assert_equal 23, Roster.count
|
@@ -113,4 +113,4 @@ class TestSquadReader < MiniTest::Unit::TestCase
|
|
113
113
|
end # method test_jp
|
114
114
|
|
115
115
|
|
116
|
-
end # class
|
116
|
+
end # class TestSquadNationalTeamReader
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-09-
|
12
|
+
date: 2014-09-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: props
|
16
|
-
requirement: &
|
16
|
+
requirement: &76904160 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *76904160
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: logutils
|
27
|
-
requirement: &
|
27
|
+
requirement: &76903770 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *76903770
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: textutils
|
38
|
-
requirement: &
|
38
|
+
requirement: &76902910 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *76902910
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: worlddb
|
49
|
-
requirement: &
|
49
|
+
requirement: &76902380 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 2.0.2
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *76902380
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: tagutils
|
60
|
-
requirement: &
|
60
|
+
requirement: &76902160 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *76902160
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: persondb
|
71
|
-
requirement: &
|
71
|
+
requirement: &76901930 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *76901930
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: activerecord-utils
|
82
|
-
requirement: &
|
82
|
+
requirement: &76901680 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *76901680
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: fetcher
|
93
|
-
requirement: &
|
93
|
+
requirement: &76901360 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0.3'
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *76901360
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: sportdb-keys
|
104
|
-
requirement: &
|
104
|
+
requirement: &76901140 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *76901140
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: sportdb-console
|
115
|
-
requirement: &
|
115
|
+
requirement: &76900930 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: '0'
|
121
121
|
type: :runtime
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *76900930
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: sportdb-update
|
126
|
-
requirement: &
|
126
|
+
requirement: &76900490 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: '0'
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *76900490
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: sportdb-service
|
137
|
-
requirement: &
|
137
|
+
requirement: &76900190 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ! '>='
|
@@ -142,10 +142,10 @@ dependencies:
|
|
142
142
|
version: '0'
|
143
143
|
type: :runtime
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *76900190
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: gli
|
148
|
-
requirement: &
|
148
|
+
requirement: &76899670 !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
151
151
|
- - ! '>='
|
@@ -153,10 +153,10 @@ dependencies:
|
|
153
153
|
version: 2.5.6
|
154
154
|
type: :runtime
|
155
155
|
prerelease: false
|
156
|
-
version_requirements: *
|
156
|
+
version_requirements: *76899670
|
157
157
|
- !ruby/object:Gem::Dependency
|
158
158
|
name: activerecord
|
159
|
-
requirement: &
|
159
|
+
requirement: &76899430 !ruby/object:Gem::Requirement
|
160
160
|
none: false
|
161
161
|
requirements:
|
162
162
|
- - ! '>='
|
@@ -164,10 +164,10 @@ dependencies:
|
|
164
164
|
version: '0'
|
165
165
|
type: :runtime
|
166
166
|
prerelease: false
|
167
|
-
version_requirements: *
|
167
|
+
version_requirements: *76899430
|
168
168
|
- !ruby/object:Gem::Dependency
|
169
169
|
name: rdoc
|
170
|
-
requirement: &
|
170
|
+
requirement: &76898960 !ruby/object:Gem::Requirement
|
171
171
|
none: false
|
172
172
|
requirements:
|
173
173
|
- - ~>
|
@@ -175,10 +175,10 @@ dependencies:
|
|
175
175
|
version: '4.0'
|
176
176
|
type: :development
|
177
177
|
prerelease: false
|
178
|
-
version_requirements: *
|
178
|
+
version_requirements: *76898960
|
179
179
|
- !ruby/object:Gem::Dependency
|
180
180
|
name: hoe
|
181
|
-
requirement: &
|
181
|
+
requirement: &76887310 !ruby/object:Gem::Requirement
|
182
182
|
none: false
|
183
183
|
requirements:
|
184
184
|
- - ~>
|
@@ -186,7 +186,7 @@ dependencies:
|
|
186
186
|
version: '3.12'
|
187
187
|
type: :development
|
188
188
|
prerelease: false
|
189
|
-
version_requirements: *
|
189
|
+
version_requirements: *76887310
|
190
190
|
description: sportdb - sport.db command line tool
|
191
191
|
email: opensport@googlegroups.com
|
192
192
|
executables:
|
@@ -259,7 +259,8 @@ files:
|
|
259
259
|
- lib/sportdb/readers/ground.rb
|
260
260
|
- lib/sportdb/readers/league.rb
|
261
261
|
- lib/sportdb/readers/season.rb
|
262
|
-
- lib/sportdb/readers/
|
262
|
+
- lib/sportdb/readers/squad_club.rb
|
263
|
+
- lib/sportdb/readers/squad_national_team.rb
|
263
264
|
- lib/sportdb/readers/team.rb
|
264
265
|
- lib/sportdb/schema.rb
|
265
266
|
- lib/sportdb/standings.rb
|
@@ -278,6 +279,8 @@ files:
|
|
278
279
|
- test/data/at-austria/2013_14/bl_ii.txt
|
279
280
|
- test/data/at-austria/2013_14/el.txt
|
280
281
|
- test/data/at-austria/2013_14/el.yml
|
282
|
+
- test/data/at-austria/2013_14/squads/austria.txt
|
283
|
+
- test/data/at-austria/2013_14/squads/salzburg.txt
|
281
284
|
- test/data/at-austria/leagues.txt
|
282
285
|
- test/data/at-austria/teams.txt
|
283
286
|
- test/data/at-austria/teams_2.txt
|
@@ -287,6 +290,7 @@ files:
|
|
287
290
|
- test/data/national-teams/north-america/assocs.txt
|
288
291
|
- test/data/national-teams/north-america/teams.txt
|
289
292
|
- test/data/national-teams/teams.txt
|
293
|
+
- test/data/players/europe/at-austria/players.txt
|
290
294
|
- test/data/players/europe/de-deutschland/players.txt
|
291
295
|
- test/data/players/south-america/br-brazil/players.txt
|
292
296
|
- test/data/world-cup/1930/cup.txt
|
@@ -330,7 +334,8 @@ files:
|
|
330
334
|
- test/test_round_def.rb
|
331
335
|
- test/test_round_header.rb
|
332
336
|
- test/test_scores.rb
|
333
|
-
- test/
|
337
|
+
- test/test_squad_club_reader.rb
|
338
|
+
- test/test_squad_national_team_reader.rb
|
334
339
|
- test/test_standings.rb
|
335
340
|
- test/test_standings_ii.rb
|
336
341
|
- test/test_utils.rb
|
@@ -379,16 +384,17 @@ test_files:
|
|
379
384
|
- test/test_load.rb
|
380
385
|
- test/test_cursor.rb
|
381
386
|
- test/test_standings.rb
|
387
|
+
- test/test_squad_club_reader.rb
|
382
388
|
- test/test_scores.rb
|
383
389
|
- test/test_winner.rb
|
384
390
|
- test/test_standings_ii.rb
|
385
391
|
- test/test_round_def.rb
|
386
392
|
- test/test_utils.rb
|
387
|
-
- test/test_squad_reader.rb
|
388
393
|
- test/test_reader_from_string.rb
|
389
394
|
- test/test_round_header.rb
|
390
395
|
- test/test_round_auto.rb
|
391
396
|
- test/test_goals.rb
|
397
|
+
- test/test_squad_national_team_reader.rb
|
392
398
|
- test/test_reader.rb
|
393
399
|
- test/test_assoc_reader.rb
|
394
400
|
- test/test_changes.rb
|