sportdb 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,11 +21,5 @@ team_keys_world2 = [
21
21
 
22
22
  world.add_teams_from_ary!( team_keys_world2 )
23
23
 
24
-
25
- world2 = Group.create!( event: world, pos: 2, title: 'Gruppe 2' )
26
-
27
- world2.add_teams_from_ary!( team_keys_world2 )
28
-
29
-
30
24
  ## The End
31
25
  #################
@@ -6,36 +6,36 @@
6
6
  # what timezone to use?
7
7
 
8
8
 
9
- ######################################################
10
- ### Group 2 | Mexico, Costa Rica, El Salvador, Guyana
11
9
 
10
+ Group 2 | Mexiko, Costa Rica, El Salvador, Guyana
12
11
 
13
- 1. Spieltag
12
+
13
+ 1. Spieltag / Group 2
14
14
 
15
15
  2012-06-09 12:00 Mexiko - Guyana 3:1
16
16
  2012-06-09 12:00 Costa Rica - El Salvador 2:2
17
17
 
18
- 2. Spieltag
18
+ 2. Spieltag / Group 2
19
19
 
20
20
  2012-06-13 12:00 Guyana - Costa Rica 0:4
21
21
  2012-06-13 12:00 El Salvador - Mexiko 1:2
22
22
 
23
- 3. Spieltag
23
+ 3. Spieltag / Group 2
24
24
 
25
25
  2012-09-08 12:00 El Salvador - Guyana 2:2
26
26
  2012-09-08 12:00 Costa Rica - Mexiko 0:2
27
27
 
28
- 4. Spieltag
28
+ 4. Spieltag / Group 2
29
29
 
30
30
  2012-09-12 12:00 Guyana - El Salvador 2:3
31
31
  2012-09-12 12:00 Mexiko - Costa Rica 1:0
32
32
 
33
- 5. Spieltag
33
+ 5. Spieltag / Group 2
34
34
 
35
35
  2012-10-13 12:00 Guyana - Mexiko 0:5
36
36
  2012-10-13 12:00 El Salvador - Costa Rica 0:1
37
37
 
38
- 6. Spieltag
38
+ 6. Spieltag / Group 2
39
39
 
40
40
  2012-10-17 12:00 Mexiko - El Salvador 2:0
41
41
  2012-10-17 12:00 Costa Rica - Guyana 7:0
@@ -10,5 +10,23 @@ world = Event.create!( league: League.find_by_key!('world.quali.euro'),
10
10
  season: Season.find_by_key!('2012/13'),
11
11
  start_at: Time.cet( '2012-09-07 00:00' ) )
12
12
 
13
+ team_keys_worldc = [
14
+ 'ger',
15
+ 'fro',
16
+ 'irl',
17
+ 'kaz',
18
+ 'aut',
19
+ 'swe' ]
20
+
21
+ team_keys_worldi = [
22
+ 'fra',
23
+ 'esp',
24
+ 'blr',
25
+ 'fin',
26
+ 'geo' ]
27
+
28
+ world.add_teams_from_ary!( team_keys_worldc + team_keys_worldi )
29
+
30
+
13
31
  ## The End
14
32
  #################
@@ -4,79 +4,81 @@
4
4
 
5
5
  # note: timezone for games (play_at) is *always* CET (central european time)
6
6
 
7
+ Gruppe C | GER FRO IRL KAZ AUT SWE
7
8
 
8
- 1. Spieltag - Fr. 7. Sep 2012
9
+
10
+ 1. Spieltag - Fr. 7. Sep 2012 / Gruppe C
9
11
 
10
12
  (1) ger 3:0 fro 2012-09-07 15:00
11
13
  (2) kaz 1:2 irl 2012-09-07 15:00
12
14
 
13
15
 
14
- 2. Spieltag - Di. 11. Sep 2012
16
+ 2. Spieltag - Di. 11. Sep 2012 / Gruppe C
15
17
 
16
18
  (3) aut 1:2 ger 2012-09-11 15:00
17
19
  (4) swe 2:0 kaz 2012-09-11 15:00
18
20
 
19
21
 
20
- 3. Spieltag - Fr. 12. Okt 2012
22
+ 3. Spieltag - Fr. 12. Okt 2012 / Gruppe C
21
23
 
22
24
  (5) irl 1:6 ger 2012-10-12 20:45
23
25
  (6) fro 1:2 swe 2012-10-12 18:00
24
26
  (7) kaz 0:0 aut 2012-10-12 18:00
25
27
 
26
28
 
27
- 4. Spieltag - Di. 16. Okt 2012
29
+ 4. Spieltag - Di. 16. Okt 2012 / Gruppe C
28
30
 
29
31
  (8) ger 4:4 swe 2012-10-16 20:45
30
32
  (9) fro 1:4 irl 2012-10-16 20:00
31
33
  (10) aut 4:0 kaz 2012-10-16 20:30
32
34
 
33
35
 
34
- 5. Spieltag - Fr. 22. Mär 2013
36
+ 5. Spieltag - Fr. 22. Mär 2013 / Gruppe C
35
37
 
36
38
  (11) kaz - ger 2013-03-22 15:00
37
39
  (12) aut - fro 2013-03-22 15:00
38
40
  (13) swe - irl 2013-03-22 15:00
39
41
 
40
42
 
41
- 6. Spieltag - Di. 26. Mär 2013
43
+ 6. Spieltag - Di. 26. Mär 2013 / Gruppe C
42
44
 
43
45
  (14) ger - kaz 2013-03-26 15:00
44
46
  (15) irl - aut 2013-03-26 15:00
45
47
 
46
48
 
47
- 7. Spieltag - Fr. 7. Jun 2013
49
+ 7. Spieltag - Fr. 7. Jun 2013 / Gruppe C
48
50
 
49
51
  (16) irl - fro 2013-06-07 15:00
50
52
  (17) aut - swe 2013-06-07 15:00
51
53
 
52
54
 
53
- 8. Spieltag - Di. 11. Jun 2013
55
+ 8. Spieltag - Di. 11. Jun 2013 / Gruppe C
54
56
 
55
57
  (18) swe - fro 2013-06-11 15:00
56
58
 
57
59
 
58
- 9. Spieltag - Fr. 6. Sep 2013
60
+ 9. Spieltag - Fr. 6. Sep 2013 / Gruppe C
59
61
 
60
62
  (19) ger - aut 2013-09-06 15:00
61
63
  (20) kaz - fro 2013-09-06 15:00
62
64
  (21) irl - swe 2013-09-06 15:00
63
65
 
64
66
 
65
- 10. Spieltag - Di. 10. Sep 2013
67
+ 10. Spieltag - Di. 10. Sep 2013 / Gruppe C
66
68
 
67
69
  (22) fro - ger 2013-09-10 15:00
68
70
  (23) aut - irl 2013-09-10 15:00
69
71
  (24) kaz - swe 2013-09-10 15:00
70
72
 
71
73
 
72
- 11. Spieltag - Fr. 11. Okt 2013
74
+ 11. Spieltag - Fr. 11. Okt 2013 / Gruppe C
73
75
 
74
76
  (25) ger - irl 2013-10-11 15:00
75
77
  (26) fro - kaz 2013-10-11 15:00
76
78
  (27) swe - aut 2013-10-11 15:00
77
79
 
78
80
 
79
- 12. Spieltag - Di. 15. Okt 2013
81
+ 12. Spieltag - Di. 15. Okt 2013 / Gruppe C
80
82
 
81
83
  (28) swe - ger 2013-10-15 15:00
82
84
  (29) fro - aut 2013-10-15 15:00
@@ -3,70 +3,72 @@
3
3
 
4
4
  # note: timezone for games (play_at) is *always* CET (central european time)
5
5
 
6
+ Gruppe I | FRA ESP BLR FIN GEO
6
7
 
7
- 1. Spieltag - Fr. 7. Sep 2012
8
+
9
+ 1. Spieltag - Fr. 7. Sep 2012 / Gruppe I
8
10
 
9
11
  (1) geo 1:0 blr 2012-09-07 15:00
10
12
  (2) fin 0:1 fra 2012-09-07 15:00
11
13
 
12
14
 
13
- 2. Spieltag - Di. 11. Sep 2012
15
+ 2. Spieltag - Di. 11. Sep 2012 / Gruppe I
14
16
 
15
17
  (3) geo 0:1 esp 2012-09-11 15:00
16
18
  (4) fra 3:1 blr 2012-09-11 15:00
17
19
 
18
20
 
19
- 3. Spieltag - Fr. 12. Okt 2012
21
+ 3. Spieltag - Fr. 12. Okt 2012 / Gruppe I
20
22
 
21
23
  (5) fin 1:1 geo 2012-10-12 17:30
22
24
  (6) blr 0:4 esp 2012-10-12 20:00
23
25
 
24
26
 
25
- 4. Spieltag - Di. 16. Okt 2012
27
+ 4. Spieltag - Di. 16. Okt 2012 / Gruppe I
26
28
 
27
29
  (7) esp 1:1 fra 2012-10-16 21:00
28
30
  (8) blr 2:0 geo 2012-10-16 18:00
29
31
 
30
32
 
31
- 5. Spieltag - Fr. 22. Mär 2013
33
+ 5. Spieltag - Fr. 22. Mär 2013 / Gruppe I
32
34
 
33
35
  (9) fra - geo 2013-03-22 15:00
34
36
  (10) esp - fin 2013-03-22 15:00
35
37
 
36
38
 
37
- 6. Spieltag - Di. 26. Mär 2013
39
+ 6. Spieltag - Di. 26. Mär 2013 / Gruppe I
38
40
 
39
41
  (11) fra - esp 2013-03-26 15:00
40
42
 
41
43
 
42
- 7. Spieltag - Fr. 7. Jun 2013
44
+ 7. Spieltag - Fr. 7. Jun 2013 / Gruppe I
43
45
 
44
46
  (12) fin - blr 2013-06-07 15:00
45
47
 
46
48
 
47
- 8. Spieltag - Di. 11. Jun 2013
49
+ 8. Spieltag - Di. 11. Jun 2013 / Gruppe I
48
50
 
49
51
  (13) blr - fin 2013-06-11 15:00
50
52
 
51
53
 
52
- 9. Spieltag - Fr. 6. Sep 2013
54
+ 9. Spieltag - Fr. 6. Sep 2013 / Gruppe I
53
55
 
54
56
  (14) geo - fra 2013-09-06 15:00
55
57
  (15) fin - esp 2013-09-06 15:00
56
58
 
57
59
 
58
- 10. Spieltag - Di. 10. Sep 2013
60
+ 10. Spieltag - Di. 10. Sep 2013 / Gruppe I
59
61
 
60
62
  (16) blr - fra 2013-09-10 15:00
61
63
  (17) geo - fin 2013-09-10 15:00
62
64
 
63
65
 
64
- 11. Spieltag - Fr. 11. Okt 2013
66
+ 11. Spieltag - Fr. 11. Okt 2013 / Gruppe I
65
67
 
66
68
  (18) esp - blr 2013-10-11 15:00
67
69
 
68
70
 
69
- 12. Spieltag - Di. 15. Okt 2013
71
+ 12. Spieltag - Di. 15. Okt 2013 / Gruppe I
70
72
 
71
73
  (19) fra - fin 2013-10-15 15:00
72
74
  (20) esp - geo 2013-10-15 15:00
data/db/world/teams.rb CHANGED
@@ -12,11 +12,11 @@ za = Country.find_by_key!( 'za' )
12
12
 
13
13
  teams_africa = [
14
14
  [ 'alg', 'Algerien', 'ALG', dz ],
15
- [ 'civ', 'Elfenbeinküste|Elfenbeinkueste', 'CIV', ci ],
15
+ [ 'civ', 'Elfenbeinküste', 'CIV', ci ],
16
16
  [ 'gha', 'Ghana', 'GHA', gh ],
17
17
  [ 'cmr', 'Kamerun', 'CMR', cm ],
18
18
  [ 'nga', 'Nigeria', 'NGA', ng ],
19
- [ 'rsa', 'Südafrika|Suedafrika', 'RSA', za ]
19
+ [ 'rsa', 'Südafrika', 'RSA', za ]
20
20
  ]
21
21
 
22
22
 
@@ -32,7 +32,7 @@ teams_asia = [
32
32
  [ 'aus', 'Australien', 'AUS', au ],
33
33
  [ 'jpn', 'Japan', 'JPN', jp ],
34
34
  [ 'prk', 'Nordkorea', 'PRK', kp ],
35
- [ 'kor', 'Südkorea|Suedkorea', 'KOR', kr ]
35
+ [ 'kor', 'Südkorea', 'KOR', kr ]
36
36
  ]
37
37
 
38
38
  ###############################
data/lib/sportdb.rb CHANGED
@@ -20,7 +20,9 @@ require 'worlddb'
20
20
 
21
21
  # our own code
22
22
 
23
- require 'sportdb/keys' # let keys go first; just string constants (get included in models)
23
+ require 'sportdb/version'
24
+
25
+ require 'sportdb/keys'
24
26
  require 'sportdb/models/forward'
25
27
  require 'sportdb/models/badge'
26
28
  require 'sportdb/models/city'
@@ -41,7 +43,6 @@ require 'sportdb/utils'
41
43
  require 'sportdb/loader'
42
44
  require 'sportdb/reader'
43
45
  require 'sportdb/templater'
44
- require 'sportdb/version'
45
46
  require 'sportdb/cli/opts'
46
47
  require 'sportdb/cli/runner'
47
48
 
@@ -76,21 +77,25 @@ module SportDB
76
77
  ['leagues',
77
78
  'seasons',
78
79
  'at/teams',
79
- # 'at/2011_12/bl',
80
+ 'at/2011_12/bl',
80
81
  # 'at/2011_12/cup',
81
- 'at/2012_13/bl',
82
+ # 'at/2012_13/bl',
82
83
  # 'at/2012_13/cup',
83
- 'copa/teams',
84
- 'copa/sud_2012_13'
84
+ # 'copa/teams',
85
+ # 'copa/sud_2012_13',
86
+ 'america/teams',
87
+ 'world/teams',
88
+ 'world/quali_2012_13_america'
85
89
  ]
86
90
  end
87
91
 
88
92
  def self.fixtures_txt_test
89
93
  [
90
- # [ AT_2011_12, 'at/2011_12/bl'],
91
- [ AT_2012_13, 'at/2012_13/bl'],
94
+ [ AT_2011_12, 'at/2011_12/bl'],
95
+ # [ AT_2012_13, 'at/2012_13/bl'],
92
96
  # [ AT_CUP_2012_13, 'at/2012_13/cup'],
93
- ['copa.sud.2012/13', 'copa/sud_2012_13']
97
+ # ['copa.sud.2012/13', 'copa/sud_2012_13'],
98
+ [ WORLD_QUALI_AMERICA_2012_13, 'world/quali_2012_13_america']
94
99
  ]
95
100
  end
96
101
 
@@ -126,8 +131,6 @@ module SportDB
126
131
  'world/teams',
127
132
  'world/2010',
128
133
  'world/quali_2012_13_europe',
129
- 'world/quali_2012_13_europe_c',
130
- 'world/quali_2012_13_europe_i',
131
134
  'world/quali_2012_13_america',
132
135
  'nhl/teams']
133
136
  end
@@ -65,7 +65,7 @@ sportdb - sport.db command line tool, version #{VERSION}
65
65
 
66
66
  Examples:
67
67
  sportdb cl/teams cl/2012_13/cl # import champions league (cl)
68
- sportdb -c # create database schema
68
+ sportdb --create # create database schema
69
69
 
70
70
  More Examples:
71
71
  sportdb # show stats (table counts, table props)
@@ -0,0 +1,54 @@
1
+ ## for use to run with interactive ruby (irb)
2
+ ## e.g. irb -r sportdb/console
3
+
4
+ require 'sportdb'
5
+
6
+ # some ruby stdlibs
7
+
8
+ require 'logger'
9
+ require 'pp' # pretty printer
10
+ require 'uri'
11
+ require 'json'
12
+ require 'yaml'
13
+
14
+
15
+ ## shortcuts for models
16
+
17
+ Event = SportDB::Models::Event
18
+ Team = SportDB::Models::Team
19
+ Game = SportDB::Models::Game
20
+ Group = SportDB::Models::Group
21
+ Round = SportDB::Models::Round
22
+ Season = SportDB::Models::Season
23
+ League = SportDB::Models::League
24
+ Badge = SportDB::Models::Badge
25
+
26
+ # Tag = WorldDB::Models::Tag
27
+ # Tagging = WorldDB::Models::Tagging
28
+ Country = WorldDB::Models::Country
29
+ Region = WorldDB::Models::Region
30
+ City = WorldDB::Models::City
31
+ Prop = WorldDB::Models::Prop
32
+
33
+ ## connect to db
34
+
35
+ DB_CONFIG = {
36
+ adapter: 'sqlite3',
37
+ database: 'sport.db'
38
+ }
39
+
40
+ pp DB_CONFIG
41
+ ActiveRecord::Base.establish_connection( DB_CONFIG )
42
+
43
+ ## test drive
44
+
45
+ puts "Welcome to sport.db, version #{SportDB::VERSION} (world.db, version #{WorldDB::VERSION})!"
46
+ puts " #{'%5d' % Event.count} events"
47
+ puts " #{'%5d' % Team.count} teams"
48
+ puts " #{'%5d' % Game.count} games"
49
+ puts " #{'%5d' % City.count} cities"
50
+ puts "Ready."
51
+
52
+ ## turn on activerecord logging to console
53
+
54
+ ActiveRecord::Base.logger = Logger.new( STDOUT )
data/lib/sportdb/keys.rb CHANGED
@@ -1,6 +1,5 @@
1
1
 
2
- module SportDB
3
- module Keys
2
+ module SportDB::Keys
4
3
 
5
4
  module EventKeys
6
5
  # use constants for known keys; lets us define aliases (if things change)
@@ -25,5 +24,4 @@ module SportDB
25
24
 
26
25
  include SportDB::Keys::EventKeys
27
26
 
28
- end # module Keys
29
- end # module SportDB
27
+ end # module SportDB::Keys
@@ -39,14 +39,13 @@ class Loader
39
39
 
40
40
  puts "*** loading data '#{name}' (#{path})..."
41
41
 
42
- code = File.read( path )
42
+ ## nb: assume/enfore utf-8 encoding (with or without BOM - byte order mark)
43
+ ## - see sportdb/utils.rb
44
+ code = File.read_utf8( path )
43
45
 
44
46
  load_fixtures_worker( code )
45
47
 
46
- ### fix:
47
- ## for loaded from fs use filestat? for version - why? why not?
48
-
49
- Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "rb.1" )
48
+ Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "file.rb.#{File.mtime(path).strftime('%Y.%m.%d')}" )
50
49
  end
51
50
 
52
51
  def load_fixtures_builtin( name ) # load from gem (built-in)
@@ -54,7 +53,7 @@ class Loader
54
53
 
55
54
  puts "*** loading data '#{name}' (#{path})..."
56
55
 
57
- code = File.read( path )
56
+ code = File.read_utf8( path )
58
57
 
59
58
  load_fixtures_worker( code )
60
59