sportdb 1.9.16 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +2 -19
  3. data/Manifest.txt +1 -137
  4. data/README.md +2 -21
  5. data/Rakefile +14 -25
  6. data/lib/sportdb.rb +9 -260
  7. data/lib/sportdb/cli/main.rb +5 -14
  8. data/lib/sportdb/cli/opts.rb +2 -0
  9. data/lib/sportdb/cli/version.rb +26 -0
  10. metadata +10 -278
  11. data/.gemtest +0 -0
  12. data/config/fixtures/de.yml +0 -46
  13. data/config/fixtures/en.yml +0 -54
  14. data/config/fixtures/es.yml +0 -48
  15. data/config/fixtures/fr.yml +0 -53
  16. data/config/fixtures/it.yml +0 -55
  17. data/config/fixtures/pt.yml +0 -46
  18. data/config/fixtures/ro.yml +0 -55
  19. data/data/seasons.txt +0 -74
  20. data/data/setups/all.txt +0 -5
  21. data/lib/sportdb/calc.rb +0 -279
  22. data/lib/sportdb/deleter.rb +0 -52
  23. data/lib/sportdb/finders/date.rb +0 -374
  24. data/lib/sportdb/finders/goals.rb +0 -260
  25. data/lib/sportdb/finders/scores.rb +0 -122
  26. data/lib/sportdb/lang.rb +0 -216
  27. data/lib/sportdb/matcher.rb +0 -31
  28. data/lib/sportdb/models/assoc.rb +0 -106
  29. data/lib/sportdb/models/assoc_assoc.rb +0 -15
  30. data/lib/sportdb/models/badge.rb +0 -14
  31. data/lib/sportdb/models/event.rb +0 -65
  32. data/lib/sportdb/models/event_ground.rb +0 -15
  33. data/lib/sportdb/models/event_team.rb +0 -16
  34. data/lib/sportdb/models/forward.rb +0 -55
  35. data/lib/sportdb/models/game.rb +0 -244
  36. data/lib/sportdb/models/goal.rb +0 -15
  37. data/lib/sportdb/models/ground.rb +0 -100
  38. data/lib/sportdb/models/group.rb +0 -23
  39. data/lib/sportdb/models/group_team.rb +0 -14
  40. data/lib/sportdb/models/league.rb +0 -83
  41. data/lib/sportdb/models/person.rb +0 -21
  42. data/lib/sportdb/models/roster.rb +0 -18
  43. data/lib/sportdb/models/round.rb +0 -22
  44. data/lib/sportdb/models/season.rb +0 -14
  45. data/lib/sportdb/models/stats/alltime_standing.rb +0 -44
  46. data/lib/sportdb/models/stats/alltime_standing_entry.rb +0 -23
  47. data/lib/sportdb/models/stats/event_standing.rb +0 -55
  48. data/lib/sportdb/models/stats/event_standing_entry.rb +0 -21
  49. data/lib/sportdb/models/stats/group_standing.rb +0 -50
  50. data/lib/sportdb/models/stats/group_standing_entry.rb +0 -22
  51. data/lib/sportdb/models/team.rb +0 -119
  52. data/lib/sportdb/models/team_comp.rb +0 -64
  53. data/lib/sportdb/models/utils.rb +0 -78
  54. data/lib/sportdb/models/world/city.rb +0 -21
  55. data/lib/sportdb/models/world/continent.rb +0 -20
  56. data/lib/sportdb/models/world/country.rb +0 -19
  57. data/lib/sportdb/models/world/region.rb +0 -19
  58. data/lib/sportdb/patterns.rb +0 -38
  59. data/lib/sportdb/reader.rb +0 -130
  60. data/lib/sportdb/reader_file.rb +0 -123
  61. data/lib/sportdb/reader_zip.rb +0 -165
  62. data/lib/sportdb/readers/assoc.rb +0 -54
  63. data/lib/sportdb/readers/event.rb +0 -200
  64. data/lib/sportdb/readers/game.rb +0 -877
  65. data/lib/sportdb/readers/ground.rb +0 -53
  66. data/lib/sportdb/readers/league.rb +0 -54
  67. data/lib/sportdb/readers/season.rb +0 -83
  68. data/lib/sportdb/readers/squad_club.rb +0 -201
  69. data/lib/sportdb/readers/squad_national_team.rb +0 -173
  70. data/lib/sportdb/readers/team.rb +0 -53
  71. data/lib/sportdb/schema.rb +0 -373
  72. data/lib/sportdb/standings.rb +0 -178
  73. data/lib/sportdb/stats.rb +0 -27
  74. data/lib/sportdb/utils.rb +0 -89
  75. data/lib/sportdb/utils_date.rb +0 -26
  76. data/lib/sportdb/utils_goals.rb +0 -20
  77. data/lib/sportdb/utils_group.rb +0 -63
  78. data/lib/sportdb/utils_map.rb +0 -44
  79. data/lib/sportdb/utils_round.rb +0 -165
  80. data/lib/sportdb/utils_scores.rb +0 -17
  81. data/lib/sportdb/utils_teams.rb +0 -43
  82. data/lib/sportdb/version.rb +0 -22
  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/leagues.txt +0 -11
  91. data/test/data/at-austria/teams.txt +0 -75
  92. data/test/data/at-austria/teams_2.txt +0 -34
  93. data/test/data/national-teams/assocs.txt +0 -231
  94. data/test/data/national-teams/europe/assocs.txt +0 -13
  95. data/test/data/national-teams/europe/teams.txt +0 -13
  96. data/test/data/national-teams/north-america/assocs.txt +0 -10
  97. data/test/data/national-teams/north-america/teams.txt +0 -7
  98. data/test/data/national-teams/teams.txt +0 -19
  99. data/test/data/players/europe/at-austria/players.txt +0 -45
  100. data/test/data/players/europe/de-deutschland/players.txt +0 -41
  101. data/test/data/players/south-america/br-brazil/players.txt +0 -51
  102. data/test/data/world-cup/1930/cup.txt +0 -71
  103. data/test/data/world-cup/1930/cup.yml +0 -23
  104. data/test/data/world-cup/1930/cup_goals.txt +0 -47
  105. data/test/data/world-cup/1930/cup_goals.yml +0 -23
  106. data/test/data/world-cup/1954/cup.txt +0 -90
  107. data/test/data/world-cup/1954/cup.yml +0 -30
  108. data/test/data/world-cup/1962/cup.txt +0 -86
  109. data/test/data/world-cup/1962/cup.yml +0 -32
  110. data/test/data/world-cup/1974/cup.yml +0 -35
  111. data/test/data/world-cup/1974/cup_finals.txt +0 -14
  112. data/test/data/world-cup/1974/cup_i.txt +0 -55
  113. data/test/data/world-cup/1974/cup_ii.txt +0 -34
  114. data/test/data/world-cup/2014/cup.txt +0 -5
  115. data/test/data/world-cup/2014/cup.yml +0 -54
  116. data/test/data/world-cup/2014/squads/br-brazil.txt +0 -46
  117. data/test/data/world-cup/2014/squads/de-deutschland.txt +0 -8
  118. data/test/data/world-cup/2014/squads/jp-japan.txt +0 -30
  119. data/test/data/world-cup/2014/squads/uy-uruguay.txt +0 -32
  120. data/test/data/world-cup/leagues.txt +0 -5
  121. data/test/data/world-cup/seasons_1930.txt +0 -4
  122. data/test/data/world-cup/seasons_1954.txt +0 -4
  123. data/test/data/world-cup/seasons_1962.txt +0 -4
  124. data/test/data/world-cup/seasons_1974.txt +0 -5
  125. data/test/data/world-cup/teams_1930.txt +0 -26
  126. data/test/data/world-cup/teams_1954.txt +0 -30
  127. data/test/data/world-cup/teams_1962.txt +0 -29
  128. data/test/data/world-cup/teams_1974.txt +0 -29
  129. data/test/helper.rb +0 -120
  130. data/test/test_assoc_reader.rb +0 -201
  131. data/test/test_changes.rb +0 -74
  132. data/test/test_cursor.rb +0 -50
  133. data/test/test_date.rb +0 -100
  134. data/test/test_goals.rb +0 -109
  135. data/test/test_lang.rb +0 -130
  136. data/test/test_load.rb +0 -61
  137. data/test/test_reader.rb +0 -88
  138. data/test/test_reader_from_string.rb +0 -65
  139. data/test/test_round_auto.rb +0 -370
  140. data/test/test_round_def.rb +0 -109
  141. data/test/test_round_header.rb +0 -183
  142. data/test/test_scores.rb +0 -70
  143. data/test/test_squad_club_reader.rb +0 -76
  144. data/test/test_squad_national_team_reader.rb +0 -116
  145. data/test/test_standings.rb +0 -279
  146. data/test/test_standings_ii.rb +0 -46
  147. data/test/test_utils.rb +0 -124
  148. data/test/test_winner.rb +0 -95
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f652191b23c1c3acab00a7b950f7b93ec6bce4f4
4
- data.tar.gz: 85fe028e22fa00c0ee763ba6f472c0d23016009e
3
+ metadata.gz: 6d9324898363df6c12153669aecc98373b2fa3b0
4
+ data.tar.gz: 979905b01383585177295b1c8a2ff26fe28210a8
5
5
  SHA512:
6
- metadata.gz: e175cc5dbd766ef735bb4c00a7d2afd47466c1aa3543fe2911a26b696b80b2b18a832ad85e2dc9f9575804a441b6c2471daa2779c1bfec8cbdd2452bbd202877
7
- data.tar.gz: 21136016a7ea1294f86f1064bc9f604613936d6f8e016fd53144337f1894fa5b7ee8e4453bb3aa83cb5a82e556764509e7d0befd4793fe6583b7c200ad5b5c27
6
+ metadata.gz: 1a20a2993f5057c30a2bfc2c0fc81789660eb1d32463a383eee9dea686de8712d7cd6e9c1401e519c9f1142e7bf1fcb7439d0434a4244a2afed914460f6cd431
7
+ data.tar.gz: 5a7502b43a15715de568c126f3710795d911a0ff55fecc0101cdb09a7b7035e48ecae1a62248dd4869103fda76850a0594dcb8de1f6dbbb24bd65869eee567e5
data/HISTORY.md CHANGED
@@ -1,21 +1,4 @@
1
- ### 0.4.0 / 2012-10-16
2
1
 
3
- * Add plain text fixture reader/loader
4
- * Add --generate/g option for generating fixtures from the DB using templates
2
+ ### 0.1.0 / 2014-12-05
5
3
 
6
- ### 0.3.1 / 2012-10-14
7
-
8
- * Move models into its own namespace, that is, SportDB::Models
9
- * Add ActiveRecord logging for --verbose option
10
-
11
- ### 0.3.0 / 2012-10-07
12
-
13
- * Add --delete option to delete all records
14
-
15
- ### 0.2.0 / 2012-10-06
16
-
17
- * Add --load option for builtin fixtures
18
-
19
- ### 0.1.0 / 2012-10-06
20
-
21
- * Everything is new. First release
4
+ * Everything is new. First release
@@ -3,143 +3,7 @@ Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
5
  bin/sportdb
6
- config/fixtures/de.yml
7
- config/fixtures/en.yml
8
- config/fixtures/es.yml
9
- config/fixtures/fr.yml
10
- config/fixtures/it.yml
11
- config/fixtures/pt.yml
12
- config/fixtures/ro.yml
13
- data/seasons.txt
14
- data/setups/all.txt
15
6
  lib/sportdb.rb
16
- lib/sportdb/calc.rb
17
7
  lib/sportdb/cli/main.rb
18
8
  lib/sportdb/cli/opts.rb
19
- lib/sportdb/deleter.rb
20
- lib/sportdb/finders/date.rb
21
- lib/sportdb/finders/goals.rb
22
- lib/sportdb/finders/scores.rb
23
- lib/sportdb/lang.rb
24
- lib/sportdb/matcher.rb
25
- lib/sportdb/models/assoc.rb
26
- lib/sportdb/models/assoc_assoc.rb
27
- lib/sportdb/models/badge.rb
28
- lib/sportdb/models/event.rb
29
- lib/sportdb/models/event_ground.rb
30
- lib/sportdb/models/event_team.rb
31
- lib/sportdb/models/forward.rb
32
- lib/sportdb/models/game.rb
33
- lib/sportdb/models/goal.rb
34
- lib/sportdb/models/ground.rb
35
- lib/sportdb/models/group.rb
36
- lib/sportdb/models/group_team.rb
37
- lib/sportdb/models/league.rb
38
- lib/sportdb/models/person.rb
39
- lib/sportdb/models/roster.rb
40
- lib/sportdb/models/round.rb
41
- lib/sportdb/models/season.rb
42
- lib/sportdb/models/stats/alltime_standing.rb
43
- lib/sportdb/models/stats/alltime_standing_entry.rb
44
- lib/sportdb/models/stats/event_standing.rb
45
- lib/sportdb/models/stats/event_standing_entry.rb
46
- lib/sportdb/models/stats/group_standing.rb
47
- lib/sportdb/models/stats/group_standing_entry.rb
48
- lib/sportdb/models/team.rb
49
- lib/sportdb/models/team_comp.rb
50
- lib/sportdb/models/utils.rb
51
- lib/sportdb/models/world/city.rb
52
- lib/sportdb/models/world/continent.rb
53
- lib/sportdb/models/world/country.rb
54
- lib/sportdb/models/world/region.rb
55
- lib/sportdb/patterns.rb
56
- lib/sportdb/reader.rb
57
- lib/sportdb/reader_file.rb
58
- lib/sportdb/reader_zip.rb
59
- lib/sportdb/readers/assoc.rb
60
- lib/sportdb/readers/event.rb
61
- lib/sportdb/readers/game.rb
62
- lib/sportdb/readers/ground.rb
63
- lib/sportdb/readers/league.rb
64
- lib/sportdb/readers/season.rb
65
- lib/sportdb/readers/squad_club.rb
66
- lib/sportdb/readers/squad_national_team.rb
67
- lib/sportdb/readers/team.rb
68
- lib/sportdb/schema.rb
69
- lib/sportdb/standings.rb
70
- lib/sportdb/stats.rb
71
- lib/sportdb/utils.rb
72
- lib/sportdb/utils_date.rb
73
- lib/sportdb/utils_goals.rb
74
- lib/sportdb/utils_group.rb
75
- lib/sportdb/utils_map.rb
76
- lib/sportdb/utils_round.rb
77
- lib/sportdb/utils_scores.rb
78
- lib/sportdb/utils_teams.rb
79
- lib/sportdb/version.rb
80
- test/data/at-austria/2013_14/bl.txt
81
- test/data/at-austria/2013_14/bl.yml
82
- test/data/at-austria/2013_14/bl_ii.txt
83
- test/data/at-austria/2013_14/el.txt
84
- test/data/at-austria/2013_14/el.yml
85
- test/data/at-austria/2013_14/squads/austria.txt
86
- test/data/at-austria/2013_14/squads/salzburg.txt
87
- test/data/at-austria/leagues.txt
88
- test/data/at-austria/teams.txt
89
- test/data/at-austria/teams_2.txt
90
- test/data/national-teams/assocs.txt
91
- test/data/national-teams/europe/assocs.txt
92
- test/data/national-teams/europe/teams.txt
93
- test/data/national-teams/north-america/assocs.txt
94
- test/data/national-teams/north-america/teams.txt
95
- test/data/national-teams/teams.txt
96
- test/data/players/europe/at-austria/players.txt
97
- test/data/players/europe/de-deutschland/players.txt
98
- test/data/players/south-america/br-brazil/players.txt
99
- test/data/world-cup/1930/cup.txt
100
- test/data/world-cup/1930/cup.yml
101
- test/data/world-cup/1930/cup_goals.txt
102
- test/data/world-cup/1930/cup_goals.yml
103
- test/data/world-cup/1954/cup.txt
104
- test/data/world-cup/1954/cup.yml
105
- test/data/world-cup/1962/cup.txt
106
- test/data/world-cup/1962/cup.yml
107
- test/data/world-cup/1974/cup.yml
108
- test/data/world-cup/1974/cup_finals.txt
109
- test/data/world-cup/1974/cup_i.txt
110
- test/data/world-cup/1974/cup_ii.txt
111
- test/data/world-cup/2014/cup.txt
112
- test/data/world-cup/2014/cup.yml
113
- test/data/world-cup/2014/squads/br-brazil.txt
114
- test/data/world-cup/2014/squads/de-deutschland.txt
115
- test/data/world-cup/2014/squads/jp-japan.txt
116
- test/data/world-cup/2014/squads/uy-uruguay.txt
117
- test/data/world-cup/leagues.txt
118
- test/data/world-cup/seasons_1930.txt
119
- test/data/world-cup/seasons_1954.txt
120
- test/data/world-cup/seasons_1962.txt
121
- test/data/world-cup/seasons_1974.txt
122
- test/data/world-cup/teams_1930.txt
123
- test/data/world-cup/teams_1954.txt
124
- test/data/world-cup/teams_1962.txt
125
- test/data/world-cup/teams_1974.txt
126
- test/helper.rb
127
- test/test_assoc_reader.rb
128
- test/test_changes.rb
129
- test/test_cursor.rb
130
- test/test_date.rb
131
- test/test_goals.rb
132
- test/test_lang.rb
133
- test/test_load.rb
134
- test/test_reader.rb
135
- test/test_reader_from_string.rb
136
- test/test_round_auto.rb
137
- test/test_round_def.rb
138
- test/test_round_header.rb
139
- test/test_scores.rb
140
- test/test_squad_club_reader.rb
141
- test/test_squad_national_team_reader.rb
142
- test/test_standings.rb
143
- test/test_standings_ii.rb
144
- test/test_utils.rb
145
- test/test_winner.rb
9
+ lib/sportdb/cli/version.rb
data/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  ## Usage
16
16
 
17
- The sportdb gem lets you load fixtures in plain text into your sports database (also includes schema & models for easy reuse)
17
+ The sportdb gem lets you load fixtures in plain text into your sports database
18
18
 
19
19
  ~~~
20
20
  SYNOPSIS
@@ -128,26 +128,6 @@ EXAMPLES
128
128
  ~~~
129
129
 
130
130
 
131
- ## Usage in Ruby (Console / Interactive Shell)
132
-
133
-
134
- Try the built-in console script. In your interactive Ruby shell type:
135
-
136
- >> require 'sportdb/console'
137
- # => Welcome to sport.db, version 1.9.7 (world.db, version 1.9.3)!
138
-
139
- This will try to connect to the `sport.db` SQLite database in your working folder.
140
- To get started try some queries, for example:
141
-
142
- >> Team.count
143
- # => 157
144
- >> t = Team.find_by_key( 'barcelona' )
145
- # => ...
146
-
147
- and so on.
148
-
149
-
150
-
151
131
  ## Install
152
132
 
153
133
  Just install the gem:
@@ -174,3 +154,4 @@ Use it as you please with no restrictions whatsoever.
174
154
  Send them along to the
175
155
  [Open Sports & Friends Forum/Mailing List](http://groups.google.com/group/opensport).
176
156
  Thanks!
157
+
data/Rakefile CHANGED
@@ -1,15 +1,12 @@
1
1
  require 'hoe'
2
- require './lib/sportdb/version.rb'
3
-
4
- ## NB: plugin (hoe-manifest) not required; just used for future testing/development
5
- ## Hoe::plugin :manifest # more options for manifests (in the future; not yet)
2
+ require './lib/sportdb/cli/version.rb'
6
3
 
7
4
 
8
5
  Hoe.spec 'sportdb' do
9
-
10
- self.version = SportDb::VERSION
11
-
12
- self.summary = 'sportdb - sport.db command line tool'
6
+
7
+ self.version = SportDbCli::VERSION
8
+
9
+ self.summary = 'sportdb - sport.db Command Line Tool'
13
10
  self.description = summary
14
11
 
15
12
  self.urls = ['https://github.com/sportdb/sport.db.ruby']
@@ -18,40 +15,33 @@ Hoe.spec 'sportdb' do
18
15
  self.email = 'opensport@googlegroups.com'
19
16
 
20
17
  # switch extension to .markdown for gihub formatting
21
- # -- NB: auto-changed when included in manifest
18
+ # -- Note: auto-changed when included in manifest
22
19
  self.readme_file = 'README.md'
23
20
  self.history_file = 'HISTORY.md'
24
21
 
25
22
  self.extra_deps = [
26
- ['props' ],
27
- ['logutils'],
28
- ['textutils', '>= 0.9.10'],
29
- ['worlddb', '>= 2.0.8'], # NB: worlddb already includes
30
- # - logutils
31
- # - textutils
32
- ['tagutils'], # tags n tagging tables
33
- ['persondb'], # persons (people) table
34
- ['activerecord-utils'], # extras e.g. rnd, find_by! for 3.x etc.
35
- ['fetcher', '>= 0.4.4'],
23
+ ['sportdb-models', '>= 1.10.0'],
24
+
25
+ ['fetcher', '>= 0.4.4'], ## check if included already in datafil ??
36
26
  ['datafile', '>= 0.1.1'],
37
27
 
38
28
  ### sportdb addons
39
- ['sportdb-keys'],
40
- ['sportdb-console'],
29
+ ## ['sportdb-keys'],
30
+ ## ['sportdb-console'],
41
31
  ['sportdb-update'],
42
32
  ['sportdb-service'],
43
33
 
44
34
  ## 3rd party
45
35
  ['gli', '>= 2.12.2'],
46
36
 
47
- ['activerecord'] # NB: will include activesupport,etc.
48
- ### ['sqlite3', '~> 1.3'] # NB: install on your own; remove dependency
37
+ ## ['activerecord'], # Note: will include activesupport,etc.
38
+ ['sqlite3']
49
39
  ]
50
40
 
51
41
  self.licenses = ['Public Domain']
52
42
 
53
43
  self.spec_extras = {
54
- :required_ruby_version => '>= 1.9.2'
44
+ required_ruby_version: '>= 1.9.2'
55
45
  }
56
46
 
57
47
  self.post_install_message =<<EOS
@@ -64,4 +54,3 @@ https://groups.google.com/group/opensport
64
54
  EOS
65
55
 
66
56
  end
67
-
@@ -1,276 +1,30 @@
1
1
  # encoding: utf-8
2
2
 
3
- ###
4
- # NB: for local testing run like:
5
- #
6
- # 1.9.x: ruby -Ilib lib/sportdb.rb
7
-
8
- # core and stlibs (note: get included via worlddb gem; see worlddb gem/lib)
9
-
10
-
11
- require 'fileutils'
12
-
13
-
14
- # rubygems / 3rd party libs
15
-
16
- require 'active_record'
17
- require 'activerecord/utils' # check - if dependency on logutils? or props? etc let others go first
18
- # fix: move activerecord/utils to world db - no need to require here again
19
-
20
- require 'worlddb'
21
- require 'persondb'
22
-
23
- require 'logutils/db' # NB: explict require required for LogDb (NOT automatic)
24
- # fix: move to world db -- no need to require here
25
3
 
4
+ require 'sportdb/models'
26
5
 
6
+ ## check if already included in datafile gem ??
27
7
  require 'fetcher' # for fetching/downloading fixtures via HTTP/HTTPS etc.
8
+ require 'datafile' ## lets us use Datafile::Builder,Datafile etc.
28
9
 
29
- # our own code
30
-
31
- require 'sportdb/version' # let version always go first
32
-
33
- require 'sportdb/patterns'
34
- require 'sportdb/models/forward'
35
- require 'sportdb/models/world/city'
36
- require 'sportdb/models/world/country'
37
- require 'sportdb/models/world/continent'
38
- require 'sportdb/models/world/region'
39
- require 'sportdb/models/assoc'
40
- require 'sportdb/models/assoc_assoc'
41
- require 'sportdb/models/badge'
42
- require 'sportdb/models/event'
43
- require 'sportdb/models/event_ground'
44
- require 'sportdb/models/event_team'
45
- require 'sportdb/models/game'
46
- require 'sportdb/models/goal'
47
- require 'sportdb/models/ground'
48
- require 'sportdb/models/group'
49
- require 'sportdb/models/group_team'
50
- require 'sportdb/models/league'
51
- require 'sportdb/models/person'
52
- require 'sportdb/models/roster'
53
- require 'sportdb/models/round'
54
- require 'sportdb/models/season'
55
- require 'sportdb/models/team'
56
- require 'sportdb/models/team_comp'
57
-
58
-
59
- require 'sportdb/models/stats/alltime_standing'
60
- require 'sportdb/models/stats/alltime_standing_entry'
61
- require 'sportdb/models/stats/event_standing'
62
- require 'sportdb/models/stats/event_standing_entry'
63
- require 'sportdb/models/stats/group_standing'
64
- require 'sportdb/models/stats/group_standing_entry'
65
-
66
- require 'sportdb/models/utils' # e.g. GameCursor
67
-
68
-
69
- require 'sportdb/schema' # NB: requires sportdb/models (include SportDB::Models)
70
-
71
- require 'sportdb/finders/date'
72
- require 'sportdb/finders/scores'
73
-
74
- require 'sportdb/utils'
75
- require 'sportdb/utils_date'
76
- require 'sportdb/utils_group'
77
- require 'sportdb/utils_map'
78
- require 'sportdb/utils_round'
79
- require 'sportdb/utils_scores'
80
- require 'sportdb/utils_teams'
81
- require 'sportdb/utils_goals'
82
- require 'sportdb/matcher'
83
- require 'sportdb/calc' # fix/todo: obsolete - replace w/ standings
84
- require 'sportdb/standings'
85
-
86
-
87
- require 'sportdb/finders/goals' # no: requires FixturesHelpers
88
-
89
- require 'sportdb/readers/assoc'
90
- require 'sportdb/readers/event'
91
- require 'sportdb/readers/game'
92
- require 'sportdb/readers/ground'
93
- require 'sportdb/readers/league'
94
- require 'sportdb/readers/season'
95
- require 'sportdb/readers/squad_club' # roster
96
- require 'sportdb/readers/squad_national_team'
97
- require 'sportdb/readers/team'
98
- require 'sportdb/reader'
99
- require 'sportdb/reader_file'
100
- require 'sportdb/reader_zip'
10
+ require 'gli'
101
11
 
12
+ # our own code
102
13
 
14
+ require 'sportdb/cli/version' # let version always go first
103
15
 
104
- require 'sportdb/lang'
16
+ # additional for cli only
17
+ require 'sportdb/cli/opts'
105
18
 
106
- require 'sportdb/deleter'
107
- require 'sportdb/stats'
108
19
 
109
20
 
110
21
  module SportDb
111
22
 
112
- def self.config_path
113
- "#{root}/config"
114
- end
115
-
116
- def self.data_path
117
- "#{root}/data"
118
- end
119
-
120
- def self.test_data_path
121
- "#{root}/test/data"
122
- end
123
-
124
-
125
- def self.lang
126
- # todo/fix: find a better way for single instance ??
127
- # will get us ruby warning: instance variable @lang not initialized => find a better way!!!
128
- # just use @lang w/o .nil? e.g.
129
- # @lang =|| Lang.new why? why not?? or better use @@lang =|| Lang.new for class variable!!!
130
- if @lang.nil?
131
- @lang = Lang.new
132
- end
133
- @lang
134
- end
135
-
136
-
137
23
  def self.main
138
24
  ## Runner.new.run(ARGV) - old code
139
25
  require 'sportdb/cli/main'
140
26
  end
141
27
 
142
- def self.create
143
- CreateDb.new.up
144
- ConfDb::Model::Prop.create!( key: 'db.schema.sport.version', value: VERSION )
145
- end
146
-
147
- def self.create_all
148
- ## build schema - convenience helper
149
- LogDb.create
150
- ConfDb.create
151
- TagDb.create
152
- WorldDb.create
153
- PersonDb.create
154
- SportDb.create
155
- end
156
-
157
-
158
- def self.read_setup( setup, include_path )
159
- reader = Reader.new( include_path )
160
- reader.load_setup( setup )
161
- end
162
-
163
- def self.read_setup_from_zip( zip_name, setup, include_path, opts={} ) ## todo/check - use a better (shorter) name ??
164
- reader = ZipReader.new( zip_name, include_path, opts )
165
- reader.load_setup( setup )
166
- reader.close
167
- end
168
-
169
- def self.read_all( include_path ) # convenience helper
170
- read_setup( 'setups/all', include_path )
171
- end
172
-
173
- def self.read_builtin
174
- read_setup( 'setups/all', data_path )
175
- end
176
-
177
-
178
- # load built-in (that is, bundled within the gem) named plain text seeds
179
- # - pass in an array of pairs of event/seed names e.g.
180
- # [['at.2012/13', 'at/2012_13/bl'],
181
- # ['cl.2012/13', 'cl/2012_13/cl']] etc.
182
-
183
- def self.read( ary, include_path )
184
- reader = Reader.new( include_path )
185
- ## todo: check kind_of?( Array ) or kind_of?(String) to support array or string
186
- ary.each do |name|
187
- reader.load( name )
188
- end
189
- end
190
-
191
-
192
- # delete ALL records (use with care!)
193
- def self.delete!
194
- puts '*** deleting sport table records/data...'
195
- Deleter.new.run
196
- end # method delete!
197
-
198
- def self.update!
199
- puts '*** update event fixtures...'
200
- Updater.new.run
201
- end
202
-
203
-
204
- def self.stats
205
- Stats.new.tables # NOTE: same as tables (remove??? why? why not??)
206
- end
207
-
208
- def self.tables
209
- Stats.new.tables
210
- end
211
-
212
-
213
- def self.connect( db_config={} )
214
-
215
- if db_config.empty?
216
- puts "ENV['DATBASE_URL'] - >#{ENV['DATABASE_URL']}<"
217
-
218
- ### change default to ./sport.db ?? why? why not?
219
- db = URI.parse( ENV['DATABASE_URL'] || 'sqlite3:///sport.db' )
220
-
221
- if db.scheme == 'postgres'
222
- config = {
223
- adapter: 'postgresql',
224
- host: db.host,
225
- port: db.port,
226
- username: db.user,
227
- password: db.password,
228
- database: db.path[1..-1],
229
- encoding: 'utf8'
230
- }
231
- else # assume sqlite3
232
- config = {
233
- adapter: db.scheme, # sqlite3
234
- database: db.path[1..-1] # sport.db (NB: cut off leading /, thus 1..-1)
235
- }
236
- end
237
- else
238
- config = db_config # use passed in config hash
239
- end
240
-
241
- ## todo/check: use if defined?( JRUBY_VERSION ) instead ??
242
- if RUBY_PLATFORM =~ /java/ && config[:adapter] == 'sqlite3'
243
- # quick hack for JRuby sqlite3 support via jdbc
244
- puts "jruby quick hack - adding jdbc libs for jruby sqlite3 database support"
245
- require 'jdbc/sqlite3'
246
- require 'active_record/connection_adapters/jdbc_adapter'
247
- require 'active_record/connection_adapters/jdbcsqlite3_adapter'
248
- end
249
-
250
- puts "Connecting to db using settings: "
251
- pp config
252
- ActiveRecord::Base.establish_connection( config )
253
- # ActiveRecord::Base.logger = Logger.new( STDOUT )
254
- end
255
-
256
-
257
- def self.setup_in_memory_db
258
-
259
- # Database Setup & Config
260
- ActiveRecord::Base.logger = Logger.new( STDOUT )
261
- ## ActiveRecord::Base.colorize_logging = false - no longer exists - check new api/config setting?
262
-
263
- self.connect( adapter: 'sqlite3',
264
- database: ':memory:' )
265
-
266
- ## build schema
267
- SportDb.create_all
268
-
269
- ## read builtins - why? why not?
270
- SportDb.read_builtin
271
- end # setup_in_memory_db (using SQLite :memory:)
272
-
273
-
274
28
  end # module SportDb
275
29
 
276
30
 
@@ -285,10 +39,5 @@ require 'sportdb/service'
285
39
  ## puts 'after auto-load (require) sportdb addons'
286
40
 
287
41
 
42
+ SportDb.main if __FILE__ == $0
288
43
 
289
- if __FILE__ == $0
290
- SportDb.main
291
- else
292
- ## say hello
293
- puts SportDb.banner
294
- end