sportdb 1.8.23 → 1.8.24

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -54,9 +54,10 @@ lib/sportdb/readers/event.rb
54
54
  lib/sportdb/readers/game.rb
55
55
  lib/sportdb/readers/ground.rb
56
56
  lib/sportdb/readers/league.rb
57
+ lib/sportdb/readers/national_team.rb
57
58
  lib/sportdb/readers/race.rb
59
+ lib/sportdb/readers/race_team.rb
58
60
  lib/sportdb/readers/record.rb
59
- lib/sportdb/readers/roster.rb
60
61
  lib/sportdb/readers/season.rb
61
62
  lib/sportdb/readers/team.rb
62
63
  lib/sportdb/readers/track.rb
@@ -110,6 +111,8 @@ test/data/at-austria/2013_14/el.yml
110
111
  test/data/at-austria/leagues.txt
111
112
  test/data/at-austria/teams.txt
112
113
  test/data/at-austria/teams_2.txt
114
+ test/data/players/europe/de-deutschland/players.txt
115
+ test/data/players/south-america/br-brazil/players.txt
113
116
  test/data/world-cup/1930/cup.txt
114
117
  test/data/world-cup/1930/cup.yml
115
118
  test/data/world-cup/1954/cup.txt
@@ -120,6 +123,10 @@ test/data/world-cup/1974/cup.yml
120
123
  test/data/world-cup/1974/cup_finals.txt
121
124
  test/data/world-cup/1974/cup_i.txt
122
125
  test/data/world-cup/1974/cup_ii.txt
126
+ test/data/world-cup/2014/cup.txt
127
+ test/data/world-cup/2014/cup.yml
128
+ test/data/world-cup/2014/squads/br-brazil.txt
129
+ test/data/world-cup/2014/squads/de-deutschland.txt
123
130
  test/data/world-cup/leagues.txt
124
131
  test/data/world-cup/seasons_1930.txt
125
132
  test/data/world-cup/seasons_1954.txt
@@ -134,6 +141,8 @@ test/test_changes.rb
134
141
  test/test_cursor.rb
135
142
  test/test_date.rb
136
143
  test/test_lang.rb
144
+ test/test_load.rb
145
+ test/test_national_team_reader.rb
137
146
  test/test_reader.rb
138
147
  test/test_round_auto.rb
139
148
  test/test_round_def.rb
data/bin/sportdb CHANGED
File without changes
data/lib/sportdb.rb CHANGED
@@ -95,7 +95,8 @@ require 'sportdb/readers/ground'
95
95
  require 'sportdb/readers/league'
96
96
  require 'sportdb/readers/race'
97
97
  require 'sportdb/readers/record'
98
- require 'sportdb/readers/roster'
98
+ require 'sportdb/readers/race_team'
99
+ require 'sportdb/readers/national_team'
99
100
  require 'sportdb/readers/season'
100
101
  require 'sportdb/readers/team'
101
102
  require 'sportdb/readers/track'
@@ -73,27 +73,40 @@ class Reader
73
73
  reader = TrackReader.new( include_path )
74
74
  reader.read( name )
75
75
  elsif name =~ /^drivers/ # e.g. drivers.txt in formula1.db
76
- load_persons( name )
76
+ reader = PersonDb::PersonReader.new( include_path )
77
+ reader.read( name )
77
78
  elsif match_players_for_country( name ) do |country_key|
78
79
  country = Country.find_by_key!( country_key )
79
- load_persons( name, country_id: country.id )
80
+ reader = PersonDb::PersonReader.new( include_path )
81
+ reader.read( name, country_id: country.id )
80
82
  end
81
83
  elsif match_skiers_for_country( name ) do |country_key| # name =~ /^([a-z]{2})\/skiers/
82
84
  # auto-add country code (from folder structure) for country-specific skiers (persons)
83
85
  # e.g. at/skiers or at-austria/skiers.men
84
86
  country = Country.find_by_key!( country_key )
85
- load_persons( name, country_id: country.id )
87
+ reader = PersonDb::PersonReader.new( include_path )
88
+ reader.read( name, country_id: country.id )
86
89
  end
87
90
  elsif name =~ /^skiers/ # e.g. skiers.men.txt in ski.db
88
- load_persons( name )
91
+ reader = PersonDb::PersonReader.new( include_path )
92
+ reader.read( name )
89
93
  elsif name =~ /^teams/ # e.g. teams.txt in formula1.db
90
94
  reader = TeamReader.new( include_path )
91
95
  reader.read( name )
92
96
  elsif name =~ /\/races/ # e.g. 2013/races.txt in formula1.db
97
+ ## fix/bug: NOT working for now; sorry
98
+ # need to read event first and pass along to read (event_id: event.id) etc.
93
99
  reader = RaceReader.new( include_path )
94
100
  reader.read( name )
101
+ elsif name =~ /\/squads\/([a-z]{2,3})-[^\/]+$/
102
+ ## fix: add to country matcher new format
103
+ ## name is country! and parent folder is type name e.g. /squads/br-brazil
104
+ country = Country.find_by_key!( $1 )
105
+ reader = NationalTeamReader.new( include_path )
106
+ ## note: pass in @event.id - that is, last seen event (e.g. parsed via GameReader/MatchReader)
107
+ reader.read( name, country_id: country.id, event_id: @event.id )
95
108
  elsif name =~ /\/squads/ || name =~ /\/rosters/ # e.g. 2013/squads.txt in formula1.db
96
- reader = RosterReader.new( include_path )
109
+ reader = RaceTeamReader.new( include_path )
97
110
  reader.read( name )
98
111
  elsif name =~ /\/([0-9]{2})-/
99
112
  race_pos = $1.to_i
@@ -131,6 +144,12 @@ class Reader
131
144
  reader.read( name, club: is_club_fixture?( name ) )
132
145
  elsif name =~ /\/(\d{4}|\d{4}_\d{2})(--[^\/]+)?\// ||
133
146
  name =~ /\/(\d{4}|\d{4}_\d{2})$/
147
+
148
+ # note: keep a "public" reference of last event in @event - e.g. used/required by squads etc.
149
+ eventreader = EventReader.new( include_path )
150
+ eventreader.read( name )
151
+ @event = eventreader.event
152
+
134
153
  # e.g. must match /2012/ or /2012_13/ or /2012--xxx/ or /2012_13--xx/
135
154
  # or /2012 or /2012_13 e.g. brazil/2012 or brazil/2012_13
136
155
  reader = GameReader.new( include_path )
@@ -142,16 +161,5 @@ class Reader
142
161
  end # method load
143
162
 
144
163
 
145
- ####
146
- # fix: move to persondb for (re)use
147
-
148
- def load_persons( name, more_attribs={} )
149
- reader = PersonDb::PersonReader.new( include_path )
150
- ## fix: add more_attribs !!!!! -- check other readers as an example
151
- ## - gets added to new or read??
152
- reader.read( name )
153
- end # load_persons
154
-
155
-
156
164
  end # class Reader
157
165
  end # module SportDb
@@ -0,0 +1,148 @@
1
+ # encoding: UTF-8
2
+
3
+ module SportDb
4
+
5
+
6
+ ### squad/roster reader for national teams
7
+ class NationalTeamReader
8
+
9
+ include LogUtils::Logging
10
+
11
+ ## make models available by default with namespace
12
+ # e.g. lets you use Usage instead of Model::Usage
13
+ include Models
14
+
15
+ ## value helpers e.g. is_year?, is_taglist? etc.
16
+ include TextUtils::ValueHelper
17
+
18
+ include FixtureHelpers
19
+
20
+
21
+ attr_reader :include_path
22
+
23
+
24
+ def initialize( include_path, opts = {} )
25
+ @include_path = include_path
26
+ end
27
+
28
+
29
+ def read( name, more_attribs={} )
30
+ path = "#{include_path}/#{name}.txt"
31
+
32
+ logger.info "parsing data '#{name}' (#{path})..."
33
+
34
+ # event
35
+ @event = Event.find( more_attribs[:event_id] )
36
+ pp @event
37
+
38
+ ## check/fix:
39
+ ## allow three letter codes
40
+ ## assume three letter code are *team* codes (e.g. fdr, gdr, etc)
41
+ ## not country code (allows multiple teams per country)
42
+
43
+ ### check for country_id
44
+ ## fix: check for country_key - allow (convert to country_id)
45
+
46
+ country = Country.find( more_attribs[:country_id] )
47
+ logger.info " find national team squad/lineup for #{country.name}"
48
+
49
+ ## todo/fix: find national team for country - use event.teams w/ where country.id ??
50
+ ### for now assume country code matches team for now (do NOT forget to downcase e.g. BRA==bra)
51
+ logger.info " assume country code == team code for #{country.code}"
52
+
53
+ ## note: use @team - share/use in worker method
54
+ @team = Team.find_by_key!( country.code.downcase )
55
+ pp @team
56
+
57
+ ### SportDb.lang.lang = LangChecker.new.analyze( name, include_path )
58
+
59
+ reader = LineReader.new( path )
60
+
61
+ logger.info " persons count for country: #{country.persons.count}"
62
+ known_persons_old = TextUtils.build_title_table_for( country.persons )
63
+
64
+ ### fix: add auto camelcase/titlecase
65
+ ## move to textutils
66
+ ## make it an option for name to auto Camelcase/titlecase?
67
+ ## e.g. BONFIM COSTA SANTOS becomes
68
+ ## Bonfim Costa Santos etc.
69
+ ## fix: better move into person parser?
70
+ ## store all alt_names titleized!!!!!
71
+
72
+ @known_persons = []
73
+ known_persons_old.each do |person_pair|
74
+ key = person_pair[0]
75
+ values = person_pair[1].map { |value| titleize(value) }
76
+
77
+ @known_persons << [ key, values ]
78
+ end
79
+
80
+ pp @known_persons
81
+
82
+
83
+ read_worker( reader )
84
+
85
+ Prop.create_from_fixture!( name, path )
86
+ end
87
+
88
+
89
+ def titleize( str )
90
+ ## fix: for now works only with ASCII only
91
+ ## words 2 letters and ups
92
+ str.gsub(/\b[A-Z]{2,}\b/) { |match| match.capitalize }
93
+ end
94
+
95
+
96
+ def read_worker( reader )
97
+
98
+ pos_counter = 999000 # pos counter for undefined players w/o pos
99
+
100
+ reader.each_line do |line|
101
+ logger.debug " line: >#{line}<"
102
+
103
+ cut_off_end_of_line_comment!( line )
104
+
105
+ pos = find_leading_pos!( line )
106
+
107
+ if pos.nil?
108
+ pos_counter+=1 ## e.g. 999001,999002 etc.
109
+ pos = pos_counter
110
+ end
111
+
112
+ # map_team!( line )
113
+ # team_key = find_team!( line )
114
+ # team = Team.find_by_key!( team_key )
115
+
116
+ map_person!( line )
117
+ person_key = find_person!( line )
118
+ person = Person.find_by_key!( person_key )
119
+
120
+ logger.debug " line2: >#{line}<"
121
+
122
+ ### check if roster record exists
123
+ roster = Roster.find_by_event_id_and_team_id_and_person_id( @event.id, @team.id, person.id )
124
+
125
+ if roster.present?
126
+ logger.debug "update Roster #{roster.id}:"
127
+ else
128
+ logger.debug "create Roster:"
129
+ roster = Roster.new
130
+ end
131
+
132
+ roster_attribs = {
133
+ pos: pos,
134
+ person_id: person.id,
135
+ team_id: @team.id,
136
+ event_id: @event.id # NB: reuse/fallthrough from races - make sure load_races goes first (to setup event)
137
+ }
138
+
139
+ logger.debug roster_attribs.to_json
140
+
141
+ roster.update_attributes!( roster_attribs )
142
+ end # lines.each
143
+
144
+ end # method read_worker
145
+
146
+
147
+ end # class NationTeamReader
148
+ end # module SportDb
@@ -3,7 +3,8 @@
3
3
  module SportDb
4
4
 
5
5
 
6
- class RosterReader
6
+ ### squad/roster reader for races
7
+ class RaceTeamReader
7
8
 
8
9
  include LogUtils::Logging
9
10
 
@@ -44,13 +45,13 @@ class RosterReader
44
45
  @known_persons = TextUtils.build_title_table_for( Person.all )
45
46
 
46
47
 
47
- read_rosters_worker( reader )
48
+ read_worker( reader )
48
49
 
49
50
  Prop.create_from_fixture!( name, path )
50
51
  end
51
52
 
52
53
 
53
- def read_rosters_worker( reader )
54
+ def read_worker( reader )
54
55
 
55
56
  reader.each_line do |line|
56
57
  logger.debug " line: >#{line}<"
@@ -91,8 +92,8 @@ class RosterReader
91
92
  roster.update_attributes!( roster_attribs )
92
93
  end # lines.each
93
94
 
94
- end # method read_rosters_worker
95
+ end # method read_worker
95
96
 
96
97
 
97
- end # class RosterReader
98
+ end # class RaceTeamReader
98
99
  end # module SportDb
@@ -1,6 +1,6 @@
1
1
 
2
2
  module SportDb
3
- VERSION = '1.8.23'
3
+ VERSION = '1.8.24'
4
4
  end
5
5
 
6
6
 
@@ -0,0 +1,41 @@
1
+ #############################
2
+ # Germany / Deutschland
3
+
4
+ ## GK
5
+
6
+ Manuel Neuer, 27 Mar 1986 ## Germany Bayern Munich
7
+ Ron-Robert Zieler, 12 Feb 1989 ## Germany Hannover 96
8
+ Roman Weidenfeller, 6 Aug 1980 ## Germany Borussia Dortmund
9
+
10
+ ## DF
11
+
12
+ Philipp Lahm, 11 Nov 1983 ## Germany Bayern Munich
13
+ Per Mertesacker, 29 Sep 1984 ## Germany Arsenal
14
+ Jérôme Boateng, 3 Sep1988 ## Germany Bayern Munich
15
+ Mats Hummels, 16 Dec1988 ## Germany Borussia Dortmund
16
+ Benedikt Höwedes, 29 Feb 1988 ## Germany Schalke 04
17
+ Marcel Schmelzer, 22 Jan1988 ## Germany Borussia Dortmund
18
+ Kevin Großkreutz, 19 Jul 1988 ## Germany Borussia Dortmund
19
+ Matthias Ginter, 19 Jan 1994 ## Germany SC Freiburg
20
+ Shkodran Mustafi, 17 Apr 1992 ## Italy Sampdoria
21
+ Erik Durm, 12 May 1992 ## Germany Borussia Dortmund
22
+
23
+ ## MF
24
+
25
+ Bastian Schweinsteiger, 1 Aug 1984 ## Germany Bayern Munich
26
+ Mesut Özil, 15 Oct 1988 ## England Arsenal
27
+ Sami Khedira, 4 Apr 1987 ## Spain Real Madrid
28
+ Toni Kroos, 4 Jan 1990 ## Germany Bayern Munich
29
+ Mario Götze, 3 Jun 1992 ## Germany Bayern Munich
30
+ Lars Bender, 27 Apr 1989 ## Germany Bayer Leverkusen
31
+ Julian Draxler, 20 Sep 1993 ## Germany Schalke 04
32
+ Christoph Kramer, 12 Feb 1991 ## Germany Borussia Mönchengladbach
33
+
34
+ ## FW
35
+
36
+ Miroslav Klose, 9 Jun 1978 ## Italy Lazio
37
+ Lukas Podolski, 4 Jun 1985 ## England Arsenal
38
+ André Schürrle, 6 Nov 1990 ## England Chelsea
39
+ Marco Reus, 31 May 1989 ## Germany Borussia Dortmund
40
+ Thomas Müller, 13 Sep 1989 ## Germany Bayern Munich
41
+ Kevin Volland, 30 Jul 1992 ## Germany 1899 Hoffenheim
@@ -0,0 +1,51 @@
1
+ #############
2
+ # Brazil
3
+
4
+
5
+ # NB: let official (player) shirt name go first (e.g. Neymar Jr)
6
+
7
+
8
+ ## GK / Goalkeepers
9
+
10
+ Jefferson|Jefferson DE OLIVEIRA GALVAO, 2 Jan 1983, 190
11
+ Júlio César|Júlio César SOARES DE ESPINDOLA, 3 Sep 1979, 186
12
+ D. Cavalieri|Diego CAVALIERI, 1 Dec 1982, 189
13
+ Victor, 21 Jan 1983 ## Brazil Atlético Mineiro
14
+
15
+
16
+ ## DF / Defenders
17
+
18
+ Dani Alves|Daniel ALVES|Daniel ALVES DA SILVA, 6 May 1983, 172
19
+ T. Silva|Thiago SILVA|Thiago EMILIANO DA SILVA, 22 Sep 1984, 183
20
+ David Luiz|David Luiz MOREIRA MARINHO, 22 Apr 1987, 189
21
+ Marcelo|Marcelo VIEIRA DA SILVA JUNIOR, 12 May 1988, 174
22
+ Dante|Dante BONFIM COSTA SANTOS, 18 Oct 1983, 188
23
+ Filipe Luís|Filipe Luís KASMIRSKI, 9 Aug 1985, 182
24
+ Réver|Réver Humberto ALVES ARAUJO, 4 Jan 1985, 192
25
+ Maicon, 26 Jul 1981 ## Italy Roma
26
+ Maxwell, 27 Aug 1981 ## France Paris Saint-Germain
27
+ Henrique, 14 Oct 1986 ## Italy Napoli
28
+
29
+
30
+ ## MF / Midfielders
31
+
32
+ Fernando|Fernando Lucas MARTINS, 3 Mar 1992, 175
33
+ Lucas|Lucas RODRIGUES MOURA SILVA, 13 Aug 1992, 173
34
+ Hernanes|Anderson Hernanes DE CARVALHO VIANA LIMA, 29 May 1985, 180
35
+ Oscar|Oscar DOS SANTOS EMBOABA JUNIOR, 9 Sep 1991, 180
36
+ Jean|Jean Raphael VANDERLEI MOREIRA, 24 Jun 1986, 170
37
+ L. Gustavo|Luiz Gustavo|Luiz Gustavo DIAS, 23 Jul 1987, 186
38
+ Paulinho|José Paulo BEZERRA MACIEL JUNIOR, 25 Jul 1988, 182
39
+ Bernard|Bernard ANICIO CALDEIRA DUARTE, 8 Sep 1992, 164
40
+ Jádson|Jádson RODRIGUES, 5 Oct 1983, 169
41
+ Ramires, 24 Mar 1987 ## England Chelsea
42
+ Fernandinho, 4 May 1985 ## England Manchester City
43
+ Willian, 9 Aug 1988 ## England Chelsea
44
+
45
+
46
+ ## FW / Forwards
47
+
48
+ Fred|Frederico CHAVES GUEDES, 3 Oct 1983, 185
49
+ Neymar Jr|Neymar|Neymar DA SILVA SANTOS JUNIOR, 5 Feb 1992, 174
50
+ Hulk|Givanildo VIEIRA DE SOUSA, 25 Jul 1986, 180
51
+ Jô|João Alves de Assis Silva, 20 Mar 1987
@@ -0,0 +1,5 @@
1
+ ############################
2
+ # World Cup 2014 Brazil
3
+
4
+ # note: empty just for testing squads
5
+
@@ -0,0 +1,54 @@
1
+ ##################################
2
+ # World Cup 2014 Brazil
3
+
4
+ league: world
5
+ season: 2014
6
+ start_at: 2014-06-12
7
+
8
+
9
+ ######
10
+ # 32 Teams
11
+ #
12
+ # Europe (UEFA): 13 places
13
+ # Africa (CAF): 5 places
14
+ # Asia (AFC): 4 places
15
+ # South America (CONMEBOL) 5 places (+ Brazil qualified automatically as host nation for a total of 5 or 6 places)
16
+ # North, Central American and Caribbean (CONCACAF): 4 places
17
+ # Oceania (OFC): 0
18
+ #
19
+ # see en.wikipedia.org/wiki/2014_FIFA_World_Cup_qualification
20
+
21
+ # teams:
22
+ #- nga # Nigeria -- Africa (5)
23
+ #- civ # Côte d'Ivoire
24
+ #- cmr # Cameroon
25
+ #- gha # Ghana
26
+ #- alg # Algeria
27
+ #- aus # Australia -- Asia (4) includes Australia
28
+ #- irn # Iran
29
+ #- jpn # Japan
30
+ #- kor # South Korea
31
+ #- crc # Costa Rica -- North, Central American and Caribbean (4)
32
+ #- usa # United States
33
+ #- hon # Honduras
34
+ #- mex # Mexico
35
+ #- bra # Brazil -- South America (5+1)
36
+ #- arg # Argentina
37
+ #- col # Colombia
38
+ #- chi # Chile
39
+ #- ecu # Ecuador
40
+ #- uru # Uruguay
41
+ #- bel # Belgium -- Europe (13)
42
+ #- ger # Germany
43
+ #- ita # Italy
44
+ #- ned # Netherlands
45
+ #- sui # Switzerland
46
+ #- bih # Bosnia and Herzegovina
47
+ #- rus # Russia
48
+ #- esp # Spain
49
+ #- eng # England
50
+ #- gre # Greece
51
+ #- cro # Croatia
52
+ #- por # Portugal
53
+ #- fra # France
54
+
@@ -0,0 +1,46 @@
1
+ ##############################
2
+ # Brazil - World Cup 2014
3
+ #
4
+ # Coaching Staff
5
+ # - Head Coach: Luiz Felipe Scolari
6
+
7
+
8
+ ####################
9
+ # GK / Goal Keepers
10
+
11
+ Jefferson ## Botafogo
12
+ Julio César ## Toronto F.C
13
+ Victor ## Atlético-MG
14
+
15
+ ####################
16
+ # DF / Defenders
17
+
18
+ Dante (Bayern de Munique)
19
+ David Luiz (Chelsea)
20
+ Henrique (Napoli)
21
+ Thiago Silva (Paris Saint-Germain)
22
+ Daniel Alves (Barcelona)
23
+ Maicon (Roma)
24
+ Marcelo (Real Madrid)
25
+ Maxwell (PSG)
26
+
27
+ ####################
28
+ # MF / Midfielders
29
+
30
+ Fernandinho (Manchester City)
31
+ Hernanes (Inter de Milão)
32
+ Luiz Gustavo (Wolfsburg)
33
+ Oscar (Chelsea)
34
+ Paulinho (Tottenham)
35
+ Ramires (Chelsea)
36
+ Willian (Chelsea)
37
+
38
+ ####################
39
+ # FW / Forwards
40
+
41
+ Bernard (Shakhtar)
42
+ Fred (Fluminense)
43
+ Hulk (Zenit)
44
+ Jô (Atlético-MG)
45
+ Neymar (Barcelona)
46
+
@@ -0,0 +1,8 @@
1
+ #################################
2
+ # Deutschland - World Cup 2014
3
+
4
+
5
+ Mesut Özil
6
+ Thomas Müller
7
+ Bastian Schweinsteiger
8
+
data/test/helper.rb CHANGED
@@ -23,19 +23,25 @@ League = SportDb::Model::League
23
23
  Season = SportDb::Model::Season
24
24
  Event = SportDb::Model::Event
25
25
  Team = SportDb::Model::Team
26
+ Roster = SportDb::Model::Roster
26
27
 
27
28
  Round = SportDb::Model::Round
28
29
  Game = SportDb::Model::Game
29
30
  GameCursor = SportDb::Model::GameCursor
30
31
 
32
+
31
33
  ####################
32
34
  # Reader shortcuts
33
35
 
34
- TeamReader = SportDb::TeamReader
35
- SeasonReader = SportDb::SeasonReader
36
- LeagueReader = SportDb::LeagueReader
37
- GameReader = SportDb::GameReader
36
+ Reader = SportDb::Reader
37
+ TeamReader = SportDb::TeamReader
38
+ SeasonReader = SportDb::SeasonReader
39
+ LeagueReader = SportDb::LeagueReader
40
+ GameReader = SportDb::GameReader
41
+ NationalTeamReader = SportDb::NationalTeamReader
42
+ RaceTeamReader = SportDb::RaceTeamReader
38
43
 
44
+ PersonReader = PersonDb::PersonReader
39
45
 
40
46
  #################################
41
47
  # setup db -> schema / tables
data/test/test_load.rb ADDED
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_load.rb
6
+ # or better
7
+ # rake -I ./lib test
8
+
9
+
10
+ require 'helper'
11
+
12
+ class TestLoad < MiniTest::Unit::TestCase
13
+
14
+ def setup
15
+ WorldDb.delete!
16
+ SportDb.delete!
17
+ PersonDb.delete!
18
+ SportDb.read_builtin # add 2014 season
19
+ end
20
+
21
+
22
+ def test_br
23
+ br = Country.create!( key: 'br', title: 'Brazil', code: 'BRA', pop: 1, area: 1)
24
+ bra = Team.create!( key: 'bra', title: 'Brazil', code: 'BRA', country_id: br.id )
25
+
26
+ reader = Reader.new( SportDb.test_data_path )
27
+
28
+ ## fix: add to country_matcher - allow players/br-brazil.txt e.g. country encode in file
29
+ reader.load( 'players/south-america/br-brazil/players' )
30
+ assert_equal 30, Person.count
31
+
32
+ reader.load( 'world-cup/leagues' )
33
+ assert_equal 1, League.count
34
+ reader.load( 'world-cup/2014/cup' )
35
+ assert_equal 1, Event.count
36
+
37
+ reader.load( 'world-cup/2014/squads/br-brazil' )
38
+ assert_equal 23, Roster.count
39
+ end # method test_br
40
+
41
+
42
+ def test_de
43
+ de = Country.create!( key: 'de', title: 'Germany', code: 'GER', pop: 1, area: 1)
44
+ ger = Team.create!( key: 'ger', title: 'Germany', code: 'GER', country_id: de.id )
45
+
46
+ reader = Reader.new( SportDb.test_data_path )
47
+
48
+ reader.load( 'players/europe/de-deutschland/players' )
49
+ assert_equal 27, Person.count
50
+
51
+ reader.load( 'world-cup/leagues' )
52
+ assert_equal 1, League.count
53
+ reader.load( 'world-cup/2014/cup' )
54
+ assert_equal 1, Event.count
55
+
56
+ reader.load( 'world-cup/2014/squads/de-deutschland' )
57
+ assert_equal 3, Roster.count
58
+ end # method test_de
59
+
60
+
61
+ end # class TestLoad
@@ -0,0 +1,80 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_national_team_reader.rb
6
+ # or better
7
+ # rake -I ./lib test
8
+
9
+
10
+ require 'helper'
11
+
12
+ class TestNationalTeamReader < MiniTest::Unit::TestCase
13
+
14
+ def setup
15
+ WorldDb.delete!
16
+ SportDb.delete!
17
+ PersonDb.delete!
18
+
19
+ add_world_cup_2014
20
+ end
21
+
22
+ def add_world_cup_2014
23
+ SportDb.read_builtin # add 2014 season
24
+
25
+ leaguereader = LeagueReader.new( SportDb.test_data_path )
26
+ leaguereader.read( 'world-cup/leagues' )
27
+
28
+ assert_equal 1, League.count
29
+
30
+ l = League.find_by_key!( 'world' )
31
+ assert_equal 'World Cup', l.title
32
+
33
+ gamereader = GameReader.new( SportDb.test_data_path )
34
+ gamereader.read( 'world-cup/2014/cup' )
35
+
36
+ assert_equal 1, Event.count
37
+ end
38
+
39
+ def test_br
40
+ br = Country.create!( key: 'br', title: 'Brazil', code: 'BRA', pop: 1, area: 1)
41
+
42
+ ## read persons
43
+ personreader = PersonReader.new( SportDb.test_data_path )
44
+ personreader.read( 'players/south-america/br-brazil/players', country_id: br.id )
45
+
46
+ assert_equal 30, Person.count
47
+
48
+ bra = Team.create!( key: 'bra', title: 'Brazil', code: 'BRA', country_id: br.id )
49
+
50
+
51
+ event = Event.find_by_key!( 'world.2014' )
52
+
53
+ reader = NationalTeamReader.new( SportDb.test_data_path )
54
+ reader.read( 'world-cup/2014/squads/br-brazil', country_id: br.id, event_id: event.id )
55
+
56
+ assert_equal 23, Roster.count
57
+ end # method test_br
58
+
59
+
60
+ def test_de
61
+ de = Country.create!( key: 'de', title: 'Germany', code: 'GER', pop: 1, area: 1)
62
+
63
+ ## read persons
64
+ personreader = PersonReader.new( SportDb.test_data_path )
65
+ personreader.read( 'players/europe/de-deutschland/players', country_id: de.id )
66
+
67
+ assert_equal 27, Person.count
68
+
69
+ ger = Team.create!( key: 'ger', title: 'Germany', code: 'GER', country_id: de.id )
70
+
71
+ event = Event.find_by_key!( 'world.2014' )
72
+
73
+ reader = NationalTeamReader.new( SportDb.test_data_path )
74
+ reader.read( 'world-cup/2014/squads/de-deutschland', country_id: de.id, event_id: event.id )
75
+
76
+ assert_equal 3, Roster.count
77
+ end # method test_de
78
+
79
+
80
+ end # class TestNationalTeamReader
metadata CHANGED
@@ -1,183 +1,148 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.23
4
+ version: 1.8.24
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Gerald Bauer
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-05-19 00:00:00.000000000 Z
12
+ date: 2014-05-22 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: props
15
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &77540830 !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0'
20
22
  type: :runtime
21
23
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ! '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
24
+ version_requirements: *77540830
27
25
  - !ruby/object:Gem::Dependency
28
26
  name: logutils
29
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &77563220 !ruby/object:Gem::Requirement
28
+ none: false
30
29
  requirements:
31
30
  - - ! '>='
32
31
  - !ruby/object:Gem::Version
33
32
  version: '0'
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ! '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
35
+ version_requirements: *77563220
41
36
  - !ruby/object:Gem::Dependency
42
37
  name: textutils
43
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &77562470 !ruby/object:Gem::Requirement
39
+ none: false
44
40
  requirements:
45
41
  - - ! '>='
46
42
  - !ruby/object:Gem::Version
47
43
  version: '0'
48
44
  type: :runtime
49
45
  prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
46
+ version_requirements: *77562470
55
47
  - !ruby/object:Gem::Dependency
56
48
  name: worlddb
57
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &77561520 !ruby/object:Gem::Requirement
50
+ none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: 2.0.2
62
55
  type: :runtime
63
56
  prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ! '>='
67
- - !ruby/object:Gem::Version
68
- version: 2.0.2
57
+ version_requirements: *77561520
69
58
  - !ruby/object:Gem::Dependency
70
59
  name: tagutils
71
- requirement: !ruby/object:Gem::Requirement
60
+ requirement: &77560760 !ruby/object:Gem::Requirement
61
+ none: false
72
62
  requirements:
73
63
  - - ! '>='
74
64
  - !ruby/object:Gem::Version
75
65
  version: '0'
76
66
  type: :runtime
77
67
  prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ! '>='
81
- - !ruby/object:Gem::Version
82
- version: '0'
68
+ version_requirements: *77560760
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: persondb
85
- requirement: !ruby/object:Gem::Requirement
71
+ requirement: &77558250 !ruby/object:Gem::Requirement
72
+ none: false
86
73
  requirements:
87
74
  - - ! '>='
88
75
  - !ruby/object:Gem::Version
89
76
  version: '0'
90
77
  type: :runtime
91
78
  prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ! '>='
95
- - !ruby/object:Gem::Version
96
- version: '0'
79
+ version_requirements: *77558250
97
80
  - !ruby/object:Gem::Dependency
98
81
  name: activerecord-utils
99
- requirement: !ruby/object:Gem::Requirement
82
+ requirement: &77556820 !ruby/object:Gem::Requirement
83
+ none: false
100
84
  requirements:
101
85
  - - ! '>='
102
86
  - !ruby/object:Gem::Version
103
87
  version: '0'
104
88
  type: :runtime
105
89
  prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ! '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
90
+ version_requirements: *77556820
111
91
  - !ruby/object:Gem::Dependency
112
92
  name: fetcher
113
- requirement: !ruby/object:Gem::Requirement
93
+ requirement: &77346810 !ruby/object:Gem::Requirement
94
+ none: false
114
95
  requirements:
115
96
  - - ! '>='
116
97
  - !ruby/object:Gem::Version
117
98
  version: '0.3'
118
99
  type: :runtime
119
100
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ! '>='
123
- - !ruby/object:Gem::Version
124
- version: '0.3'
101
+ version_requirements: *77346810
125
102
  - !ruby/object:Gem::Dependency
126
103
  name: gli
127
- requirement: !ruby/object:Gem::Requirement
104
+ requirement: &77369960 !ruby/object:Gem::Requirement
105
+ none: false
128
106
  requirements:
129
107
  - - ! '>='
130
108
  - !ruby/object:Gem::Version
131
109
  version: 2.5.6
132
110
  type: :runtime
133
111
  prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ! '>='
137
- - !ruby/object:Gem::Version
138
- version: 2.5.6
112
+ version_requirements: *77369960
139
113
  - !ruby/object:Gem::Dependency
140
114
  name: activerecord
141
- requirement: !ruby/object:Gem::Requirement
115
+ requirement: &77271920 !ruby/object:Gem::Requirement
116
+ none: false
142
117
  requirements:
143
118
  - - ! '>='
144
119
  - !ruby/object:Gem::Version
145
120
  version: '0'
146
121
  type: :runtime
147
122
  prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ! '>='
151
- - !ruby/object:Gem::Version
152
- version: '0'
123
+ version_requirements: *77271920
153
124
  - !ruby/object:Gem::Dependency
154
125
  name: rdoc
155
- requirement: !ruby/object:Gem::Requirement
126
+ requirement: &77265060 !ruby/object:Gem::Requirement
127
+ none: false
156
128
  requirements:
157
129
  - - ~>
158
130
  - !ruby/object:Gem::Version
159
131
  version: '4.0'
160
132
  type: :development
161
133
  prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ~>
165
- - !ruby/object:Gem::Version
166
- version: '4.0'
134
+ version_requirements: *77265060
167
135
  - !ruby/object:Gem::Dependency
168
136
  name: hoe
169
- requirement: !ruby/object:Gem::Requirement
137
+ requirement: &77283630 !ruby/object:Gem::Requirement
138
+ none: false
170
139
  requirements:
171
140
  - - ~>
172
141
  - !ruby/object:Gem::Version
173
- version: '3.10'
142
+ version: '3.11'
174
143
  type: :development
175
144
  prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ~>
179
- - !ruby/object:Gem::Version
180
- version: '3.10'
145
+ version_requirements: *77283630
181
146
  description: sportdb - sport.db command line tool
182
147
  email: opensport@googlegroups.com
183
148
  executables:
@@ -244,9 +209,10 @@ files:
244
209
  - lib/sportdb/readers/game.rb
245
210
  - lib/sportdb/readers/ground.rb
246
211
  - lib/sportdb/readers/league.rb
212
+ - lib/sportdb/readers/national_team.rb
247
213
  - lib/sportdb/readers/race.rb
214
+ - lib/sportdb/readers/race_team.rb
248
215
  - lib/sportdb/readers/record.rb
249
- - lib/sportdb/readers/roster.rb
250
216
  - lib/sportdb/readers/season.rb
251
217
  - lib/sportdb/readers/team.rb
252
218
  - lib/sportdb/readers/track.rb
@@ -300,6 +266,8 @@ files:
300
266
  - test/data/at-austria/leagues.txt
301
267
  - test/data/at-austria/teams.txt
302
268
  - test/data/at-austria/teams_2.txt
269
+ - test/data/players/europe/de-deutschland/players.txt
270
+ - test/data/players/south-america/br-brazil/players.txt
303
271
  - test/data/world-cup/1930/cup.txt
304
272
  - test/data/world-cup/1930/cup.yml
305
273
  - test/data/world-cup/1954/cup.txt
@@ -310,6 +278,10 @@ files:
310
278
  - test/data/world-cup/1974/cup_finals.txt
311
279
  - test/data/world-cup/1974/cup_i.txt
312
280
  - test/data/world-cup/1974/cup_ii.txt
281
+ - test/data/world-cup/2014/cup.txt
282
+ - test/data/world-cup/2014/cup.yml
283
+ - test/data/world-cup/2014/squads/br-brazil.txt
284
+ - test/data/world-cup/2014/squads/de-deutschland.txt
313
285
  - test/data/world-cup/leagues.txt
314
286
  - test/data/world-cup/seasons_1930.txt
315
287
  - test/data/world-cup/seasons_1954.txt
@@ -324,6 +296,8 @@ files:
324
296
  - test/test_cursor.rb
325
297
  - test/test_date.rb
326
298
  - test/test_lang.rb
299
+ - test/test_load.rb
300
+ - test/test_national_team_reader.rb
327
301
  - test/test_reader.rb
328
302
  - test/test_round_auto.rb
329
303
  - test/test_round_def.rb
@@ -335,7 +309,6 @@ files:
335
309
  homepage: https://github.com/geraldb/sport.db.ruby
336
310
  licenses:
337
311
  - Public Domain
338
- metadata: {}
339
312
  post_install_message: ! '******************************************************************************
340
313
 
341
314
 
@@ -353,30 +326,34 @@ rdoc_options:
353
326
  require_paths:
354
327
  - lib
355
328
  required_ruby_version: !ruby/object:Gem::Requirement
329
+ none: false
356
330
  requirements:
357
331
  - - ! '>='
358
332
  - !ruby/object:Gem::Version
359
333
  version: 1.9.2
360
334
  required_rubygems_version: !ruby/object:Gem::Requirement
335
+ none: false
361
336
  requirements:
362
337
  - - ! '>='
363
338
  - !ruby/object:Gem::Version
364
339
  version: '0'
365
340
  requirements: []
366
341
  rubyforge_project:
367
- rubygems_version: 2.1.10
342
+ rubygems_version: 1.8.17
368
343
  signing_key:
369
- specification_version: 4
344
+ specification_version: 3
370
345
  summary: sportdb - sport.db command line tool
371
346
  test_files:
372
- - test/test_changes.rb
373
- - test/test_cursor.rb
374
347
  - test/test_date.rb
375
348
  - test/test_lang.rb
376
- - test/test_reader.rb
377
- - test/test_round_auto.rb
378
- - test/test_round_def.rb
379
- - test/test_round_header.rb
349
+ - test/test_load.rb
350
+ - test/test_cursor.rb
380
351
  - test/test_scores.rb
381
- - test/test_utils.rb
382
352
  - test/test_winner.rb
353
+ - test/test_round_def.rb
354
+ - test/test_utils.rb
355
+ - test/test_round_header.rb
356
+ - test/test_round_auto.rb
357
+ - test/test_national_team_reader.rb
358
+ - test/test_reader.rb
359
+ - test/test_changes.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 7aa8a4205419c3506fc1527e6cf45ca56d4bfcb8
4
- data.tar.gz: bed9fcb72a3f0f931048afb1c348f4d24a224dc0
5
- SHA512:
6
- metadata.gz: 2b16a61eb98bd836272199997275f8dd08989bb2501a8939c961208367566ab8a99cb4198f563b027249523f6ad247a781a65a6f6a0602ae6b7b9ed5b17082cd
7
- data.tar.gz: 167a8ec86e1b0f8069e6f02ae7eff72fb9acc08ee1b31222d1786f4d3d3f80e55a625f4b50c377528ac57607932edf216964225caffb254adf8e52cacff53ce2