sportdb 1.9.16 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +2 -19
- data/Manifest.txt +1 -137
- data/README.md +2 -21
- data/Rakefile +14 -25
- data/lib/sportdb.rb +9 -260
- data/lib/sportdb/cli/main.rb +5 -14
- data/lib/sportdb/cli/opts.rb +2 -0
- data/lib/sportdb/cli/version.rb +26 -0
- metadata +10 -278
- data/.gemtest +0 -0
- data/config/fixtures/de.yml +0 -46
- data/config/fixtures/en.yml +0 -54
- data/config/fixtures/es.yml +0 -48
- data/config/fixtures/fr.yml +0 -53
- data/config/fixtures/it.yml +0 -55
- data/config/fixtures/pt.yml +0 -46
- data/config/fixtures/ro.yml +0 -55
- data/data/seasons.txt +0 -74
- data/data/setups/all.txt +0 -5
- data/lib/sportdb/calc.rb +0 -279
- data/lib/sportdb/deleter.rb +0 -52
- data/lib/sportdb/finders/date.rb +0 -374
- data/lib/sportdb/finders/goals.rb +0 -260
- data/lib/sportdb/finders/scores.rb +0 -122
- data/lib/sportdb/lang.rb +0 -216
- data/lib/sportdb/matcher.rb +0 -31
- data/lib/sportdb/models/assoc.rb +0 -106
- data/lib/sportdb/models/assoc_assoc.rb +0 -15
- data/lib/sportdb/models/badge.rb +0 -14
- data/lib/sportdb/models/event.rb +0 -65
- data/lib/sportdb/models/event_ground.rb +0 -15
- data/lib/sportdb/models/event_team.rb +0 -16
- data/lib/sportdb/models/forward.rb +0 -55
- data/lib/sportdb/models/game.rb +0 -244
- data/lib/sportdb/models/goal.rb +0 -15
- data/lib/sportdb/models/ground.rb +0 -100
- data/lib/sportdb/models/group.rb +0 -23
- data/lib/sportdb/models/group_team.rb +0 -14
- data/lib/sportdb/models/league.rb +0 -83
- data/lib/sportdb/models/person.rb +0 -21
- data/lib/sportdb/models/roster.rb +0 -18
- data/lib/sportdb/models/round.rb +0 -22
- data/lib/sportdb/models/season.rb +0 -14
- data/lib/sportdb/models/stats/alltime_standing.rb +0 -44
- data/lib/sportdb/models/stats/alltime_standing_entry.rb +0 -23
- data/lib/sportdb/models/stats/event_standing.rb +0 -55
- data/lib/sportdb/models/stats/event_standing_entry.rb +0 -21
- data/lib/sportdb/models/stats/group_standing.rb +0 -50
- data/lib/sportdb/models/stats/group_standing_entry.rb +0 -22
- data/lib/sportdb/models/team.rb +0 -119
- data/lib/sportdb/models/team_comp.rb +0 -64
- data/lib/sportdb/models/utils.rb +0 -78
- data/lib/sportdb/models/world/city.rb +0 -21
- data/lib/sportdb/models/world/continent.rb +0 -20
- data/lib/sportdb/models/world/country.rb +0 -19
- data/lib/sportdb/models/world/region.rb +0 -19
- data/lib/sportdb/patterns.rb +0 -38
- data/lib/sportdb/reader.rb +0 -130
- data/lib/sportdb/reader_file.rb +0 -123
- data/lib/sportdb/reader_zip.rb +0 -165
- data/lib/sportdb/readers/assoc.rb +0 -54
- data/lib/sportdb/readers/event.rb +0 -200
- data/lib/sportdb/readers/game.rb +0 -877
- data/lib/sportdb/readers/ground.rb +0 -53
- data/lib/sportdb/readers/league.rb +0 -54
- data/lib/sportdb/readers/season.rb +0 -83
- data/lib/sportdb/readers/squad_club.rb +0 -201
- data/lib/sportdb/readers/squad_national_team.rb +0 -173
- data/lib/sportdb/readers/team.rb +0 -53
- data/lib/sportdb/schema.rb +0 -373
- data/lib/sportdb/standings.rb +0 -178
- data/lib/sportdb/stats.rb +0 -27
- data/lib/sportdb/utils.rb +0 -89
- data/lib/sportdb/utils_date.rb +0 -26
- data/lib/sportdb/utils_goals.rb +0 -20
- data/lib/sportdb/utils_group.rb +0 -63
- data/lib/sportdb/utils_map.rb +0 -44
- data/lib/sportdb/utils_round.rb +0 -165
- data/lib/sportdb/utils_scores.rb +0 -17
- data/lib/sportdb/utils_teams.rb +0 -43
- data/lib/sportdb/version.rb +0 -22
- data/test/data/at-austria/2013_14/bl.txt +0 -227
- data/test/data/at-austria/2013_14/bl.yml +0 -30
- data/test/data/at-austria/2013_14/bl_ii.txt +0 -154
- data/test/data/at-austria/2013_14/el.txt +0 -4
- data/test/data/at-austria/2013_14/el.yml +0 -25
- data/test/data/at-austria/2013_14/squads/austria.txt +0 -40
- data/test/data/at-austria/2013_14/squads/salzburg.txt +0 -35
- data/test/data/at-austria/leagues.txt +0 -11
- data/test/data/at-austria/teams.txt +0 -75
- data/test/data/at-austria/teams_2.txt +0 -34
- data/test/data/national-teams/assocs.txt +0 -231
- data/test/data/national-teams/europe/assocs.txt +0 -13
- data/test/data/national-teams/europe/teams.txt +0 -13
- data/test/data/national-teams/north-america/assocs.txt +0 -10
- data/test/data/national-teams/north-america/teams.txt +0 -7
- data/test/data/national-teams/teams.txt +0 -19
- data/test/data/players/europe/at-austria/players.txt +0 -45
- data/test/data/players/europe/de-deutschland/players.txt +0 -41
- data/test/data/players/south-america/br-brazil/players.txt +0 -51
- data/test/data/world-cup/1930/cup.txt +0 -71
- data/test/data/world-cup/1930/cup.yml +0 -23
- data/test/data/world-cup/1930/cup_goals.txt +0 -47
- data/test/data/world-cup/1930/cup_goals.yml +0 -23
- data/test/data/world-cup/1954/cup.txt +0 -90
- data/test/data/world-cup/1954/cup.yml +0 -30
- data/test/data/world-cup/1962/cup.txt +0 -86
- data/test/data/world-cup/1962/cup.yml +0 -32
- data/test/data/world-cup/1974/cup.yml +0 -35
- data/test/data/world-cup/1974/cup_finals.txt +0 -14
- data/test/data/world-cup/1974/cup_i.txt +0 -55
- data/test/data/world-cup/1974/cup_ii.txt +0 -34
- data/test/data/world-cup/2014/cup.txt +0 -5
- data/test/data/world-cup/2014/cup.yml +0 -54
- data/test/data/world-cup/2014/squads/br-brazil.txt +0 -46
- data/test/data/world-cup/2014/squads/de-deutschland.txt +0 -8
- data/test/data/world-cup/2014/squads/jp-japan.txt +0 -30
- data/test/data/world-cup/2014/squads/uy-uruguay.txt +0 -32
- data/test/data/world-cup/leagues.txt +0 -5
- data/test/data/world-cup/seasons_1930.txt +0 -4
- data/test/data/world-cup/seasons_1954.txt +0 -4
- data/test/data/world-cup/seasons_1962.txt +0 -4
- data/test/data/world-cup/seasons_1974.txt +0 -5
- data/test/data/world-cup/teams_1930.txt +0 -26
- data/test/data/world-cup/teams_1954.txt +0 -30
- data/test/data/world-cup/teams_1962.txt +0 -29
- data/test/data/world-cup/teams_1974.txt +0 -29
- data/test/helper.rb +0 -120
- data/test/test_assoc_reader.rb +0 -201
- data/test/test_changes.rb +0 -74
- data/test/test_cursor.rb +0 -50
- data/test/test_date.rb +0 -100
- data/test/test_goals.rb +0 -109
- data/test/test_lang.rb +0 -130
- data/test/test_load.rb +0 -61
- data/test/test_reader.rb +0 -88
- data/test/test_reader_from_string.rb +0 -65
- data/test/test_round_auto.rb +0 -370
- data/test/test_round_def.rb +0 -109
- data/test/test_round_header.rb +0 -183
- data/test/test_scores.rb +0 -70
- data/test/test_squad_club_reader.rb +0 -76
- data/test/test_squad_national_team_reader.rb +0 -116
- data/test/test_standings.rb +0 -279
- data/test/test_standings_ii.rb +0 -46
- data/test/test_utils.rb +0 -124
- data/test/test_winner.rb +0 -95
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d9324898363df6c12153669aecc98373b2fa3b0
|
4
|
+
data.tar.gz: 979905b01383585177295b1c8a2ff26fe28210a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
4
|
-
* Add --generate/g option for generating fixtures from the DB using templates
|
2
|
+
### 0.1.0 / 2014-12-05
|
5
3
|
|
6
|
-
|
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
|
data/Manifest.txt
CHANGED
@@ -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/
|
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
|
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 =
|
11
|
-
|
12
|
-
self.summary = 'sportdb - sport.db
|
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
|
-
# --
|
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
|
-
['
|
27
|
-
|
28
|
-
['
|
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'] #
|
48
|
-
|
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
|
-
|
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
|
-
|
data/lib/sportdb.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|