sportdb 1.8.22 → 1.8.23

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7aa8a4205419c3506fc1527e6cf45ca56d4bfcb8
4
+ data.tar.gz: bed9fcb72a3f0f931048afb1c348f4d24a224dc0
5
+ SHA512:
6
+ metadata.gz: 2b16a61eb98bd836272199997275f8dd08989bb2501a8939c961208367566ab8a99cb4198f563b027249523f6ad247a781a65a6f6a0602ae6b7b9ed5b17082cd
7
+ data.tar.gz: 167a8ec86e1b0f8069e6f02ae7eff72fb9acc08ee1b31222d1786f4d3d3f80e55a625f4b50c377528ac57607932edf216964225caffb254adf8e52cacff53ce2
@@ -116,13 +116,19 @@ test/data/world-cup/1954/cup.txt
116
116
  test/data/world-cup/1954/cup.yml
117
117
  test/data/world-cup/1962/cup.txt
118
118
  test/data/world-cup/1962/cup.yml
119
+ test/data/world-cup/1974/cup.yml
120
+ test/data/world-cup/1974/cup_finals.txt
121
+ test/data/world-cup/1974/cup_i.txt
122
+ test/data/world-cup/1974/cup_ii.txt
119
123
  test/data/world-cup/leagues.txt
120
124
  test/data/world-cup/seasons_1930.txt
121
125
  test/data/world-cup/seasons_1954.txt
122
126
  test/data/world-cup/seasons_1962.txt
127
+ test/data/world-cup/seasons_1974.txt
123
128
  test/data/world-cup/teams_1930.txt
124
129
  test/data/world-cup/teams_1954.txt
125
130
  test/data/world-cup/teams_1962.txt
131
+ test/data/world-cup/teams_1974.txt
126
132
  test/helper.rb
127
133
  test/test_changes.rb
128
134
  test/test_cursor.rb
data/Rakefile CHANGED
@@ -30,6 +30,8 @@ Hoe.spec 'sportdb' do
30
30
  # - logutils
31
31
  # - textutils
32
32
  ['tagutils'], # tags n tagging tables
33
+ ['persondb'], # persons (people) table
34
+ ['activerecord-utils'], # extras e.g. rnd, find_by! for 3.x etc.
33
35
  ['fetcher', '>= 0.3'],
34
36
 
35
37
  ## 3rd party
File without changes
@@ -14,14 +14,23 @@ require 'logger' ## todo/fix: no longer needed - replaced by logutil
14
14
  require 'fileutils'
15
15
  require 'erb'
16
16
 
17
+
17
18
  # rubygems / 3rd party libs
18
19
 
19
20
  require 'active_record' ## todo: add sqlite3? etc.
21
+ require 'activerecord/utils' # check - if dependency on logutils? or props? etc let others go first
20
22
 
21
23
  require 'logutils'
24
+ require 'logutils/db' # NB: explict require required for LogDb (NOT automatic)
25
+
22
26
  require 'textutils'
27
+ require 'tagutils'
28
+
29
+ require 'props'
30
+ require 'props/db' # NB: explict require required for ConfDb (NOT automatic) - move to textutils/deb - why/why not??
23
31
 
24
32
  require 'worlddb'
33
+ require 'persondb'
25
34
 
26
35
  require 'fetcher' # for fetching/downloading fixtures via HTTP/HTTPS etc.
27
36
 
@@ -206,10 +215,34 @@ module SportDb
206
215
  Stats.new.tables
207
216
  end
208
217
 
218
+ ### fix:
219
+ ## remove - use ConfDb.dump or similar -- add api depreciated
209
220
  def self.props
210
221
  Stats.new.props
211
222
  end
212
223
 
224
+ def self.setup_in_memory_db
225
+ # Database Setup & Config
226
+
227
+ ActiveRecord::Base.logger = Logger.new( STDOUT )
228
+ ## ActiveRecord::Base.colorize_logging = false - no longer exists - check new api/config setting?
229
+
230
+ ## NB: every connect will create a new empty in memory db
231
+ ActiveRecord::Base.establish_connection(
232
+ adapter: 'sqlite3',
233
+ database: ':memory:' )
234
+
235
+ ## build schema
236
+ LogDb.create
237
+ ConfDb.create
238
+ TagDb.create
239
+ WorldDb.create
240
+ PersonDb.create
241
+ SportDb.create
242
+
243
+ ## read builtins - why? why not?
244
+ SportDb.read_builtin
245
+ end # setup_in_memory_db (using SQLite :memory:)
213
246
 
214
247
 
215
248
  def self.load_plugins
@@ -98,6 +98,7 @@ command [:create] do |c|
98
98
  ConfDb.create
99
99
  TagDb.create
100
100
  WorldDb.create
101
+ PersonDb.create
101
102
  SportDb.create
102
103
 
103
104
  SportDb.read_builtin # e.g. seasons.txt etc
@@ -131,6 +132,7 @@ command [:setup,:s] do |c|
131
132
  ConfDb.create
132
133
  TagDb.create
133
134
  WorldDb.create
135
+ PersonDb.create
134
136
  SportDb.create
135
137
 
136
138
  SportDb.read_builtin # e.g. seasons.txt etc
@@ -27,7 +27,6 @@ module SportDb
27
27
  Roster.delete_all
28
28
 
29
29
  Track.delete_all
30
- Person.delete_all
31
30
  Team.delete_all
32
31
 
33
32
  League.delete_all
@@ -22,6 +22,10 @@ module Matcher
22
22
  match_xxx_for_country( name, 'skiers', &blk )
23
23
  end
24
24
 
25
+ def match_players_for_country( name, &blk )
26
+ match_xxx_for_country( name, 'players', &blk )
27
+ end
28
+
25
29
  def match_stadiums_for_country( name, &blk )
26
30
  match_xxx_for_country( name, 'stadiums', &blk )
27
31
  end
@@ -5,14 +5,15 @@
5
5
  module SportDb
6
6
  module Model
7
7
 
8
- ## todo: why? why not use include WorldDb::Models here???
8
+ Prop = ConfDb::Model::Prop
9
9
 
10
+ ## todo: why? why not use include WorldDb::Models here???
10
11
  Continent = WorldDb::Model::Continent
11
12
  Country = WorldDb::Model::Country
12
13
  Region = WorldDb::Model::Region
13
14
  City = WorldDb::Model::City
14
15
 
15
- Prop = ConfDb::Model::Prop
16
+ Person = PersonDb::Model::Person
16
17
 
17
18
  ## nb: for now only team and league use worlddb tables
18
19
  # e.g. with belongs_to assoc (country,region)
@@ -20,6 +21,7 @@ module SportDb
20
21
  class Team < ActiveRecord::Base ; end
21
22
  class League < ActiveRecord::Base ; end
22
23
  class Ground < ActiveRecord::Base ; end
24
+ class Goal < ActiveRecord::Base ; end
23
25
 
24
26
  end
25
27
  end
@@ -38,3 +40,11 @@ module WorldDb
38
40
  end
39
41
  end
40
42
 
43
+
44
+ module PersonDb
45
+ module Model
46
+ Goal = SportDb::Model::Goal
47
+ end
48
+ end
49
+
50
+
@@ -6,7 +6,7 @@ module SportDb
6
6
  class Goal < ActiveRecord::Base
7
7
 
8
8
  belongs_to :game
9
- belongs_to :person
9
+ belongs_to :person, class_name: 'PersonDb::Model::Person', foreign_key: 'person_id'
10
10
 
11
11
  end # class Goal
12
12
 
@@ -1,69 +1,21 @@
1
1
 
2
- module SportDb
3
- module Model
4
-
5
-
6
- class Person < ActiveRecord::Base
7
- self.table_name = 'persons' # avoids possible "smart" plural inflection to people
8
-
9
- has_many :goals
10
-
11
- belongs_to :country, :class_name => 'WorldDb::Model::Country', :foreign_key => 'country_id'
12
-
2
+ #### note ---
3
+ ## uses PersonDb namespace!!!!!
4
+ #
5
+ # move to models/person/person.rb - why? why not??
13
6
 
14
- def title() name end # alias for name
15
- def title=(value) self.name = value end # alias for name
16
7
 
8
+ module PersonDb
9
+ module Model
17
10
 
18
- def self.create_or_update_from_values( new_attributes, values )
19
-
20
- ## fix: add/configure logger for ActiveRecord!!!
21
- logger = LogKernel::Logger.root
22
-
23
- ## check optional values
24
- values.each_with_index do |value, index|
25
- if value =~ /^[a-z]{2}$/ ## assume two-letter country key e.g. at,de,mx,etc.
26
- value_country = Country.find_by_key!( value )
27
- new_attributes[ :country_id ] = value_country.id
28
- elsif value =~ /^[A-Z]{3}$/ ## assume three-letter code e.g. AUS, MAL, etc.
29
- new_attributes[ :code ] = value
30
- elsif value =~ /^([0-9]{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s([0-9]{4})$/ ## assume birthday
31
- value_date_str = '%02d/%s/%d' % [$1, $2, $3] ## move to matcher!!
32
- value_date = Date.strptime( value_date_str, '%d/%b/%Y' ) ## %b - abbreviated month name (e.g. Jan,Feb, etc.)
33
- logger.debug " birthday #{value_date_str} - #{value_date}"
34
- new_attributes[ :born_at ] = value_date
35
- ## todo: convert to date
36
- else
37
- ## todo: assume title2 ??
38
- ## assume title2 if title2 is empty (not already in use)
39
- ## and if it title2 contains at least two letter e.g. [a-zA-Z].*[a-zA-Z]
40
- # issue warning: unknown type for value
41
- logger.warn "unknown type for value >#{value}< - key #{new_attributes[:key]}"
42
- end
43
- end
44
-
45
- ## quick hack: set nationality_id if not present to country_id
46
- if new_attributes[ :nationality_id ].blank?
47
- new_attributes[ :nationality_id ] = new_attributes[ :country_id ]
48
- end
49
-
50
- rec = Person.find_by_key( new_attributes[ :key ] )
51
- if rec.present?
52
- logger.debug "update Person #{rec.id}-#{rec.key}:"
53
- else
54
- logger.debug "create Person:"
55
- rec = Person.new
56
- end
57
-
58
- logger.debug new_attributes.to_json
59
-
60
- rec.update_attributes!( new_attributes )
61
- end # create_or_update_from_values
11
+ ### extends "basic" person model in PersonDb
12
+ class Person
62
13
 
14
+ has_many :goals
63
15
 
64
16
  end # class Person
65
17
 
66
18
 
67
19
  end # module Model
68
- end # module SportDb
20
+ end # module PersonDb
69
21
 
@@ -7,7 +7,7 @@ class Record < ActiveRecord::Base
7
7
 
8
8
  belongs_to :race # or
9
9
  belongs_to :run
10
- belongs_to :person
10
+ belongs_to :person, class_name: 'PersonDb::Model::Person', foreign_key: 'person_id'
11
11
 
12
12
  end # class Record
13
13
 
@@ -8,7 +8,7 @@ class Roster < ActiveRecord::Base
8
8
 
9
9
  belongs_to :event
10
10
  belongs_to :team
11
- belongs_to :person
11
+ belongs_to :person, class_name: 'PersonDb::Model::Person', foreign_key: 'person_id'
12
12
 
13
13
  end # class Roster
14
14
 
@@ -74,6 +74,10 @@ class Reader
74
74
  reader.read( name )
75
75
  elsif name =~ /^drivers/ # e.g. drivers.txt in formula1.db
76
76
  load_persons( name )
77
+ elsif match_players_for_country( name ) do |country_key|
78
+ country = Country.find_by_key!( country_key )
79
+ load_persons( name, country_id: country.id )
80
+ end
77
81
  elsif match_skiers_for_country( name ) do |country_key| # name =~ /^([a-z]{2})\/skiers/
78
82
  # auto-add country code (from folder structure) for country-specific skiers (persons)
79
83
  # e.g. at/skiers or at-austria/skiers.men
@@ -139,16 +143,13 @@ class Reader
139
143
 
140
144
 
141
145
  ####
142
- ## fix: move to persondb for (re)use
146
+ # fix: move to persondb for (re)use
143
147
 
144
148
  def load_persons( name, more_attribs={} )
145
-
146
- reader = ValuesReaderV2.new( name, include_path, more_attribs )
147
-
148
- reader.each_line do |new_attributes, values|
149
- Person.create_or_update_from_values( new_attributes, values )
150
- end # each lines
151
-
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 )
152
153
  end # load_persons
153
154
 
154
155
 
@@ -27,7 +27,8 @@ end
27
27
 
28
28
  add_index :teams, :key, unique: true
29
29
 
30
-
30
+ ###########
31
+ # check: use table (rename to) venues / stadiums - why? why not?
31
32
  create_table :grounds do |t|
32
33
  t.string :key, null: false # import/export key
33
34
  t.string :title, null: false
@@ -53,25 +54,6 @@ end
53
54
  add_index :grounds, :key, unique: true
54
55
 
55
56
 
56
- create_table :persons do |t| # use people ? instead of persons (person/persons makes it easier?)
57
- t.string :key, null: false # import/export key
58
- t.string :name, null: false
59
- t.string :synonyms # comma separated list of synonyms
60
- t.string :code # three letter code (short title)
61
-
62
- ## todo: add gender flag (male/female -man/lady how?)
63
- t.date :born_at # optional date of birth (birthday)
64
- ## todo: add country of birth might not be the same as nationality
65
-
66
- t.references :city
67
- t.references :region
68
- t.references :country, null: false
69
-
70
- t.references :nationality, null: false # by default assume same as country of birth (see above)
71
-
72
- t.timestamps
73
- end
74
-
75
57
  # join table: person+game(team1+team2+event(season+league))
76
58
  create_table :goals do |t|
77
59
  t.references :person, null: false
@@ -139,6 +121,9 @@ create_table :records do |t| # use TimeRecord? instead of simple record
139
121
  end
140
122
 
141
123
 
124
+ ################
125
+ # fix/todo: rename to squads / lineups
126
+
142
127
  # join table -> person+team+event(season+league)
143
128
  create_table :rosters do |t| # use squads as an alternative name? why? why not??
144
129
  t.references :person, null: false
@@ -200,7 +185,8 @@ end
200
185
 
201
186
  add_index :groups, :event_id # fk event_id index
202
187
 
203
-
188
+ ###########################
189
+ # fix: rename table to matches
204
190
  create_table :games do |t|
205
191
  t.string :key # import/export key
206
192
  t.references :round, null: false
@@ -13,12 +13,14 @@ module SportDb
13
13
 
14
14
  puts " #{Track.count} tracks / #{Race.count} races (track+event recs) / #{Run.count} runs"
15
15
  puts " #{Record.count} records (race|run+person recs)"
16
- puts " #{Person.count} persons / #{Roster.count} rosters (person+team+event recs)"
16
+ puts " #{Roster.count} rosters (person+team+event recs)"
17
17
  puts " #{Goal.count} goals (person+game recs)"
18
18
 
19
19
  puts " #{Ground.count} grounds|stadiums"
20
20
  end
21
21
 
22
+ ## fix/chek:
23
+ # move to Prop gem / reuse code from Prop gem
22
24
  def props
23
25
  puts "Props:"
24
26
  Prop.order( 'created_at asc' ).all.each do |prop|
@@ -1,6 +1,6 @@
1
1
 
2
2
  module SportDb
3
- VERSION = '1.8.22'
3
+ VERSION = '1.8.23'
4
4
  end
5
5
 
6
6
 
@@ -0,0 +1,35 @@
1
+ ##################################################
2
+ # World Cup 1974 West Germany, 13 June - 7 July
3
+
4
+ league: world
5
+ season: 1974
6
+ start_at: 1974-06-13
7
+
8
+ fixtures:
9
+ - cup_i
10
+ - cup_ii
11
+ - cup_finals
12
+
13
+ # 16 Teams
14
+ teams:
15
+ # -- Africa
16
+ - zai # Zaire
17
+ # -- Asia
18
+ - aus # Australia
19
+ # -- Europe
20
+ - bul # Bulgaria
21
+ - frg # West Germany
22
+ - gdr # East Germany
23
+ - ita # Italy
24
+ - ned # Netherlands
25
+ - pol # Poland
26
+ - sco # Scotland
27
+ - swe # Sweden
28
+ - yug # Yugoslavia
29
+ # -- North and Central America
30
+ - hai # Haiti
31
+ # -- South America
32
+ - arg # Argentina
33
+ - bra # Brazil
34
+ - chi # Chile
35
+ - uru # Uruguay
@@ -0,0 +1,14 @@
1
+ ##################################################
2
+ # World Cup 1974 West Germany, 13 June - 7 July
3
+
4
+
5
+
6
+ Match for third place
7
+
8
+ # fix: use Muenchen not Munich
9
+ (37) 6 July Brazil 0-1 Poland @ Olympiastadion, Munich
10
+
11
+ Final
12
+
13
+ (38) 7 July Netherlands 1-2 West Germany @ Olympiastadion, Munich
14
+
@@ -0,0 +1,55 @@
1
+ ##################################################
2
+ # World Cup 1974 West Germany, 13 June - 7 July
3
+
4
+ Group 1 | East Germany West Germany Chile Australia
5
+ Group 2 | Yugoslavia Brazil Scotland Zaire
6
+ Group 3 | Netherlands Sweden Bulgaria Uruguay
7
+ Group 4 | Poland Argentina Italy Haiti
8
+
9
+
10
+ Group 1:
11
+
12
+ (1) 14 June West Germany 1-0 Chile @ Olympiastadion, West Berlin
13
+ (2) 14 June East Germany 2-0 Australia @ Volksparkstadion, Hamburg
14
+
15
+ (9) 18 June Chile 1-1 East Germany @ Olympiastadion, West Berlin
16
+ (10) 18 June Australia 0-3 West Germany @ Volksparkstadion, Hamburg
17
+
18
+ (17) 22 June Australia 0-0 Chile @ Olympiastadion, West Berlin
19
+ (18) 22 June East Germany 1-0 West Germany @ Volksparkstadion, Hamburg
20
+
21
+
22
+ Group 2:
23
+
24
+ (3) 13 June Brazil 0-0 Yugoslavia @ Waldstadion, Frankfurt
25
+ (4) 14 June Zaire 0-2 Scotland @ Westfalenstadion, Dortmund
26
+
27
+ (11) 18 June Yugoslavia 9-0 Zaire @ Parkstadion, Gelsenkirchen
28
+ (12) 18 June Scotland 0-0 Brazil @ Waldstadion, Frankfurt
29
+
30
+ (19) 22 June Scotland 1-1 Yugoslavia @ Waldstadion, Frankfurt
31
+ (20) 22 June Zaire 0-3 Brazil @ Parkstadion, Gelsenkirchen
32
+
33
+
34
+ Group 3:
35
+
36
+ (5) 15 June Uruguay 0-2 Netherlands @ Niedersachsenstadion, Hanover
37
+ (6) 15 June Sweden 0-0 Bulgaria @ Rheinstadion, Düsseldorf
38
+
39
+ (13) 19 June Netherlands 0-0 Sweden @ Westfalenstadion, Dortmund
40
+ (14) 19 June Uruguay 1-1 Bulgaria @ Niedersachsenstadion, Hanover
41
+
42
+ (21) 23 June Netherlands 4-1 Bulgaria @ Westfalenstadion, Dortmund
43
+ (22) 23 June Sweden 3-0 Uruguay @ Rheinstadion, Düsseldorf
44
+
45
+
46
+ Group 4:
47
+
48
+ (7) 15 June Italy 3-1 Haiti @ Olympiastadion, Munich
49
+ (8) 15 June Poland 3-2 Argentina @ Neckarstadion, Stuttgart
50
+
51
+ (15) 19 June Haiti 0-7 Poland @ Olympiastadion, Munich
52
+ (16) 19 June Argentina 1-1 Italy @ Neckarstadion, Stuttgart
53
+
54
+ (23) 23 June Argentina 4-1 Haiti @ Olympiastadion, Munich
55
+ (24) 23 June Poland 2-1 Italy @ Neckarstadion, Stuttgart
@@ -0,0 +1,34 @@
1
+ ##################################################
2
+ # World Cup 1974 West Germany, 13 June - 7 July
3
+
4
+
5
+ #### Second Round
6
+ ## todo/fix: add stage/add stage key to rounds
7
+ #
8
+ # Group A -> I
9
+ # Group B -> J - fix: use Group A,B etc.
10
+
11
+ Group I | Netherlands Brazil East Germany Argentina
12
+ Group J | West Germany Poland Sweden Yugoslavia
13
+
14
+ Group I:
15
+
16
+ (25) 26 June Brazil 1-0 East Germany @ Niedersachsenstadion, Hanover
17
+ (26) 26 June Netherlands 4-0 Argentina @ Parkstadion, Gelsenkirchen
18
+
19
+ (29) 30 June East Germany 0-2 Netherlands @ Parkstadion, Gelsenkirchen
20
+ (30) 30 June Argentina 1-2 Brazil @ Niedersachsenstadion, Hanover
21
+
22
+ (33) 3 July Argentina 1-1 East Germany @ Parkstadion, Gelsenkirchen
23
+ (34) 3 July Netherlands 2-0 Brazil @ Westfalenstadion, Dortmund
24
+
25
+ Group J:
26
+
27
+ (27) 26 June Yugoslavia 0-2 West Germany @ Rheinstadion, Düsseldorf
28
+ (28) 26 June Sweden 0-1 Poland @ Neckarstadion, Stuttgart
29
+
30
+ (31) 30 June West Germany 4-2 Sweden @ Rheinstadion, Düsseldorf
31
+ (32) 30 June Poland 2-1 Yugoslavia @ Waldstadion, Frankfurt
32
+
33
+ (35) 3 July Poland 0-1 West Germany @ Waldstadion, Frankfurt
34
+ (36) 3 July Sweden 2-1 Yugoslavia @ Rheinstadion, Düsseldorf
@@ -0,0 +1,5 @@
1
+ #####################
2
+ # Seasons / Years
3
+
4
+ 1974
5
+
@@ -0,0 +1,29 @@
1
+ ########################
2
+ # 16 Teams
3
+
4
+ # -- Africa
5
+ zai, Zaire, ZAI, cd
6
+
7
+ # -- Asia
8
+ aus, Australia, AUS, au
9
+
10
+ # -- Europe
11
+ bul, Bulgaria, BUL, bg
12
+ frg, West Germany, FRG, de
13
+ gdr, East Germany, GDR, de
14
+ ita, Italy, ITA, it
15
+ ned, Netherlands, NED, nl
16
+ pol, Poland, POL, pl
17
+ sco, Scotland, SCO, sc
18
+ swe, Sweden, SWE, se
19
+ yug, Yugoslavia, YUG, rs
20
+
21
+
22
+ # -- North and Central America
23
+ hai, Haiti, HAI, ht
24
+
25
+ # -- South America
26
+ arg, Argentina, ARG, ar
27
+ bra, Brazil, BRA, br
28
+ chi, Chile, CHI, cl
29
+ uru, Uruguay, URU, uy
@@ -7,67 +7,18 @@
7
7
  require 'minitest/autorun'
8
8
 
9
9
 
10
-
11
- require 'pp'
12
-
13
-
14
- # ruby gems
15
-
16
- require 'active_record'
17
-
18
- require 'worlddb'
19
- require 'logutils'
20
- require 'logutils/db' # NB: explict require required for LogDb (not automatic)
21
- require 'props/db' ## fix: use textutils/db in the future too ??
22
-
23
-
24
10
  ## our own code
25
11
 
26
12
  require 'sportdb'
27
13
 
28
14
 
29
- #######################
30
- #
31
- # for reuse
32
- # --- move to sportdb/test.rb ???
33
- # SportDb.setup_in_memory_db ??? why? why not?? or
34
- # SportDb.setup_test_db - alias ??
35
-
36
-
37
-
38
- def setup_in_memory_db
39
- # Database Setup & Config
40
-
41
- db_config = {
42
- adapter: 'sqlite3',
43
- database: ':memory:'
44
- }
45
-
46
- pp db_config
47
-
48
- ActiveRecord::Base.logger = Logger.new( STDOUT )
49
- ## ActiveRecord::Base.colorize_logging = false - no longer exists - check new api/config setting?
50
-
51
- ## NB: every connect will create a new empty in memory db
52
- ActiveRecord::Base.establish_connection( db_config )
53
-
54
-
55
- ## build schema
56
-
57
- LogDb.create
58
- ConfDb.create
59
- TagDb.create
60
- WorldDb.create
61
- SportDb.create
62
-
63
- SportDb.read_builtin
64
- end
65
-
66
- ####
15
+ #####################
67
16
  # Models shortcuts
68
17
 
69
18
  Country = WorldDb::Model::Country
70
19
 
20
+ Person = PersonDb::Model::Person
21
+
71
22
  League = SportDb::Model::League
72
23
  Season = SportDb::Model::Season
73
24
  Event = SportDb::Model::Event
@@ -77,7 +28,7 @@ Round = SportDb::Model::Round
77
28
  Game = SportDb::Model::Game
78
29
  GameCursor = SportDb::Model::GameCursor
79
30
 
80
- ####
31
+ ####################
81
32
  # Reader shortcuts
82
33
 
83
34
  TeamReader = SportDb::TeamReader
@@ -86,4 +37,8 @@ LeagueReader = SportDb::LeagueReader
86
37
  GameReader = SportDb::GameReader
87
38
 
88
39
 
89
- setup_in_memory_db()
40
+ #################################
41
+ # setup db -> schema / tables
42
+
43
+ SportDb.setup_in_memory_db
44
+
@@ -21,8 +21,10 @@ class TestRoundAuto < MiniTest::Unit::TestCase
21
21
 
22
22
  def add_countries
23
23
  countries = [
24
+ ['cd', 'Congo DR', 'COD' ],
24
25
  ['kr', 'South Korea', 'KOR' ],
25
-
26
+ ['au', 'Australia', 'AUS' ],
27
+
26
28
  ['ar', 'Argentina', 'ARG' ],
27
29
  ['br', 'Brazil', 'BRA' ],
28
30
  ['bo', 'Bolivia', 'BOL' ],
@@ -34,6 +36,7 @@ class TestRoundAuto < MiniTest::Unit::TestCase
34
36
 
35
37
  ['mx', 'Mexico', 'MEX' ],
36
38
  ['us', 'United States', 'USA' ],
39
+ ['ht', 'Haiti', 'HAI' ],
37
40
 
38
41
  ['at', 'Austria', 'AUT' ],
39
42
  ['be', 'Belgium', 'BEL' ],
@@ -51,9 +54,11 @@ class TestRoundAuto < MiniTest::Unit::TestCase
51
54
  ['ch', 'Switzerland', 'SUI' ],
52
55
  ['sc', 'Scotland', 'SCO' ],
53
56
  ['tr', 'Turkey', 'TUR' ],
57
+ ['nl', 'Netherlands', 'NED' ],
58
+ ['pl', 'Poland', 'POL' ],
59
+ ['se', 'Sweden', 'SWE' ],
54
60
  ]
55
61
 
56
-
57
62
  countries.each do |country|
58
63
  key = country[0]
59
64
  name = country[1]
@@ -63,23 +68,89 @@ class TestRoundAuto < MiniTest::Unit::TestCase
63
68
  end
64
69
 
65
70
 
66
- def test_world_cup_1954
71
+ def test_world_cup_1974
67
72
  teamreader = TeamReader.new( SportDb.test_data_path )
68
- teamreader.read( 'world-cup/teams_1954' )
73
+ teamreader.read( 'world-cup/teams_1974' )
69
74
 
70
75
  assert_equal 16, Team.count
71
76
 
72
- br = Team.find_by_key!( 'bra' )
73
- uy = Team.find_by_key!( 'uru' )
74
- be = Team.find_by_key!( 'bel' )
77
+ seasonreader = SeasonReader.new( SportDb.test_data_path )
78
+ seasonreader.read( 'world-cup/seasons_1974')
79
+
80
+ assert_equal 1, Season.count
81
+
82
+ y = Season.find_by_key!( '1974' )
83
+ assert_equal '1974', y.title
84
+
85
+ leaguereader = LeagueReader.new( SportDb.test_data_path )
86
+ leaguereader.read( 'world-cup/leagues' )
87
+
88
+ assert_equal 1, League.count
89
+
90
+ l = League.find_by_key!( 'world' )
91
+ assert_equal 'World Cup', l.title
92
+
93
+ gamereader = GameReader.new( SportDb.test_data_path )
94
+ gamereader.read( 'world-cup/1974/cup' )
75
95
 
76
- assert_equal 'Brazil', br.title
77
- assert_equal 'Uruguay', uy.title
78
- assert_equal 'Belgium', be.title
96
+ assert_equal 1, Event.count
79
97
 
80
- assert_equal 'BRA', br.code
81
- assert_equal 'URU', uy.code
98
+ w = Event.find_by_key!( 'world.1974' )
99
+
100
+ assert_equal 16, w.teams.count
101
+ assert_equal 38, w.games.count
102
+ assert_equal 12, w.rounds.count
103
+
104
+ rounds_exp = [
105
+ [1, 'Matchday 1', '1974-06-13', 1], # first group stage
106
+ [2, 'Matchday 2', '1974-06-14', 3],
107
+ [3, 'Matchday 3', '1974-06-15', 4],
108
+ [4, 'Matchday 4', '1974-06-18', 4],
109
+ [5, 'Matchday 5', '1974-06-19', 4],
110
+ [6, 'Matchday 6', '1974-06-22', 4],
111
+ [7, 'Matchday 7', '1974-06-23', 4],
112
+ [8, 'Matchday 8', '1974-06-26', 4], # second group stage
113
+ [9, 'Matchday 9', '1974-06-30', 4],
114
+ [10, 'Matchday 10', '1974-07-03', 4],
115
+ [11, 'Match for third place', '1974-07-06', 1], # finals
116
+ [12, 'Final', '1974-07-07', 1],
117
+ ]
82
118
 
119
+ assert_rounds( rounds_exp )
120
+
121
+ #########################
122
+ ## 2nd run
123
+ ### try update (e.g. read again - should NOT create new rounds/games/teams)
124
+ #
125
+ # note: update only works if rounds get not deleted or added
126
+ # - (adding for updates works only at the end/tail - not at the beginning or inbetween, for example)
127
+
128
+ gamereader = GameReader.new( SportDb.test_data_path )
129
+ gamereader.read( 'world-cup/1974/cup' )
130
+
131
+ assert_equal 1, Event.count
132
+
133
+ w = Event.find_by_key!( 'world.1974' )
134
+
135
+ assert_equal 16, w.teams.count
136
+ assert_equal 38, w.games.count
137
+ assert_equal 12, w.rounds.count
138
+
139
+ assert_rounds( rounds_exp )
140
+
141
+ end # method test_world_cup_1974
142
+
143
+
144
+ def test_world_cup_1954
145
+ teamreader = TeamReader.new( SportDb.test_data_path )
146
+ teamreader.read( 'world-cup/teams_1954' )
147
+
148
+ assert_equal 16, Team.count
149
+
150
+ assert_teams( [
151
+ [ 'bra', 'Brazil', 'BRA' ],
152
+ [ 'uru', 'Uruguay', 'URU' ],
153
+ [ 'bel', 'Belgium', 'BEL' ] ] )
83
154
 
84
155
  seasonreader = SeasonReader.new( SportDb.test_data_path )
85
156
  seasonreader.read( 'world-cup/seasons_1954')
@@ -134,17 +205,10 @@ class TestRoundAuto < MiniTest::Unit::TestCase
134
205
 
135
206
  assert_equal 13, Team.count
136
207
 
137
- ar = Team.find_by_key!( 'arg' )
138
- br = Team.find_by_key!( 'bra' )
139
- be = Team.find_by_key!( 'bel' )
140
-
141
- assert_equal 'Argentina', ar.title
142
- assert_equal 'Brazil', br.title
143
- assert_equal 'Belgium', be.title
144
-
145
- assert_equal 'ARG', ar.code
146
- assert_equal 'BRA', br.code
147
-
208
+ assert_teams( [
209
+ [ 'arg', 'Argentina', 'ARG' ],
210
+ [ 'bra', 'Brazil', 'BRA' ],
211
+ [ 'bel', 'Belgium', 'BEL' ] ] )
148
212
 
149
213
  seasonreader = SeasonReader.new( SportDb.test_data_path )
150
214
  seasonreader.read( 'world-cup/seasons_1930')
@@ -191,19 +255,6 @@ class TestRoundAuto < MiniTest::Unit::TestCase
191
255
  ]
192
256
 
193
257
  assert_rounds( rounds_exp )
194
-
195
- ##
196
- # auto-numbered knock-out rounds
197
- # r11 = Round.find_by_pos!( 11 )
198
-
199
- # assert_equal 'Semi-finals', r11.title
200
- # assert_equal 2, r11.games.count
201
-
202
- # r12 = Round.find_by_pos!( 12 )
203
-
204
- # assert_equal 'Final', r12.title
205
- # assert_equal 1, r12.games.count
206
-
207
258
  end # method test_world_cup_1930
208
259
 
209
260
 
@@ -213,17 +264,10 @@ class TestRoundAuto < MiniTest::Unit::TestCase
213
264
 
214
265
  assert_equal 16, Team.count
215
266
 
216
- ar = Team.find_by_key!( 'arg' )
217
- br = Team.find_by_key!( 'bra' )
218
- it = Team.find_by_key!( 'ita' )
219
-
220
- assert_equal 'Argentina', ar.title
221
- assert_equal 'Brazil', br.title
222
- assert_equal 'Italy', it.title
223
-
224
- assert_equal 'ARG', ar.code
225
- assert_equal 'BRA', br.code
226
-
267
+ assert_teams( [
268
+ [ 'arg', 'Argentina', 'ARG' ],
269
+ [ 'bra', 'Brazil', 'BRA' ],
270
+ [ 'ita', 'Italy', 'ITA' ] ] )
227
271
 
228
272
  seasonreader = SeasonReader.new( SportDb.test_data_path )
229
273
  seasonreader.read( 'world-cup/seasons_1962')
@@ -313,5 +357,14 @@ class TestRoundAuto < MiniTest::Unit::TestCase
313
357
  end
314
358
  end # method assert_rounds
315
359
 
360
+ def assert_teams( teams_exp )
361
+ teams_exp.each do |team_exp|
362
+ team = Team.find_by_key!( team_exp[0] )
363
+
364
+ assert_equal team_exp[1], team.title
365
+ assert_equal team_exp[2], team.code
366
+ end
367
+ end # method assert_teams
368
+
316
369
 
317
370
  end # class TestRoundAuto
metadata CHANGED
@@ -1,126 +1,183 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.22
5
- prerelease:
4
+ version: 1.8.23
6
5
  platform: ruby
7
6
  authors:
8
7
  - Gerald Bauer
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-05-17 00:00:00.000000000 Z
11
+ date: 2014-05-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: props
16
- requirement: &68241960 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *68241960
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: logutils
27
- requirement: &68241240 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ! '>='
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *68241240
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: textutils
38
- requirement: &68255670 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
45
  - - ! '>='
42
46
  - !ruby/object:Gem::Version
43
47
  version: '0'
44
48
  type: :runtime
45
49
  prerelease: false
46
- version_requirements: *68255670
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: worlddb
49
- requirement: &68255160 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
59
  - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: 2.0.2
55
62
  type: :runtime
56
63
  prerelease: false
57
- version_requirements: *68255160
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.0.2
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: tagutils
60
- requirement: &68254520 !ruby/object:Gem::Requirement
61
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: persondb
85
+ requirement: !ruby/object:Gem::Requirement
62
86
  requirements:
63
87
  - - ! '>='
64
88
  - !ruby/object:Gem::Version
65
89
  version: '0'
66
90
  type: :runtime
67
91
  prerelease: false
68
- version_requirements: *68254520
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: activerecord-utils
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
69
111
  - !ruby/object:Gem::Dependency
70
112
  name: fetcher
71
- requirement: &68254010 !ruby/object:Gem::Requirement
72
- none: false
113
+ requirement: !ruby/object:Gem::Requirement
73
114
  requirements:
74
115
  - - ! '>='
75
116
  - !ruby/object:Gem::Version
76
117
  version: '0.3'
77
118
  type: :runtime
78
119
  prerelease: false
79
- version_requirements: *68254010
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0.3'
80
125
  - !ruby/object:Gem::Dependency
81
126
  name: gli
82
- requirement: &68253470 !ruby/object:Gem::Requirement
83
- none: false
127
+ requirement: !ruby/object:Gem::Requirement
84
128
  requirements:
85
129
  - - ! '>='
86
130
  - !ruby/object:Gem::Version
87
131
  version: 2.5.6
88
132
  type: :runtime
89
133
  prerelease: false
90
- version_requirements: *68253470
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: 2.5.6
91
139
  - !ruby/object:Gem::Dependency
92
140
  name: activerecord
93
- requirement: &68253190 !ruby/object:Gem::Requirement
94
- none: false
141
+ requirement: !ruby/object:Gem::Requirement
95
142
  requirements:
96
143
  - - ! '>='
97
144
  - !ruby/object:Gem::Version
98
145
  version: '0'
99
146
  type: :runtime
100
147
  prerelease: false
101
- version_requirements: *68253190
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ! '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
102
153
  - !ruby/object:Gem::Dependency
103
154
  name: rdoc
104
- requirement: &68252660 !ruby/object:Gem::Requirement
105
- none: false
155
+ requirement: !ruby/object:Gem::Requirement
106
156
  requirements:
107
157
  - - ~>
108
158
  - !ruby/object:Gem::Version
109
159
  version: '4.0'
110
160
  type: :development
111
161
  prerelease: false
112
- version_requirements: *68252660
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ~>
165
+ - !ruby/object:Gem::Version
166
+ version: '4.0'
113
167
  - !ruby/object:Gem::Dependency
114
168
  name: hoe
115
- requirement: &68252210 !ruby/object:Gem::Requirement
116
- none: false
169
+ requirement: !ruby/object:Gem::Requirement
117
170
  requirements:
118
171
  - - ~>
119
172
  - !ruby/object:Gem::Version
120
- version: '3.11'
173
+ version: '3.10'
121
174
  type: :development
122
175
  prerelease: false
123
- version_requirements: *68252210
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ~>
179
+ - !ruby/object:Gem::Version
180
+ version: '3.10'
124
181
  description: sportdb - sport.db command line tool
125
182
  email: opensport@googlegroups.com
126
183
  executables:
@@ -249,13 +306,19 @@ files:
249
306
  - test/data/world-cup/1954/cup.yml
250
307
  - test/data/world-cup/1962/cup.txt
251
308
  - test/data/world-cup/1962/cup.yml
309
+ - test/data/world-cup/1974/cup.yml
310
+ - test/data/world-cup/1974/cup_finals.txt
311
+ - test/data/world-cup/1974/cup_i.txt
312
+ - test/data/world-cup/1974/cup_ii.txt
252
313
  - test/data/world-cup/leagues.txt
253
314
  - test/data/world-cup/seasons_1930.txt
254
315
  - test/data/world-cup/seasons_1954.txt
255
316
  - test/data/world-cup/seasons_1962.txt
317
+ - test/data/world-cup/seasons_1974.txt
256
318
  - test/data/world-cup/teams_1930.txt
257
319
  - test/data/world-cup/teams_1954.txt
258
320
  - test/data/world-cup/teams_1962.txt
321
+ - test/data/world-cup/teams_1974.txt
259
322
  - test/helper.rb
260
323
  - test/test_changes.rb
261
324
  - test/test_cursor.rb
@@ -272,6 +335,7 @@ files:
272
335
  homepage: https://github.com/geraldb/sport.db.ruby
273
336
  licenses:
274
337
  - Public Domain
338
+ metadata: {}
275
339
  post_install_message: ! '******************************************************************************
276
340
 
277
341
 
@@ -289,32 +353,30 @@ rdoc_options:
289
353
  require_paths:
290
354
  - lib
291
355
  required_ruby_version: !ruby/object:Gem::Requirement
292
- none: false
293
356
  requirements:
294
357
  - - ! '>='
295
358
  - !ruby/object:Gem::Version
296
359
  version: 1.9.2
297
360
  required_rubygems_version: !ruby/object:Gem::Requirement
298
- none: false
299
361
  requirements:
300
362
  - - ! '>='
301
363
  - !ruby/object:Gem::Version
302
364
  version: '0'
303
365
  requirements: []
304
366
  rubyforge_project:
305
- rubygems_version: 1.8.17
367
+ rubygems_version: 2.1.10
306
368
  signing_key:
307
- specification_version: 3
369
+ specification_version: 4
308
370
  summary: sportdb - sport.db command line tool
309
371
  test_files:
372
+ - test/test_changes.rb
373
+ - test/test_cursor.rb
310
374
  - test/test_date.rb
311
375
  - test/test_lang.rb
312
- - test/test_cursor.rb
313
- - test/test_scores.rb
314
- - test/test_winner.rb
376
+ - test/test_reader.rb
377
+ - test/test_round_auto.rb
315
378
  - test/test_round_def.rb
316
- - test/test_utils.rb
317
379
  - test/test_round_header.rb
318
- - test/test_round_auto.rb
319
- - test/test_reader.rb
320
- - test/test_changes.rb
380
+ - test/test_scores.rb
381
+ - test/test_utils.rb
382
+ - test/test_winner.rb