sportdb 1.8.0 → 1.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,15 +13,11 @@ lib/sportdb.rb
13
13
  lib/sportdb/cli/main.rb
14
14
  lib/sportdb/cli/opts.rb
15
15
  lib/sportdb/console.rb
16
- lib/sportdb/data/fixtures.rb
17
16
  lib/sportdb/data/keys.rb
18
17
  lib/sportdb/data/models.rb
19
18
  lib/sportdb/deleter.rb
20
19
  lib/sportdb/lang.rb
21
20
  lib/sportdb/models/badge.rb
22
- lib/sportdb/models/city.rb
23
- lib/sportdb/models/continent.rb
24
- lib/sportdb/models/country.rb
25
21
  lib/sportdb/models/event.rb
26
22
  lib/sportdb/models/event_team.rb
27
23
  lib/sportdb/models/forward.rb
@@ -31,10 +27,8 @@ lib/sportdb/models/group.rb
31
27
  lib/sportdb/models/group_team.rb
32
28
  lib/sportdb/models/league.rb
33
29
  lib/sportdb/models/person.rb
34
- lib/sportdb/models/prop.rb
35
30
  lib/sportdb/models/race.rb
36
31
  lib/sportdb/models/record.rb
37
- lib/sportdb/models/region.rb
38
32
  lib/sportdb/models/roster.rb
39
33
  lib/sportdb/models/round.rb
40
34
  lib/sportdb/models/run.rb
@@ -42,6 +36,10 @@ lib/sportdb/models/season.rb
42
36
  lib/sportdb/models/team.rb
43
37
  lib/sportdb/models/track.rb
44
38
  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/region.rb
45
43
  lib/sportdb/reader.rb
46
44
  lib/sportdb/schema.rb
47
45
  lib/sportdb/service.rb
@@ -79,7 +77,6 @@ lib/sportdb/title.rb
79
77
  lib/sportdb/updater.rb
80
78
  lib/sportdb/utils.rb
81
79
  lib/sportdb/version.rb
82
- tasks/test.rb
83
80
  test/helper.rb
84
81
  test/test_changes.rb
85
82
  test/test_cursor.rb
data/README.md CHANGED
@@ -139,9 +139,9 @@ Just install the gem:
139
139
  ## Free Open Public Domain Datasets
140
140
 
141
141
  - [`football.db`](https://github.com/openfootball) - free open public domain football (soccer) data for use in any (programming) language
142
- - [`formula1.db`](https://github.com/geraldb/formula1.db) - free open public domain Formula 1/Formula One data for use in any (programming) language
143
- - [`ski.db`](https://github.com/geraldb/ski.db) - free open public domain Ski Alpin/Alpine Ski data for use in any (programming) language
144
- - [`sport.db`](https://github.com/geraldb/sport.db) - free open public domain sports data for use in any (programming) language
142
+ - [`formula1.db`](https://github.com/opensport/formula1.db) - free open public domain Formula 1/Formula One data for use in any (programming) language
143
+ - [`ski.db`](https://github.com/opensport/ski.db) - free open public domain Ski Alpin/Alpine Ski data for use in any (programming) language
144
+ - [`american-football.db`](https://github.com/opensport/american-football.db) - free open public domain American Football data for use in any (programming) language
145
145
 
146
146
 
147
147
  ## License
@@ -31,10 +31,11 @@ require 'sportdb/version'
31
31
 
32
32
  require 'sportdb/title' ## fix - move to textutils gem
33
33
  require 'sportdb/models/forward'
34
+ require 'sportdb/models/world/city'
35
+ require 'sportdb/models/world/country'
36
+ require 'sportdb/models/world/continent'
37
+ require 'sportdb/models/world/region'
34
38
  require 'sportdb/models/badge'
35
- require 'sportdb/models/city'
36
- require 'sportdb/models/country'
37
- require 'sportdb/models/continent'
38
39
  require 'sportdb/models/event'
39
40
  require 'sportdb/models/event_team'
40
41
  require 'sportdb/models/game'
@@ -43,10 +44,8 @@ require 'sportdb/models/group'
43
44
  require 'sportdb/models/group_team'
44
45
  require 'sportdb/models/league'
45
46
  require 'sportdb/models/person'
46
- require 'sportdb/models/prop'
47
47
  require 'sportdb/models/race'
48
48
  require 'sportdb/models/record'
49
- require 'sportdb/models/region'
50
49
  require 'sportdb/models/roster'
51
50
  require 'sportdb/models/round'
52
51
  require 'sportdb/models/run'
@@ -54,6 +53,13 @@ require 'sportdb/models/season'
54
53
  require 'sportdb/models/team'
55
54
  require 'sportdb/models/track'
56
55
  require 'sportdb/models/utils' # e.g. GameCursor
56
+
57
+ ## add backwards compatible namespace (delete later!)
58
+ module SportDb
59
+ Models = Model
60
+ end
61
+
62
+
57
63
  require 'sportdb/schema' # NB: requires sportdb/models (include SportDB::Models)
58
64
  require 'sportdb/utils'
59
65
  require 'sportdb/reader'
@@ -72,7 +78,6 @@ require 'sportdb/stats'
72
78
  # todo/fix => remove from here and move into console.rb and tasks.rb
73
79
 
74
80
  require 'sportdb/data/keys'
75
- require 'sportdb/data/fixtures'
76
81
  require 'sportdb/data/models' # add convenience finders for known fixtures
77
82
 
78
83
 
@@ -114,7 +119,7 @@ module SportDb
114
119
 
115
120
  def self.create
116
121
  CreateDb.new.up
117
- WorldDb::Models::Prop.create!( key: 'db.schema.sport.version', value: VERSION )
122
+ WorldDb::Model::Prop.create!( key: 'db.schema.sport.version', value: VERSION )
118
123
  end
119
124
 
120
125
  def self.read_setup( setup, include_path )
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module SportDb::Models
3
+ module SportDb::Model
4
4
 
5
5
  ## add convenience finders to some model classes
6
6
 
@@ -38,6 +38,6 @@ module SportDb::Models
38
38
 
39
39
  end # class Event
40
40
 
41
- end # module SportDb::Models
41
+ end # module SportDb::Model
42
42
 
43
43
 
@@ -1,4 +1,4 @@
1
- module SportDb::Models
1
+ module SportDb::Model
2
2
 
3
3
  class Badge < ActiveRecord::Base
4
4
 
@@ -9,4 +9,5 @@ class Badge < ActiveRecord::Base
9
9
  end # class Badge
10
10
 
11
11
 
12
- end # module SportDb::Models
12
+ end # module SportDb::Model
13
+
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module SportDb::Models
3
+ module SportDb::Model
4
4
 
5
5
  class Event < ActiveRecord::Base
6
6
 
@@ -54,4 +54,4 @@ class Event < ActiveRecord::Base
54
54
 
55
55
  end # class Event
56
56
 
57
- end # module SportDb::Models
57
+ end # module SportDb::Model
@@ -1,4 +1,4 @@
1
- module SportDb::Models
1
+ module SportDb::Model
2
2
 
3
3
 
4
4
  class EventTeam < ActiveRecord::Base
@@ -9,4 +9,4 @@ class EventTeam < ActiveRecord::Base
9
9
  end # class EventTeam
10
10
 
11
11
 
12
- end # module SportDb::Models
12
+ end # module SportDb::Model
@@ -2,15 +2,15 @@
2
2
  ### forward references
3
3
  ## require first to resolve circular references
4
4
 
5
- module SportDb::Models
5
+ module SportDb::Model
6
6
 
7
7
  ## todo: why? why not use include WorldDb::Models here???
8
8
 
9
- Continent = WorldDb::Models::Continent
10
- Country = WorldDb::Models::Country
11
- Region = WorldDb::Models::Region
12
- City = WorldDb::Models::City
13
- Prop = WorldDb::Models::Prop
9
+ Continent = WorldDb::Model::Continent
10
+ Country = WorldDb::Model::Country
11
+ Region = WorldDb::Model::Region
12
+ City = WorldDb::Model::City
13
+ Prop = WorldDb::Model::Prop
14
14
 
15
15
  ## nb: for now only team and league use worlddb tables
16
16
  # e.g. with belongs_to assoc (country,region)
@@ -21,12 +21,12 @@ module SportDb::Models
21
21
  end
22
22
 
23
23
 
24
- module WorldDb::Models
24
+ module WorldDb::Model
25
25
 
26
26
  # add alias? why? why not? # is there a better way?
27
27
  # - just include SportDb::Models - why? why not?
28
28
  # - just include once in loader??
29
- Team = SportDb::Models::Team
30
- League = SportDb::Models::League
29
+ Team = SportDb::Model::Team
30
+ League = SportDb::Model::League
31
31
 
32
32
  end
@@ -1,4 +1,4 @@
1
- module SportDb::Models
1
+ module SportDb::Model
2
2
 
3
3
 
4
4
  class Game < ActiveRecord::Base
@@ -86,53 +86,19 @@ class Game < ActiveRecord::Base
86
86
 
87
87
  ### getter/setters for deprecated attribs (score3,4,5,6) n national
88
88
 
89
- def score3
90
- score1et
91
- end
92
-
93
- def score4
94
- score2et
95
- end
96
-
97
- def score1ot
98
- score1et
99
- end
100
-
101
- def score2ot
102
- score2et
103
- end
104
-
105
- def score5
106
- score1p
107
- end
108
-
109
- def score6
110
- score2p
111
- end
89
+ def score3() score1et end
90
+ def score4() score2et end
91
+ def score1ot() score1et end
92
+ def score2ot() score2et end
93
+ def score5() score1p end
94
+ def score6() score2p end
112
95
 
113
- def score3=(value)
114
- self.score1et = value
115
- end
116
-
117
- def score4=(value)
118
- self.score2et = value
119
- end
120
-
121
- def score1ot=(value)
122
- self.score1et = value
123
- end
124
-
125
- def score2ot=(value)
126
- self.score2et = value
127
- end
128
-
129
- def score5=(value)
130
- self.score1p = value
131
- end
132
-
133
- def score6=(value)
134
- self.score2p = value
135
- end
96
+ def score3=(value) self.score1et = value end
97
+ def score4=(value) self.score2et = value end
98
+ def score1ot=(value) self.score1et = value end
99
+ def score2ot=(value) self.score2et = value end
100
+ def score5=(value) self.score1p = value end
101
+ def score6=(value) self.score2p = value end
136
102
 
137
103
 
138
104
 
@@ -391,4 +357,4 @@ class Game < ActiveRecord::Base
391
357
  end # class Game
392
358
 
393
359
 
394
- end # module SportDb::Models
360
+ end # module SportDb::Model
@@ -1,4 +1,4 @@
1
- module SportDb::Models
1
+ module SportDb::Model
2
2
 
3
3
 
4
4
  class Goal < ActiveRecord::Base
@@ -9,4 +9,4 @@ class Goal < ActiveRecord::Base
9
9
  end # class Goal
10
10
 
11
11
 
12
- end # module SportDb::Models
12
+ end # module SportDb::Model
@@ -1,4 +1,4 @@
1
- module SportDb::Models
1
+ module SportDb::Model
2
2
 
3
3
 
4
4
  class Group < ActiveRecord::Base
@@ -19,5 +19,5 @@ class Group < ActiveRecord::Base
19
19
  end # class Group
20
20
 
21
21
 
22
- end # module SportDb::Models
22
+ end # module SportDb::Model
23
23
 
@@ -1,4 +1,4 @@
1
- module SportDb::Models
1
+ module SportDb::Model
2
2
 
3
3
 
4
4
  class GroupTeam < ActiveRecord::Base
@@ -9,5 +9,5 @@ class GroupTeam < ActiveRecord::Base
9
9
  end # class GroupTeam
10
10
 
11
11
 
12
- end # module SportDb::Models
12
+ end # module SportDb::Model
13
13
 
@@ -1,4 +1,4 @@
1
- module SportDb::Models
1
+ module SportDb::Model
2
2
 
3
3
 
4
4
  class League < ActiveRecord::Base
@@ -10,7 +10,7 @@ class League < ActiveRecord::Base
10
10
  has_many :events
11
11
  has_many :seasons, :through => :events
12
12
 
13
- belongs_to :country, :class_name => 'WorldDb::Models::Country', :foreign_key => 'country_id'
13
+ belongs_to :country, :class_name => 'WorldDb::Model::Country', :foreign_key => 'country_id'
14
14
 
15
15
 
16
16
  def self.create_or_update_from_values( new_attributes, values )
@@ -78,4 +78,4 @@ class League < ActiveRecord::Base
78
78
  end # class League
79
79
 
80
80
 
81
- end # module SportDb::Models
81
+ end # module SportDb::Model
@@ -1,4 +1,4 @@
1
- module SportDb::Models
1
+ module SportDb::Model
2
2
 
3
3
 
4
4
  class Person < ActiveRecord::Base
@@ -6,16 +6,11 @@ class Person < ActiveRecord::Base
6
6
 
7
7
  has_many :goals
8
8
 
9
- belongs_to :country, :class_name => 'WorldDb::Models::Country', :foreign_key => 'country_id'
9
+ belongs_to :country, :class_name => 'WorldDb::Model::Country', :foreign_key => 'country_id'
10
10
 
11
11
 
12
- def title # alias for name
13
- name
14
- end
15
-
16
- def title=(value) # alias for name
17
- self.name = value
18
- end
12
+ def title() name end # alias for name
13
+ def title=(value) self.name = value end # alias for name
19
14
 
20
15
 
21
16
  def self.create_or_update_from_values( new_attributes, values )
@@ -67,4 +62,5 @@ class Person < ActiveRecord::Base
67
62
  end # class Person
68
63
 
69
64
 
70
- end # module SportDb::Models
65
+ end # module SportDb::Model
66
+
@@ -1,4 +1,4 @@
1
- module SportDb::Models
1
+ module SportDb::Model
2
2
 
3
3
 
4
4
  class Race < ActiveRecord::Base
@@ -13,4 +13,4 @@ class Race < ActiveRecord::Base
13
13
  end # class Race
14
14
 
15
15
 
16
- end # module SportDb::Models
16
+ end # module SportDb::Model
@@ -1,4 +1,4 @@
1
- module SportDb::Models
1
+ module SportDb::Model
2
2
 
3
3
 
4
4
  class Record < ActiveRecord::Base
@@ -10,4 +10,4 @@ class Record < ActiveRecord::Base
10
10
  end # class Record
11
11
 
12
12
 
13
- end # module SportDb::Models
13
+ end # module SportDb::Model
@@ -1,4 +1,6 @@
1
- module SportDb::Models
1
+ module SportDb::Model
2
+
3
+ ### use LineUp, Squad for name? - alias??
2
4
 
3
5
  class Roster < ActiveRecord::Base
4
6
 
@@ -9,4 +11,4 @@ class Roster < ActiveRecord::Base
9
11
  end # class Roster
10
12
 
11
13
 
12
- end # module SportDb::Models
14
+ end # module SportDb::Model
@@ -1,4 +1,4 @@
1
- module SportDb::Models
1
+ module SportDb::Model
2
2
 
3
3
 
4
4
  class Round < ActiveRecord::Base
@@ -9,5 +9,5 @@ class Round < ActiveRecord::Base
9
9
  end # class Round
10
10
 
11
11
 
12
- end # module SportDb::Models
12
+ end # module SportDb::Model
13
13
 
@@ -1,4 +1,4 @@
1
- module SportDb::Models
1
+ module SportDb::Model
2
2
 
3
3
 
4
4
  class Run < ActiveRecord::Base
@@ -8,4 +8,4 @@ class Run < ActiveRecord::Base
8
8
  end # class Run
9
9
 
10
10
 
11
- end # module SportDb::Models
11
+ end # module SportDb::Model
@@ -1,4 +1,4 @@
1
- module SportDb::Models
1
+ module SportDb::Model
2
2
 
3
3
 
4
4
  class Season < ActiveRecord::Base
@@ -8,4 +8,4 @@ class Season < ActiveRecord::Base
8
8
  end # class Season
9
9
 
10
10
 
11
- end # module SportDb::Models
11
+ end # module SportDb::Model
@@ -1,4 +1,4 @@
1
- module SportDb::Models
1
+ module SportDb::Model
2
2
 
3
3
 
4
4
  class Team < ActiveRecord::Base
@@ -32,8 +32,8 @@ class Team < ActiveRecord::Base
32
32
 
33
33
  has_many :badges # Winner, 2nd, Cupsieger, Aufsteiger, Absteiger, etc.
34
34
 
35
- belongs_to :country, :class_name => 'WorldDb::Models::Country', :foreign_key => 'country_id'
36
- belongs_to :city, :class_name => 'WorldDb::Models::City', :foreign_key => 'city_id'
35
+ belongs_to :country, :class_name => 'WorldDb::Model::Country', :foreign_key => 'country_id'
36
+ belongs_to :city, :class_name => 'WorldDb::Model::City', :foreign_key => 'city_id'
37
37
 
38
38
 
39
39
 
@@ -129,4 +129,4 @@ class Team < ActiveRecord::Base
129
129
  end # class Team
130
130
 
131
131
 
132
- end # module SportDb::Models
132
+ end # module SportDb::Model
@@ -1,10 +1,10 @@
1
- module SportDb::Models
1
+ module SportDb::Model
2
2
 
3
3
  class Track < ActiveRecord::Base
4
4
 
5
5
  has_many :races
6
6
 
7
- belongs_to :country, :class_name => 'WorldDb::Models::Country', :foreign_key => 'country_id'
7
+ belongs_to :country, :class_name => 'WorldDb::Model::Country', :foreign_key => 'country_id'
8
8
 
9
9
  #####################
10
10
  ## convenience helper for text parser/reader
@@ -55,4 +55,4 @@ class Track < ActiveRecord::Base
55
55
  end # class Track
56
56
 
57
57
 
58
- end # module SportDb::Models
58
+ end # module SportDb::Model
@@ -1,5 +1,5 @@
1
1
  module SportDb
2
- module Models
2
+ module Model
3
3
 
4
4
 
5
5
  class GameCursor
@@ -74,5 +74,5 @@ class GameCursorState
74
74
  end # class GameCursorState
75
75
 
76
76
 
77
- end # module Models
77
+ end # module Model
78
78
  end # module SportDb
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ ## todo: how to best extends city model?
4
+
5
+ module WorldDb::Model
6
+
7
+ class City
8
+ has_many :teams, class_name: 'SportDb::Model::Team', foreign_key: 'city_id'
9
+ end
10
+
11
+ end # module WorldDb::Model
12
+
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
- module WorldDb::Models
3
+ module WorldDb::Model
4
4
 
5
5
  class Continent
6
6
  has_many :teams, :through => :countries
7
7
  has_many :leagues, :through => :countries
8
8
  end # class Continent
9
9
 
10
- end # module WorldDb::Models
10
+ end # module WorldDb::Model
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ ## todo: how to best extends country model?
4
+
5
+ module WorldDb::Model
6
+
7
+ class Country
8
+ has_many :teams, class_name: 'SportDb::Model::Team', foreign_key: 'country_id'
9
+ has_many :leagues, class_name: 'SportDb::Model::League', foreign_key: 'country_id'
10
+ end # class Country
11
+
12
+ end # module WorldDb::Model
13
+
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ ## todo: how to best extends country model?
4
+
5
+ module WorldDb::Model
6
+
7
+ class Region
8
+ has_many :teams, class_name: 'SportDb::Model::Team', :through => :cities
9
+ end # class Region
10
+
11
+ end # module WorldDb::Model
12
+
@@ -1,6 +1,6 @@
1
1
 
2
2
  module SportDb
3
- VERSION = '1.8.0'
3
+ VERSION = '1.8.1'
4
4
  end
5
5
 
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.8.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-31 00:00:00.000000000 Z
12
+ date: 2014-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: worlddb
16
- requirement: &19980396 !ruby/object:Gem::Requirement
16
+ requirement: &20011296 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.7'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *19980396
24
+ version_requirements: *20011296
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: fetcher
27
- requirement: &19978320 !ruby/object:Gem::Requirement
27
+ requirement: &20009076 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.3'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *19978320
35
+ version_requirements: *20009076
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: gli
38
- requirement: &19975680 !ruby/object:Gem::Requirement
38
+ requirement: &20104680 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.5.6
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *19975680
46
+ version_requirements: *20104680
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &19973184 !ruby/object:Gem::Requirement
49
+ requirement: &20102280 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '4.0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *19973184
57
+ version_requirements: *20102280
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: hoe
60
- requirement: &19970100 !ruby/object:Gem::Requirement
60
+ requirement: &20099184 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '3.7'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *19970100
68
+ version_requirements: *20099184
69
69
  description: sportdb - sport.db command line tool
70
70
  email: opensport@googlegroups.com
71
71
  executables:
@@ -91,15 +91,11 @@ files:
91
91
  - lib/sportdb/cli/main.rb
92
92
  - lib/sportdb/cli/opts.rb
93
93
  - lib/sportdb/console.rb
94
- - lib/sportdb/data/fixtures.rb
95
94
  - lib/sportdb/data/keys.rb
96
95
  - lib/sportdb/data/models.rb
97
96
  - lib/sportdb/deleter.rb
98
97
  - lib/sportdb/lang.rb
99
98
  - lib/sportdb/models/badge.rb
100
- - lib/sportdb/models/city.rb
101
- - lib/sportdb/models/continent.rb
102
- - lib/sportdb/models/country.rb
103
99
  - lib/sportdb/models/event.rb
104
100
  - lib/sportdb/models/event_team.rb
105
101
  - lib/sportdb/models/forward.rb
@@ -109,10 +105,8 @@ files:
109
105
  - lib/sportdb/models/group_team.rb
110
106
  - lib/sportdb/models/league.rb
111
107
  - lib/sportdb/models/person.rb
112
- - lib/sportdb/models/prop.rb
113
108
  - lib/sportdb/models/race.rb
114
109
  - lib/sportdb/models/record.rb
115
- - lib/sportdb/models/region.rb
116
110
  - lib/sportdb/models/roster.rb
117
111
  - lib/sportdb/models/round.rb
118
112
  - lib/sportdb/models/run.rb
@@ -120,6 +114,10 @@ files:
120
114
  - lib/sportdb/models/team.rb
121
115
  - lib/sportdb/models/track.rb
122
116
  - lib/sportdb/models/utils.rb
117
+ - lib/sportdb/models/world/city.rb
118
+ - lib/sportdb/models/world/continent.rb
119
+ - lib/sportdb/models/world/country.rb
120
+ - lib/sportdb/models/world/region.rb
123
121
  - lib/sportdb/reader.rb
124
122
  - lib/sportdb/schema.rb
125
123
  - lib/sportdb/service.rb
@@ -157,7 +155,6 @@ files:
157
155
  - lib/sportdb/updater.rb
158
156
  - lib/sportdb/utils.rb
159
157
  - lib/sportdb/version.rb
160
- - tasks/test.rb
161
158
  - test/helper.rb
162
159
  - test/test_changes.rb
163
160
  - test/test_cursor.rb
@@ -1,205 +0,0 @@
1
- # encoding: utf-8
2
-
3
- def find_football_db_path_from_gemfile_gitref!
4
- puts "[debug] find_football_db_path..."
5
- puts "load path:"
6
- pp $LOAD_PATH
7
-
8
- candidates = []
9
- $LOAD_PATH.each do |path|
10
- if path =~ /\/(football\.db-[a-z0-9]+)|(football\.db)\//
11
- candidates << path.dup
12
- end
13
- end
14
-
15
- puts "found candidates:"
16
- pp candidates
17
-
18
- ## cut-off everything after /football.db
19
- # e.g. lib/ruby/gems/1.9.1/bundler/gems/football.db-38279c414449/lib becomes
20
- # lib/ruby/gems/1.9.1/bundler/gems/football.db-38279c414449
21
-
22
- cand = candidates[0]
23
-
24
- puts "cand before: #{cand}"
25
-
26
- ## nb: *? is non-greedy many operator
27
-
28
- ## todo: why not just cut off trailing /lib - is it good enough??
29
- # it's easier
30
-
31
- regex = /(\/football\.db.*?)(\/.*)/
32
- cand = cand.sub( regex ) do |_|
33
- puts "cutting off >>#{$2}<<"
34
- $1
35
- end
36
-
37
- puts "cand after: #{cand}"
38
-
39
- ## todo:exit with error if not found!!!
40
-
41
- cand
42
- end
43
-
44
-
45
-
46
- module SportDb
47
-
48
- module Fixtures # use shortcut/alias Fx?
49
-
50
- ## todo/ check: remove _FIXTURES and use module namespace instead?
51
-
52
-
53
- SEASONS = [
54
- 'seasons'
55
- ]
56
-
57
- LEAGUES = [
58
- 'leagues',
59
- 'leagues_club'
60
- ]
61
-
62
- ## todo/check: put teams into its own module/namespace (remove _TEAMS?)
63
- EUROPE_TEAMS = [
64
- 'europe/teams'
65
- ]
66
-
67
- ## NB: copa america requires jpn as team invitee (from asia)
68
- AMERICA_TEAMS = [
69
- 'world/teams',
70
- 'america/teams'
71
- ]
72
-
73
- WORLD_TEAMS = [
74
- 'world/teams',
75
- 'america/teams',
76
- 'europe/teams'
77
- ]
78
-
79
- AT_TEAMS = [ 'at/teams', 'at/teams2' ]
80
- DE_TEAMS = [ 'de/teams' ]
81
- EN_TEAMS = [ 'en/teams' ]
82
- ES_TEAMS = [ 'es/teams' ]
83
- FR_TEAMS = [ 'fr/teams' ]
84
- IT_TEAMS = [ 'it/teams' ]
85
- RO_TEAMS = [ 'ro/teams' ]
86
-
87
- CLUB_EUROPE_TEAMS =
88
- AT_TEAMS +
89
- DE_TEAMS +
90
- EN_TEAMS +
91
- ES_TEAMS +
92
- FR_TEAMS +
93
- IT_TEAMS +
94
- RO_TEAMS +
95
- [
96
- 'club/europe/teams'
97
- ]
98
-
99
-
100
- AR_TEAMS = [ 'ar/teams' ]
101
- BR_TEAMS = [ 'br/teams' ]
102
- MX_TEAMS = [ 'mx/teams' ]
103
-
104
- CLUB_AMERICA_TEAMS =
105
- AR_TEAMS +
106
- BR_TEAMS +
107
- MX_TEAMS +
108
- [
109
- 'america/teams_c',
110
- 'america/teams_n',
111
- 'america/teams_s',
112
- ]
113
-
114
- AR_FIXTURES = []
115
-
116
- ### todo: ? get event_key automatically from event_reader ?? why? why not??
117
- BR_FIXTURES = [
118
- 'br/2013/cb'
119
- ]
120
-
121
- MX_FIXTURES = [
122
- 'mx/2012/apertura',
123
- 'mx/2013/clausura'
124
- ]
125
-
126
-
127
- AT_FIXTURES = [
128
- 'at/2011_12/bl',
129
- 'at/2011_12/cup',
130
- 'at/2012_13/bl',
131
- 'at/2012_13/cup'
132
- ]
133
-
134
- DE_FIXTURES = [
135
- 'de/2012_13/bl'
136
- ]
137
-
138
- EN_FIXTURES = [
139
- 'en/2012_13/pl'
140
- ]
141
-
142
- RO_FIXTURES = [
143
- 'ro/2012_13/l1'
144
- ]
145
-
146
-
147
- EUROPE_FIXTURES = [
148
- 'euro-cup!/2008/euro',
149
- 'euro-cup!/2012/euro'
150
- ]
151
-
152
- AMERICA_FIXTURES = [
153
- 'america/2011/copa',
154
- 'america/2011/gold',
155
- 'america/2013/gold',
156
- 'america/2015/copa'
157
- ]
158
-
159
- WORLD_FIXTURES = [
160
- 'world/2009/conf',
161
- 'world/2010/cup',
162
- 'world/2014/quali_america',
163
- 'world/2014/quali_europe_c',
164
- 'world/2014/quali_europe',
165
- 'world/2014/cup'
166
- ]
167
-
168
- CLUB_EUROPE_FIXTURES = [
169
- 'club/europe/2011_12/cl',
170
- 'club/europe/2011_12/el',
171
- 'club/europe/2012_13/cl',
172
- 'club/europe/2012_13/el'
173
- ]
174
-
175
- CLUB_AMERICA_FIXTURES = [
176
- 'club/america/2011_12/cl',
177
- 'club/america/2012/libertadores',
178
- 'club/america/2012/sud',
179
- 'club/america/2012_13/cl',
180
- 'club/america/2013/libertadores'
181
- ]
182
-
183
- def self.all
184
- SEASONS +
185
- LEAGUES +
186
- CLUB_AMERICA_TEAMS +
187
- AR_FIXTURES +
188
- BR_FIXTURES +
189
- MX_FIXTURES +
190
- CLUB_AMERICA_FIXTURES +
191
- CLUB_EUROPE_TEAMS +
192
- AT_FIXTURES +
193
- DE_FIXTURES +
194
- EN_FIXTURES +
195
- RO_FIXTURES +
196
- CLUB_EUROPE_FIXTURES +
197
- WORLD_TEAMS +
198
- AMERICA_FIXTURES +
199
- EUROPE_FIXTURES +
200
- WORLD_FIXTURES
201
- end # method all
202
-
203
- end # module Fixtures
204
-
205
- end # module SportDb
@@ -1,14 +0,0 @@
1
-
2
- ## todo: how to best extends city model?
3
-
4
- module WorldDb::Models
5
- class City
6
- has_many :teams, :class_name => 'SportDb::Models::Team', :foreign_key => 'city_id'
7
- end
8
- end # module WorldDb::Models
9
-
10
-
11
- ## moved to models/forward
12
- # module SportDb::Models
13
- # City = WorldDb::Models::City
14
- # end # module SportDb::Models
@@ -1,18 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ## todo: how to best extends country model?
4
-
5
- module WorldDb::Models
6
-
7
- class Country
8
- has_many :teams, :class_name => 'SportDb::Models::Team', :foreign_key => 'country_id'
9
- has_many :leagues, :class_name => 'SportDb::Models::League', :foreign_key => 'country_id'
10
- end # class Country
11
-
12
- end # module WorldDb::Models
13
-
14
-
15
- ## moved to models/forward
16
- # module SportDb::Models
17
- # Country = WorldDb::Models::Country
18
- # end # module SportDb::Models
@@ -1,7 +0,0 @@
1
- # encoding: utf-8
2
-
3
-
4
- ## moved to models/forward
5
- # module SportDb::Models
6
- # Prop = WorldDb::Models::Prop
7
- # end # module SportDb::Models
@@ -1,16 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ## todo: how to best extends country model?
4
-
5
- module WorldDb::Models
6
-
7
- class Region
8
- has_many :teams, :class_name => 'SportDb::Models::Team', :through => :cities
9
- end # class Region
10
-
11
- end # module WorldDb::Models
12
-
13
- ## moved to models/forward
14
- # module SportDb::Models
15
- # Region = WorldDb::Models::Region
16
- # end # module SportDb::Models
@@ -1,163 +0,0 @@
1
-
2
- #########################
3
- # Fill up sport.db w/ football.db fixtures
4
-
5
-
6
- ##############################
7
- ## for testing
8
- ##
9
- ## NB: use
10
- # rake -I ../world.db.ruby/lib -I ../sport.db.ruby/lib update
11
-
12
-
13
- include SportDB::Fixtures # include fixture constants like WORLD_FIXTURES, EN_FIXTURES etc.
14
-
15
-
16
- ##########
17
- # TODO: configure - copy to your rake file
18
-
19
- # INCLUDE_PATH = "../football.db"
20
-
21
- # BUILD_DIR = "./db"
22
-
23
- # SPORT_DB_PATH = "#{BUILD_DIR}/sport.db"
24
-
25
-
26
- ################
27
-
28
- DB_CONFIG = {
29
- :adapter => 'sqlite3',
30
- :database => SPORT_DB_PATH
31
- }
32
-
33
- directory BUILD_DIR
34
-
35
- # task :clean do
36
- # rm SPORT_DB_PATH if File.exists?( SPORT_DB_PATH )
37
- # end
38
-
39
- task :env => BUILD_DIR do
40
- pp DB_CONFIG
41
- ActiveRecord::Base.establish_connection( DB_CONFIG )
42
- end
43
-
44
- # task :create => :env do
45
- # WorldDB.create
46
- # end
47
-
48
- task :import => :env do
49
- reader = SportDB::Reader.new
50
-
51
- reader.load_seasons_with_include_path( 'seasons', INCLUDE_PATH )
52
-
53
- reader.load_leagues_with_include_path( 'leagues', INCLUDE_PATH )
54
- reader.load_leagues_with_include_path( 'leagues_club', INCLUDE_PATH, { club: true } )
55
- end
56
-
57
- ### club europe (cl,el)
58
- task :club_europe => [:import] do
59
- import_fixtures( CLUB_EUROPE_TEAMS, CLUB_EUROPE_FIXTURES )
60
- end
61
-
62
- ### club america
63
- task :club_america => [:import] do
64
- import_fixtures( CLUB_AMERICA_TEAMS, CLUB_AMERICA_FIXTURES )
65
- end
66
-
67
- task :europe => [:import] do
68
- import_fixtures( EUROPE_TEAMS, EUROPE_FIXTURES )
69
- end
70
-
71
- task :america => [:import] do
72
- import_fixtures( AMERICA_TEAMS, AMERICA_FIXTURES )
73
- end
74
-
75
- task :world => [:import] do
76
- import_fixtures( WORLD_TEAMS, WORLD_FIXTURES )
77
- end
78
-
79
- ### ar - Argentina
80
- task :ar => [:import] do
81
- import_fixtures( AR_TEAMS, AR_FIXTURES )
82
- end
83
-
84
- ### br - Brasil
85
- task :br => [:import] do
86
- import_fixtures( BR_TEAMS, BR_FIXTURES )
87
- end
88
-
89
- ### mx - Mexico
90
- task :mx => [:import] do
91
- import_fixtures( MX_TEAMS, MX_FIXTURES )
92
- end
93
-
94
- #### at - Austria
95
- task :at => [:import] do
96
- import_fixtures( AT_TEAMS, AT_FIXTURES )
97
- end
98
-
99
- #### de - Deutschland/Germany
100
- task :de => [:import] do
101
- import_fixtures( DE_TEAMS, DE_FIXTURES )
102
- end
103
-
104
- #### en - England
105
- task :en => [:import] do
106
- import_fixtures( EN_TEAMS, EN_FIXTURES )
107
- end
108
-
109
- #### ro - Romania
110
- task :ro => [:import] do
111
- import_fixtures( RO_TEAMS, RO_FIXTURES )
112
- end
113
-
114
-
115
-
116
- desc 'worlddb - test loading of builtin fixtures (update)'
117
- task :update => [:world]
118
- # task :update => [:at, :de, :en, :ro, :ar, :br, :mx]
119
-
120
-
121
-
122
- def import_fixtures( teams, fixtures )
123
- reader = SportDB::Reader.new
124
- reader.load_with_include_path( teams, INCLUDE_PATH )
125
- reader.load_with_include_path( fixtures, INCLUDE_PATH )
126
- end
127
-
128
-
129
-
130
- =begin
131
-
132
- ##################
133
- # usage sample
134
- ##################
135
-
136
- #### step 1) configure tasks in test.rb in your rake file
137
-
138
- Rakefile:
139
-
140
- INCLUDE_PATH = "../football.db"
141
-
142
- BUILD_DIR = "./db"
143
-
144
- SPORT_DB_PATH = "#{BUILD_DIR}/sport.db"
145
-
146
-
147
- #### step 2) include tasks in test.rb
148
-
149
- SPORT_DB_RUBY_PATH = "../sport.db.ruby"
150
- WORLD_DB_RUBY_PATH = "../world.db.ruby"
151
-
152
- require "#{WORLD_DB_RUBY_PATH}/lib/worlddb.rb"
153
- require "#{SPORT_DB_RUBY_PATH}/lib/sportdb.rb"
154
-
155
- require "#{SPORT_DB_RUBY_PATH}/tasks/test.rb"
156
-
157
- Shell:
158
-
159
- ### step 3) call on command line
160
-
161
- $ rake -I ../world.db.ruby/lib -I ../sport.db.ruby/lib update
162
-
163
- =end