sportdb-models 1.18.5 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/Manifest.txt +27 -145
  3. data/Rakefile +4 -5
  4. data/lib/sportdb/models.rb +93 -160
  5. data/lib/sportdb/{deleter.rb → models/deleter.rb} +4 -10
  6. data/lib/sportdb/models/formats.rb +23 -0
  7. data/lib/sportdb/models/models/assoc.rb +38 -0
  8. data/lib/sportdb/models/{badge.rb → models/badge.rb} +1 -1
  9. data/lib/sportdb/models/models/event.rb +55 -0
  10. data/lib/sportdb/models/{forward.rb → models/forward.rb} +3 -3
  11. data/lib/sportdb/models/{goal.rb → models/goal.rb} +1 -1
  12. data/lib/sportdb/models/models/ground.rb +16 -0
  13. data/lib/sportdb/models/{group.rb → models/group.rb} +10 -7
  14. data/lib/sportdb/models/models/league.rb +20 -0
  15. data/lib/sportdb/models/{roster.rb → models/lineup.rb} +3 -4
  16. data/lib/sportdb/models/{game.rb → models/match.rb} +18 -61
  17. data/lib/sportdb/models/{person.rb → models/person.rb} +0 -0
  18. data/lib/sportdb/models/{round.rb → models/round.rb} +1 -6
  19. data/lib/sportdb/models/{season.rb → models/season.rb} +2 -1
  20. data/lib/sportdb/models/{stage.rb → models/stage.rb} +9 -5
  21. data/lib/sportdb/models/{stats/alltime_standing_entry.rb → models/stats/alltime_standing.rb} +9 -1
  22. data/lib/sportdb/models/{stats/event_standing_entry.rb → models/stats/event_standing.rb} +11 -1
  23. data/lib/sportdb/models/{stats/group_standing_entry.rb → models/stats/group_standing.rb} +10 -1
  24. data/lib/sportdb/models/models/team.rb +56 -0
  25. data/lib/sportdb/models/{world → models/world}/city.rb +2 -2
  26. data/lib/sportdb/models/{world → models/world}/continent.rb +0 -0
  27. data/lib/sportdb/models/{world → models/world}/country.rb +0 -0
  28. data/lib/sportdb/models/{world → models/world}/state.rb +0 -0
  29. data/lib/sportdb/{schema.rb → models/schema.rb} +165 -100
  30. data/lib/sportdb/models/stats.rb +23 -0
  31. data/lib/sportdb/models/utils.rb +24 -24
  32. data/lib/sportdb/{version.rb → models/version.rb} +12 -5
  33. data/test/helper.rb +10 -114
  34. data/test/test_changes.rb +38 -38
  35. data/test/test_cursor.rb +15 -15
  36. data/test/test_winner.rb +75 -70
  37. metadata +29 -161
  38. data/lib/sportdb/calc.rb +0 -279
  39. data/lib/sportdb/indexers/team.rb +0 -87
  40. data/lib/sportdb/mapper_teams.rb +0 -24
  41. data/lib/sportdb/matcher.rb +0 -31
  42. data/lib/sportdb/models/assoc.rb +0 -106
  43. data/lib/sportdb/models/assoc_assoc.rb +0 -15
  44. data/lib/sportdb/models/event.rb +0 -66
  45. data/lib/sportdb/models/event_ground.rb +0 -15
  46. data/lib/sportdb/models/event_team.rb +0 -16
  47. data/lib/sportdb/models/ground.rb +0 -100
  48. data/lib/sportdb/models/group_team.rb +0 -14
  49. data/lib/sportdb/models/league.rb +0 -83
  50. data/lib/sportdb/models/stage_team.rb +0 -14
  51. data/lib/sportdb/models/stats/alltime_standing.rb +0 -44
  52. data/lib/sportdb/models/stats/event_standing.rb +0 -55
  53. data/lib/sportdb/models/stats/group_standing.rb +0 -50
  54. data/lib/sportdb/models/team.rb +0 -119
  55. data/lib/sportdb/models/team_compat.rb +0 -64
  56. data/lib/sportdb/patterns.rb +0 -37
  57. data/lib/sportdb/pretty_printer.rb +0 -175
  58. data/lib/sportdb/reader.rb +0 -132
  59. data/lib/sportdb/reader_file.rb +0 -131
  60. data/lib/sportdb/reader_zip.rb +0 -172
  61. data/lib/sportdb/readers/assoc.rb +0 -54
  62. data/lib/sportdb/readers/event.rb +0 -253
  63. data/lib/sportdb/readers/event_meta.rb +0 -133
  64. data/lib/sportdb/readers/event_table.rb +0 -196
  65. data/lib/sportdb/readers/game.rb +0 -912
  66. data/lib/sportdb/readers/ground.rb +0 -53
  67. data/lib/sportdb/readers/league.rb +0 -54
  68. data/lib/sportdb/readers/season.rb +0 -83
  69. data/lib/sportdb/readers/squad_club.rb +0 -201
  70. data/lib/sportdb/readers/squad_national_team.rb +0 -173
  71. data/lib/sportdb/readers/team.rb +0 -53
  72. data/lib/sportdb/rsssf_reader.rb +0 -367
  73. data/lib/sportdb/standings.rb +0 -178
  74. data/lib/sportdb/stats.rb +0 -27
  75. data/lib/sportdb/utils.rb +0 -89
  76. data/lib/sportdb/utils_date.rb +0 -26
  77. data/lib/sportdb/utils_goals.rb +0 -20
  78. data/lib/sportdb/utils_group.rb +0 -63
  79. data/lib/sportdb/utils_map.rb +0 -44
  80. data/lib/sportdb/utils_round.rb +0 -165
  81. data/lib/sportdb/utils_scores.rb +0 -17
  82. data/lib/sportdb/utils_teams.rb +0 -48
  83. data/test/data/at-austria/2013_14/bl.txt +0 -227
  84. data/test/data/at-austria/2013_14/bl.yml +0 -30
  85. data/test/data/at-austria/2013_14/bl_ii.txt +0 -154
  86. data/test/data/at-austria/2013_14/el.txt +0 -4
  87. data/test/data/at-austria/2013_14/el.yml +0 -25
  88. data/test/data/at-austria/2013_14/squads/austria.txt +0 -40
  89. data/test/data/at-austria/2013_14/squads/salzburg.txt +0 -35
  90. data/test/data/at-austria/2014_15/1-bundesliga-ii.txt +0 -158
  91. data/test/data/at-austria/2014_15/1-bundesliga.yml +0 -18
  92. data/test/data/at-austria/2015_16/1-bundesliga-v2.conf.txt +0 -20
  93. data/test/data/at-austria/2015_16/1-bundesliga-v2.yml +0 -20
  94. data/test/data/at-austria/2015_16/1-bundesliga.conf.txt +0 -20
  95. data/test/data/at-austria/2015_16/1-bundesliga.yml +0 -24
  96. data/test/data/at-austria/2015_16/cup.yml +0 -77
  97. data/test/data/at-austria/leagues.txt +0 -11
  98. data/test/data/at-austria/teams.txt +0 -68
  99. data/test/data/at-austria/teams_2.txt +0 -21
  100. data/test/data/csv/de-2013-14--1-bundesliga.txt +0 -307
  101. data/test/data/de-deutschland/2013-14/1-bundesliga.yml +0 -26
  102. data/test/data/de-deutschland/leagues.txt +0 -4
  103. data/test/data/de-deutschland/teams.txt +0 -53
  104. data/test/data/eng-england/2015-16/1-premierleague-v2.yml +0 -2
  105. data/test/data/eng-england/2015-16/1-premierleague.yml +0 -5
  106. data/test/data/national-teams/assocs.txt +0 -231
  107. data/test/data/national-teams/europe/assocs.txt +0 -13
  108. data/test/data/national-teams/europe/teams.txt +0 -13
  109. data/test/data/national-teams/north-america/assocs.txt +0 -10
  110. data/test/data/national-teams/north-america/teams.txt +0 -7
  111. data/test/data/national-teams/teams.txt +0 -19
  112. data/test/data/players/europe/at-austria/players.txt +0 -45
  113. data/test/data/players/europe/de-deutschland/players.txt +0 -41
  114. data/test/data/players/south-america/br-brazil/players.txt +0 -51
  115. data/test/data/rsssf/at-2014-15--1-bundesliga.txt +0 -339
  116. data/test/data/rsssf/at-2015-16--1-bundesliga.txt +0 -18
  117. data/test/data/world-cup/1930/cup.txt +0 -71
  118. data/test/data/world-cup/1930/cup.yml +0 -23
  119. data/test/data/world-cup/1930/cup_goals.txt +0 -47
  120. data/test/data/world-cup/1930/cup_goals.yml +0 -23
  121. data/test/data/world-cup/1954/cup.txt +0 -90
  122. data/test/data/world-cup/1954/cup.yml +0 -30
  123. data/test/data/world-cup/1962/cup.txt +0 -86
  124. data/test/data/world-cup/1962/cup.yml +0 -32
  125. data/test/data/world-cup/1974/cup.yml +0 -35
  126. data/test/data/world-cup/1974/cup_finals.txt +0 -14
  127. data/test/data/world-cup/1974/cup_i.txt +0 -55
  128. data/test/data/world-cup/1974/cup_ii.txt +0 -34
  129. data/test/data/world-cup/2014/cup.txt +0 -5
  130. data/test/data/world-cup/2014/cup.yml +0 -54
  131. data/test/data/world-cup/2014/squads/br-brazil.txt +0 -46
  132. data/test/data/world-cup/2014/squads/de-deutschland.txt +0 -8
  133. data/test/data/world-cup/2014/squads/jp-japan.txt +0 -30
  134. data/test/data/world-cup/2014/squads/uy-uruguay.txt +0 -32
  135. data/test/data/world-cup/leagues.txt +0 -5
  136. data/test/data/world-cup/seasons_1930.txt +0 -4
  137. data/test/data/world-cup/seasons_1954.txt +0 -4
  138. data/test/data/world-cup/seasons_1962.txt +0 -4
  139. data/test/data/world-cup/seasons_1974.txt +0 -5
  140. data/test/data/world-cup/teams_1930.txt +0 -26
  141. data/test/data/world-cup/teams_1954.txt +0 -30
  142. data/test/data/world-cup/teams_1962.txt +0 -29
  143. data/test/data/world-cup/teams_1974.txt +0 -29
  144. data/test/test_assoc_reader.rb +0 -199
  145. data/test/test_event_meta_reader.rb +0 -47
  146. data/test/test_event_reader.rb +0 -64
  147. data/test/test_event_table_reader.rb +0 -57
  148. data/test/test_goals.rb +0 -107
  149. data/test/test_indexer_team.rb +0 -34
  150. data/test/test_load.rb +0 -61
  151. data/test/test_pp.rb +0 -35
  152. data/test/test_reader.rb +0 -88
  153. data/test/test_reader_from_string.rb +0 -63
  154. data/test/test_round_auto.rb +0 -370
  155. data/test/test_round_def.rb +0 -109
  156. data/test/test_round_header.rb +0 -183
  157. data/test/test_rsssf_reader.rb +0 -76
  158. data/test/test_squad_club_reader.rb +0 -76
  159. data/test/test_squad_national_team_reader.rb +0 -116
  160. data/test/test_standings.rb +0 -279
  161. data/test/test_standings_ii.rb +0 -46
  162. data/test/test_utils.rb +0 -124
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54708fea040f5de13230b7e12432946df3a7d91c
4
- data.tar.gz: 1ecebd1aa8c1052f7ffbbd12dd0588fbd174b56e
3
+ metadata.gz: 5f0d4c37492676024c57f08909596a413991d8b9
4
+ data.tar.gz: 7793d7a13474b8a2cea45b94fcbd4261b7e87984
5
5
  SHA512:
6
- metadata.gz: eda15ddd287189de9c2610dd511e66138974ac92782735148a2a9e73d699627f0e80cac443e89fa954e24648345f9b0f266c417388532ab145528a032cc93786
7
- data.tar.gz: 15ebaebd875ca30aed2ab6b7565a34e816f9c155e2f3d1b3e9d12e932e6d6d4a27c126580c269084108896ce42b799b19f64314fc6a714b2f71d008fd01692ca
6
+ metadata.gz: 275bf0569a3622579837ce8866621365176d7c91d6655a5051e3163ef000b86210fb88afc34da2edf873e219e13f2841ad2c15d925bbfc5f19a61deab0de6d6c
7
+ data.tar.gz: ff8bb5dafa8741e6e5d3c514ee32ec67cbd74c2a8a40d2f8af19cb2ac0f212741de72c2e29da12765ec6b0ac3b10845f0c83891ecfa67b3ae2514699b32b119b
@@ -2,154 +2,36 @@ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
- lib/sportdb/calc.rb
6
- lib/sportdb/deleter.rb
7
- lib/sportdb/indexers/team.rb
8
- lib/sportdb/mapper_teams.rb
9
- lib/sportdb/matcher.rb
10
5
  lib/sportdb/models.rb
11
- lib/sportdb/models/assoc.rb
12
- lib/sportdb/models/assoc_assoc.rb
13
- lib/sportdb/models/badge.rb
14
- lib/sportdb/models/event.rb
15
- lib/sportdb/models/event_ground.rb
16
- lib/sportdb/models/event_team.rb
17
- lib/sportdb/models/forward.rb
18
- lib/sportdb/models/game.rb
19
- lib/sportdb/models/goal.rb
20
- lib/sportdb/models/ground.rb
21
- lib/sportdb/models/group.rb
22
- lib/sportdb/models/group_team.rb
23
- lib/sportdb/models/league.rb
24
- lib/sportdb/models/person.rb
25
- lib/sportdb/models/roster.rb
26
- lib/sportdb/models/round.rb
27
- lib/sportdb/models/season.rb
28
- lib/sportdb/models/stage.rb
29
- lib/sportdb/models/stage_team.rb
30
- lib/sportdb/models/stats/alltime_standing.rb
31
- lib/sportdb/models/stats/alltime_standing_entry.rb
32
- lib/sportdb/models/stats/event_standing.rb
33
- lib/sportdb/models/stats/event_standing_entry.rb
34
- lib/sportdb/models/stats/group_standing.rb
35
- lib/sportdb/models/stats/group_standing_entry.rb
36
- lib/sportdb/models/team.rb
37
- lib/sportdb/models/team_compat.rb
6
+ lib/sportdb/models/deleter.rb
7
+ lib/sportdb/models/formats.rb
8
+ lib/sportdb/models/models/assoc.rb
9
+ lib/sportdb/models/models/badge.rb
10
+ lib/sportdb/models/models/event.rb
11
+ lib/sportdb/models/models/forward.rb
12
+ lib/sportdb/models/models/goal.rb
13
+ lib/sportdb/models/models/ground.rb
14
+ lib/sportdb/models/models/group.rb
15
+ lib/sportdb/models/models/league.rb
16
+ lib/sportdb/models/models/lineup.rb
17
+ lib/sportdb/models/models/match.rb
18
+ lib/sportdb/models/models/person.rb
19
+ lib/sportdb/models/models/round.rb
20
+ lib/sportdb/models/models/season.rb
21
+ lib/sportdb/models/models/stage.rb
22
+ lib/sportdb/models/models/stats/alltime_standing.rb
23
+ lib/sportdb/models/models/stats/event_standing.rb
24
+ lib/sportdb/models/models/stats/group_standing.rb
25
+ lib/sportdb/models/models/team.rb
26
+ lib/sportdb/models/models/world/city.rb
27
+ lib/sportdb/models/models/world/continent.rb
28
+ lib/sportdb/models/models/world/country.rb
29
+ lib/sportdb/models/models/world/state.rb
30
+ lib/sportdb/models/schema.rb
31
+ lib/sportdb/models/stats.rb
38
32
  lib/sportdb/models/utils.rb
39
- lib/sportdb/models/world/city.rb
40
- lib/sportdb/models/world/continent.rb
41
- lib/sportdb/models/world/country.rb
42
- lib/sportdb/models/world/state.rb
43
- lib/sportdb/patterns.rb
44
- lib/sportdb/pretty_printer.rb
45
- lib/sportdb/reader.rb
46
- lib/sportdb/reader_file.rb
47
- lib/sportdb/reader_zip.rb
48
- lib/sportdb/readers/assoc.rb
49
- lib/sportdb/readers/event.rb
50
- lib/sportdb/readers/event_meta.rb
51
- lib/sportdb/readers/event_table.rb
52
- lib/sportdb/readers/game.rb
53
- lib/sportdb/readers/ground.rb
54
- lib/sportdb/readers/league.rb
55
- lib/sportdb/readers/season.rb
56
- lib/sportdb/readers/squad_club.rb
57
- lib/sportdb/readers/squad_national_team.rb
58
- lib/sportdb/readers/team.rb
59
- lib/sportdb/rsssf_reader.rb
60
- lib/sportdb/schema.rb
61
- lib/sportdb/standings.rb
62
- lib/sportdb/stats.rb
63
- lib/sportdb/utils.rb
64
- lib/sportdb/utils_date.rb
65
- lib/sportdb/utils_goals.rb
66
- lib/sportdb/utils_group.rb
67
- lib/sportdb/utils_map.rb
68
- lib/sportdb/utils_round.rb
69
- lib/sportdb/utils_scores.rb
70
- lib/sportdb/utils_teams.rb
71
- lib/sportdb/version.rb
72
- test/data/at-austria/2013_14/bl.txt
73
- test/data/at-austria/2013_14/bl.yml
74
- test/data/at-austria/2013_14/bl_ii.txt
75
- test/data/at-austria/2013_14/el.txt
76
- test/data/at-austria/2013_14/el.yml
77
- test/data/at-austria/2013_14/squads/austria.txt
78
- test/data/at-austria/2013_14/squads/salzburg.txt
79
- test/data/at-austria/2014_15/1-bundesliga-ii.txt
80
- test/data/at-austria/2014_15/1-bundesliga.yml
81
- test/data/at-austria/2015_16/1-bundesliga-v2.conf.txt
82
- test/data/at-austria/2015_16/1-bundesliga-v2.yml
83
- test/data/at-austria/2015_16/1-bundesliga.conf.txt
84
- test/data/at-austria/2015_16/1-bundesliga.yml
85
- test/data/at-austria/2015_16/cup.yml
86
- test/data/at-austria/leagues.txt
87
- test/data/at-austria/teams.txt
88
- test/data/at-austria/teams_2.txt
89
- test/data/csv/de-2013-14--1-bundesliga.txt
90
- test/data/de-deutschland/2013-14/1-bundesliga.yml
91
- test/data/de-deutschland/leagues.txt
92
- test/data/de-deutschland/teams.txt
93
- test/data/eng-england/2015-16/1-premierleague-v2.yml
94
- test/data/eng-england/2015-16/1-premierleague.yml
95
- test/data/national-teams/assocs.txt
96
- test/data/national-teams/europe/assocs.txt
97
- test/data/national-teams/europe/teams.txt
98
- test/data/national-teams/north-america/assocs.txt
99
- test/data/national-teams/north-america/teams.txt
100
- test/data/national-teams/teams.txt
101
- test/data/players/europe/at-austria/players.txt
102
- test/data/players/europe/de-deutschland/players.txt
103
- test/data/players/south-america/br-brazil/players.txt
104
- test/data/rsssf/at-2014-15--1-bundesliga.txt
105
- test/data/rsssf/at-2015-16--1-bundesliga.txt
106
- test/data/world-cup/1930/cup.txt
107
- test/data/world-cup/1930/cup.yml
108
- test/data/world-cup/1930/cup_goals.txt
109
- test/data/world-cup/1930/cup_goals.yml
110
- test/data/world-cup/1954/cup.txt
111
- test/data/world-cup/1954/cup.yml
112
- test/data/world-cup/1962/cup.txt
113
- test/data/world-cup/1962/cup.yml
114
- test/data/world-cup/1974/cup.yml
115
- test/data/world-cup/1974/cup_finals.txt
116
- test/data/world-cup/1974/cup_i.txt
117
- test/data/world-cup/1974/cup_ii.txt
118
- test/data/world-cup/2014/cup.txt
119
- test/data/world-cup/2014/cup.yml
120
- test/data/world-cup/2014/squads/br-brazil.txt
121
- test/data/world-cup/2014/squads/de-deutschland.txt
122
- test/data/world-cup/2014/squads/jp-japan.txt
123
- test/data/world-cup/2014/squads/uy-uruguay.txt
124
- test/data/world-cup/leagues.txt
125
- test/data/world-cup/seasons_1930.txt
126
- test/data/world-cup/seasons_1954.txt
127
- test/data/world-cup/seasons_1962.txt
128
- test/data/world-cup/seasons_1974.txt
129
- test/data/world-cup/teams_1930.txt
130
- test/data/world-cup/teams_1954.txt
131
- test/data/world-cup/teams_1962.txt
132
- test/data/world-cup/teams_1974.txt
33
+ lib/sportdb/models/version.rb
133
34
  test/helper.rb
134
- test/test_assoc_reader.rb
135
35
  test/test_changes.rb
136
36
  test/test_cursor.rb
137
- test/test_event_meta_reader.rb
138
- test/test_event_reader.rb
139
- test/test_event_table_reader.rb
140
- test/test_goals.rb
141
- test/test_indexer_team.rb
142
- test/test_load.rb
143
- test/test_pp.rb
144
- test/test_reader.rb
145
- test/test_reader_from_string.rb
146
- test/test_round_auto.rb
147
- test/test_round_def.rb
148
- test/test_round_header.rb
149
- test/test_rsssf_reader.rb
150
- test/test_squad_club_reader.rb
151
- test/test_squad_national_team_reader.rb
152
- test/test_standings.rb
153
- test/test_standings_ii.rb
154
- test/test_utils.rb
155
37
  test/test_winner.rb
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
1
  require 'hoe'
2
- require './lib/sportdb/version.rb'
2
+ require './lib/sportdb/models/version.rb'
3
3
 
4
4
 
5
5
  Hoe.spec 'sportdb-models' do
6
6
 
7
- self.version = SportDb::VERSION
7
+ self.version = SportDb::Module::Models::VERSION
8
8
 
9
9
  self.summary = "sportdb-models - sport.db schema 'n' models for easy (re)use"
10
10
  self.description = summary
@@ -20,9 +20,8 @@ Hoe.spec 'sportdb-models' do
20
20
  self.history_file = 'CHANGELOG.md'
21
21
 
22
22
  self.extra_deps = [
23
- ['worlddb-models', '>= 2.4.0'], # Note: pull in all (extra) dependencies va worlddb-models
24
- ['persondb-models', '>= 0.5.0'], # persons (people) table
25
- ['sportdb-formats', '>= 0.1.2'],
23
+ ['worlddb-models', '>= 2.4.0'], # Note: pull in all (extra) dependencies va worlddb-models
24
+ ['persondb-models', '>= 0.5.0'], # persons (people) table
26
25
  ]
27
26
 
28
27
  self.licenses = ['Public Domain']
@@ -6,103 +6,46 @@ require 'worlddb/models' # NOTE: include worlddb-models gem (not cli tools g
6
6
  require 'persondb/models'
7
7
 
8
8
 
9
- require 'sportdb/formats' ## todo/fix: move all readers out-of-models AND than (finally) remove sportdb/formats dependency
9
+ # our own code
10
10
 
11
+ require 'sportdb/models/version' # let version always go first
11
12
 
13
+ require 'sportdb/models/formats'
14
+ require 'sportdb/models/models/forward'
12
15
 
13
- # our own code
16
+ require 'sportdb/models/models/world/city'
17
+ require 'sportdb/models/models/world/country'
18
+ require 'sportdb/models/models/world/continent'
19
+ require 'sportdb/models/models/world/state'
14
20
 
15
- require 'sportdb/version' # let version always go first
16
-
17
- require 'sportdb/patterns'
18
- require 'sportdb/models/forward'
19
- require 'sportdb/models/world/city'
20
- require 'sportdb/models/world/country'
21
- require 'sportdb/models/world/continent'
22
- require 'sportdb/models/world/state'
23
- require 'sportdb/models/assoc'
24
- require 'sportdb/models/assoc_assoc'
25
- require 'sportdb/models/badge'
26
- require 'sportdb/models/event'
27
- require 'sportdb/models/event_ground'
28
- require 'sportdb/models/event_team'
29
- require 'sportdb/models/game'
30
- require 'sportdb/models/goal'
31
- require 'sportdb/models/ground'
32
- require 'sportdb/models/group'
33
- require 'sportdb/models/group_team'
34
- require 'sportdb/models/league'
35
- require 'sportdb/models/person'
36
- require 'sportdb/models/roster'
37
- require 'sportdb/models/round'
38
- require 'sportdb/models/season'
39
- require 'sportdb/models/stage'
40
- require 'sportdb/models/stage_team'
41
- require 'sportdb/models/team'
42
- require 'sportdb/models/team_compat' ### fix/todo: move to compat gem !!!!!
43
-
44
-
45
- require 'sportdb/models/stats/alltime_standing'
46
- require 'sportdb/models/stats/alltime_standing_entry'
47
- require 'sportdb/models/stats/event_standing'
48
- require 'sportdb/models/stats/event_standing_entry'
49
- require 'sportdb/models/stats/group_standing'
50
- require 'sportdb/models/stats/group_standing_entry'
51
-
52
- require 'sportdb/models/utils' # e.g. GameCursor
53
-
54
-
55
- require 'sportdb/schema' # NB: requires sportdb/models (include SportDB::Models)
56
-
57
-
58
- require 'sportdb/utils'
59
- require 'sportdb/utils_date'
60
- require 'sportdb/utils_group'
61
- require 'sportdb/utils_map'
62
- require 'sportdb/utils_round'
63
- require 'sportdb/utils_scores'
64
- require 'sportdb/utils_teams'
65
- require 'sportdb/utils_goals'
66
- require 'sportdb/matcher'
67
- require 'sportdb/calc' # fix/todo: obsolete - replace w/ standings
68
- require 'sportdb/standings'
69
- require 'sportdb/mapper_teams'
70
-
71
-
72
- require 'sportdb/readers/assoc'
73
- require 'sportdb/readers/event' ## old event reader (remove later??)
74
- require 'sportdb/readers/event_table' ## new "standard" event reader
75
- require 'sportdb/readers/event_meta' ## new "standard" event reader for meta data
76
- require 'sportdb/readers/game'
77
- require 'sportdb/readers/ground'
78
- require 'sportdb/readers/league'
79
- require 'sportdb/readers/season'
80
- require 'sportdb/readers/squad_club' # roster
81
- require 'sportdb/readers/squad_national_team'
82
- require 'sportdb/readers/team'
83
- require 'sportdb/reader'
84
- require 'sportdb/reader_file'
85
- require 'sportdb/reader_zip'
86
-
87
- require 'sportdb/indexers/team'
88
-
89
-
90
- require 'sportdb/deleter'
91
- require 'sportdb/stats'
92
-
93
- require 'sportdb/pretty_printer'
94
-
95
- ## "simplified" match reader for rsssf-formated/style leagues
96
- require 'sportdb/rsssf_reader'
21
+ require 'sportdb/models/models/assoc'
22
+ require 'sportdb/models/models/badge'
23
+ require 'sportdb/models/models/event'
24
+ require 'sportdb/models/models/goal'
25
+ require 'sportdb/models/models/ground'
26
+ require 'sportdb/models/models/group'
27
+ require 'sportdb/models/models/league'
28
+ require 'sportdb/models/models/lineup'
29
+ require 'sportdb/models/models/match'
30
+ require 'sportdb/models/models/person'
31
+ require 'sportdb/models/models/round'
32
+ require 'sportdb/models/models/season'
33
+ require 'sportdb/models/models/stage'
34
+ require 'sportdb/models/models/team'
97
35
 
36
+ require 'sportdb/models/models/stats/alltime_standing'
37
+ require 'sportdb/models/models/stats/event_standing'
38
+ require 'sportdb/models/models/stats/group_standing'
98
39
 
99
- module SportDb
40
+ require 'sportdb/models/schema' # note: requires sportdb/models (include SportDB::Models)
100
41
 
101
- def self.test_data_path
102
- "#{root}/test/data"
103
- end
42
+ require 'sportdb/models/utils' # e.g. MatchCursor
43
+
44
+ require 'sportdb/models/deleter'
45
+ require 'sportdb/models/stats'
104
46
 
105
47
 
48
+ module SportDb
106
49
 
107
50
  def self.create
108
51
  CreateDb.new.up
@@ -119,52 +62,12 @@ module SportDb
119
62
  SportDb.create
120
63
  end
121
64
 
122
-
123
- def self.read_setup( setup, include_path )
124
- reader = Reader.new( include_path )
125
- reader.load_setup( setup )
126
- end
127
-
128
- def self.read_setup_from_zip( zip_name, setup, include_path, opts={} ) ## todo/check - use a better (shorter) name ??
129
- reader = ZipReader.new( zip_name, include_path, opts )
130
- reader.load_setup( setup )
131
- reader.close
132
- end
133
-
134
- def self.read_all( include_path ) # convenience helper
135
- read_setup( 'setups/all', include_path )
136
- end
137
-
138
- def self.read_builtin
139
- puts "!! WARN - deprecated SportDb.read_builtin call - remove!! no longer in use; will get removed soon"
140
- end
141
-
142
-
143
- # load built-in (that is, bundled within the gem) named plain text seeds
144
- # - pass in an array of pairs of event/seed names e.g.
145
- # [['at.2012/13', 'at/2012_13/bl'],
146
- # ['cl.2012/13', 'cl/2012_13/cl']] etc.
147
-
148
- def self.read( ary, include_path )
149
- reader = Reader.new( include_path )
150
- ## todo: check kind_of?( Array ) or kind_of?(String) to support array or string
151
- ary.each do |name|
152
- reader.load( name )
153
- end
154
- end
155
-
156
-
157
65
  # delete ALL records (use with care!)
158
66
  def self.delete!
159
67
  puts '*** deleting sport table records/data...'
160
68
  Deleter.new.run
161
69
  end # method delete!
162
70
 
163
- def self.update!
164
- puts '*** update event fixtures...'
165
- Updater.new.run
166
- end
167
-
168
71
 
169
72
  def self.tables
170
73
  Stats.new.tables
@@ -179,32 +82,36 @@ module SportDb
179
82
  ### change default to ./sport.db ?? why? why not?
180
83
  db = URI.parse( ENV['DATABASE_URL'] || 'sqlite3:///sport.db' )
181
84
 
182
- if db.scheme == 'postgres'
183
- config = {
184
- adapter: 'postgresql',
185
- host: db.host,
186
- port: db.port,
187
- username: db.user,
188
- password: db.password,
189
- database: db.path[1..-1],
190
- encoding: 'utf8'
191
- }
192
- else # assume sqlite3
193
- config = {
194
- adapter: db.scheme, # sqlite3
195
- database: db.path[1..-1] # sport.db (NB: cut off leading /, thus 1..-1)
196
- }
197
- end
85
+ config = if db.scheme == 'postgres'
86
+ { adapter: 'postgresql',
87
+ host: db.host,
88
+ port: db.port,
89
+ username: db.user,
90
+ password: db.password,
91
+ database: db.path[1..-1],
92
+ encoding: 'utf8'
93
+ }
94
+ else # assume sqlite3
95
+ { adapter: db.scheme, # sqlite3
96
+ database: db.path[1..-1] # sport.db (NB: cut off leading /, thus 1..-1)
97
+ }
98
+ end
99
+ else
100
+ ## note: for compatibility lets you also pass-in/use string keys
101
+ ## e.g. YAML.load uses/returns always string keys - always auto-convert to symbols
102
+ config = config.symbolize_keys
198
103
  end
199
104
 
105
+
106
+ ## todo/check/fix: move jruby "hack" to attic - why? why not?
200
107
  ## todo/check: use if defined?( JRUBY_VERSION ) instead ??
201
- if RUBY_PLATFORM =~ /java/ && config[:adapter] == 'sqlite3'
108
+ ## if RUBY_PLATFORM =~ /java/ && config[:adapter] == 'sqlite3'
202
109
  # quick hack for JRuby sqlite3 support via jdbc
203
- puts "jruby quick hack - adding jdbc libs for jruby sqlite3 database support"
204
- require 'jdbc/sqlite3'
205
- require 'active_record/connection_adapters/jdbc_adapter'
206
- require 'active_record/connection_adapters/jdbcsqlite3_adapter'
207
- end
110
+ ## puts "jruby quick hack - adding jdbc libs for jruby sqlite3 database support"
111
+ ## require 'jdbc/sqlite3'
112
+ ## require 'active_record/connection_adapters/jdbc_adapter'
113
+ ## require 'active_record/connection_adapters/jdbcsqlite3_adapter'
114
+ ## end
208
115
 
209
116
  puts "Connecting to db using settings: "
210
117
  pp config
@@ -212,8 +119,11 @@ module SportDb
212
119
  # ActiveRecord::Base.logger = Logger.new( STDOUT )
213
120
 
214
121
  ## if sqlite3 add (use) some pragmas for speedups
215
- if config[:adapter] == 'sqlite3'
216
- ## check/todo: if in memory e.g. ':memory:' no pragma needed!!
122
+ if config[:adapter] == 'sqlite3' &&
123
+ config[:database] != ':memory:'
124
+ ## note: if in memory database e.g. ':memory:' no pragma needed!!
125
+ ## try to speed up sqlite
126
+ ## see http://www.sqlite.org/pragma.html
217
127
  con = ActiveRecord::Base.connection
218
128
  con.execute( 'PRAGMA synchronous=OFF;' )
219
129
  con.execute( 'PRAGMA journal_mode=OFF;' )
@@ -223,24 +133,47 @@ module SportDb
223
133
 
224
134
 
225
135
  def self.setup_in_memory_db
226
-
227
136
  # Database Setup & Config
228
137
  ActiveRecord::Base.logger = Logger.new( STDOUT )
229
138
  ## ActiveRecord::Base.colorize_logging = false - no longer exists - check new api/config setting?
230
139
 
231
- self.connect( adapter: 'sqlite3',
232
- database: ':memory:' )
140
+ connect( adapter: 'sqlite3',
141
+ database: ':memory:' )
233
142
 
234
143
  ## build schema
235
- SportDb.create_all
236
-
237
- ## read builtins - why? why not?
238
- SportDb.read_builtin
144
+ create_all
239
145
  end # setup_in_memory_db (using SQLite :memory:)
240
146
 
241
147
 
242
148
  end # module SportDb
243
149
 
244
150
 
151
+
152
+ module SportDb
153
+ module Model
154
+ ##################
155
+ # add alias why? why not?
156
+ #
157
+ # more aliases to consider:
158
+ # - Tournament for Event?
159
+ # - Cup for League?
160
+ # - Roster for Lineup?
161
+ # - Stadium for Ground? - why? why not?
162
+
163
+
164
+ Competition = Event
165
+ Comp = Event
166
+
167
+ LineUp = Lineup
168
+ Squad = Lineup
169
+
170
+ Game = Match ## add (old) alias - why? why not?
171
+ end # module Model
172
+ end # module SportDb
173
+
174
+
175
+
245
176
  ## say hello
246
- puts SportDb.banner if defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG
177
+ puts SportDb::Module::Models.banner
178
+
179
+