sportdb 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ module SportDB
2
+ module Models
3
+
4
+
5
+ class Group < ActiveRecord::Base
6
+
7
+ has_many :games, :order => 'pos'
8
+ belongs_to :event
9
+
10
+ has_many :group_teams, :class_name => 'GroupTeam'
11
+ has_many :teams, :through => :group_teams
12
+
13
+ end # class Group
14
+
15
+
16
+ end # module Models
17
+ end # module SportDB
18
+
@@ -0,0 +1,15 @@
1
+ module SportDB
2
+ module Models
3
+
4
+
5
+ class GroupTeam < ActiveRecord::Base
6
+ self.table_name = 'groups_teams'
7
+
8
+ belongs_to :group
9
+ belongs_to :team
10
+ end # class GroupTeam
11
+
12
+
13
+ end # module Models
14
+ end # module SportDB
15
+
@@ -0,0 +1,12 @@
1
+ module SportDB
2
+ module Models
3
+
4
+
5
+ class Prop < ActiveRecord::Base
6
+
7
+ end # class Prop
8
+
9
+
10
+
11
+ end # module Models
12
+ end # module SportDB
@@ -0,0 +1,15 @@
1
+ module SportDB
2
+ module Models
3
+
4
+
5
+ class Round < ActiveRecord::Base
6
+
7
+ has_many :games, :order => 'pos'
8
+ belongs_to :event
9
+
10
+ end # class Round
11
+
12
+
13
+ end # module Models
14
+ end # module SportDB
15
+
@@ -0,0 +1,49 @@
1
+ module SportDB
2
+ module Models
3
+
4
+
5
+ class Team < ActiveRecord::Base
6
+
7
+ has_many :home_games, :class_name => 'Game', :foreign_key => 'team1_id'
8
+ has_many :away_games, :class_name => 'Game', :foreign_key => 'team2_id'
9
+
10
+ belongs_to :country, :class_name => 'Country', :foreign_key => 'country_id'
11
+
12
+
13
+ def self.create_from_ary!( teams, more_values={} )
14
+ teams.each do |values|
15
+
16
+ ## key & title required
17
+ attr = {
18
+ :key => values[0],
19
+ :title => values[1]
20
+ }
21
+
22
+ attr = attr.merge( more_values )
23
+
24
+ ## check for optional values
25
+ values[2..-1].each do |value|
26
+ if value.is_a? Country
27
+ attr[ :country_id ] = value.id
28
+ elsif value.length == 3 ## assume its a tag (three latters)
29
+ attr[ :tag ] = value
30
+ else
31
+ attr[ :title2 ] = value
32
+ end
33
+ end
34
+
35
+ ## check if exists
36
+ team = Team.find_by_key( values[0] )
37
+ if team.present?
38
+ puts "*** warning team with key '#{values[0]}' exists; skipping create"
39
+ else
40
+ Team.create!( attr )
41
+ end
42
+ end # each team
43
+ end
44
+
45
+ end # class Team
46
+
47
+
48
+ end # module Models
49
+ end # module SportDB
@@ -3,10 +3,23 @@ module SportDB
3
3
 
4
4
  class CreateDB
5
5
 
6
+
7
+ ## make models available in sportdb module by default with namespace
8
+ # e.g. lets you use Team instead of Models::Team
9
+ include SportDB::Models
10
+
11
+
6
12
  def self.up
7
13
 
8
14
  ActiveRecord::Schema.define do
9
15
 
16
+ create_table :countries do |t|
17
+ t.string :title, :null => false
18
+ t.string :tag, :null => false # short three letter tag
19
+ t.string :key, :null => false
20
+ t.timestamps
21
+ end
22
+
10
23
  create_table :props do |t|
11
24
  t.string :key, :null => false
12
25
  t.string :value, :null => false
@@ -18,6 +31,9 @@ create_table :teams do |t|
18
31
  t.string :title2
19
32
  t.string :key, :null => false # import/export key
20
33
  t.string :tag # make it not null? - three letter tag (short title)
34
+ t.references :country, :null => false
35
+ t.boolean :club, :null => false, :default => false # is it a club (not a national team)?
36
+ t.boolean :national, :null => false, :default => false # is it a national selection team (not a club)?
21
37
  t.timestamps
22
38
  end
23
39
 
@@ -35,11 +51,12 @@ add_index :events, :key, :unique => true
35
51
 
36
52
 
37
53
  create_table :rounds do |t|
38
- t.references :event, :null => false
39
- t.string :title, :null => false
54
+ t.references :event, :null => false
55
+ t.string :title, :null => false
40
56
  t.string :title2
41
- t.integer :pos, :null => false
42
- t.boolean :playoff, :null => false, :default => false # "regular" season (group) games or post-season (playoff) knockouts (k.o's)
57
+ t.integer :pos, :null => false
58
+ t.boolean :playoff, :null => false, :default => false # "regular" season (group) games or post-season (playoff) knockouts (k.o's)
59
+ t.datetime :start_at, :null => false
43
60
  t.timestamps
44
61
  end
45
62
 
@@ -109,7 +126,7 @@ add_index :groups_teams, :group_id
109
126
  end # block Schema.define
110
127
 
111
128
 
112
- Prop.create!( :key => 'db.schema.version', :value => SportDB::VERSION )
129
+ Prop.create!( key: 'db.schema.version', value: SportDB::VERSION )
113
130
 
114
131
  end # method up
115
132
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module SportDB
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.1'
4
4
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gerald Bauer
@@ -15,12 +15,44 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-10-07 00:00:00 Z
18
+ date: 2012-10-14 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: rdoc
21
+ name: activerecord
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 31
29
+ segments:
30
+ - 3
31
+ - 2
32
+ - 8
33
+ version: 3.2.8
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: sqlite3
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 23
45
+ segments:
46
+ - 1
47
+ - 3
48
+ - 6
49
+ version: 1.3.6
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: rdoc
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
24
56
  none: false
25
57
  requirements:
26
58
  - - ~>
@@ -31,11 +63,11 @@ dependencies:
31
63
  - 10
32
64
  version: "3.10"
33
65
  type: :development
34
- version_requirements: *id001
66
+ version_requirements: *id003
35
67
  - !ruby/object:Gem::Dependency
36
68
  name: hoe
37
69
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
70
+ requirement: &id004 !ruby/object:Gem::Requirement
39
71
  none: false
40
72
  requirements:
41
73
  - - ~>
@@ -46,7 +78,7 @@ dependencies:
46
78
  - 0
47
79
  version: "3.0"
48
80
  type: :development
49
- version_requirements: *id002
81
+ version_requirements: *id004
50
82
  description: sportdb - sport.db command line tool
51
83
  email: opensport@googlegroups.com
52
84
  executables:
@@ -70,23 +102,48 @@ files:
70
102
  - db/cl/2011_12/el.rb
71
103
  - db/cl/2012_13/cl.rb
72
104
  - db/cl/teams.rb
105
+ - db/countries.rb
106
+ - db/de/2012_13/bl.rb
107
+ - db/de/teams.rb
108
+ - db/en/2012_13/pl.rb
109
+ - db/en/teams.rb
73
110
  - db/euro/2012.rb
74
111
  - db/euro/teams.rb
75
112
  - db/mx/apertura_2012.rb
76
113
  - db/mx/teams.rb
114
+ - db/nhl/teams.rb
115
+ - db/ro/l1_2012_13.rb
116
+ - db/ro/teams.rb
77
117
  - db/world/quali_2012_13.rb
118
+ - db/world/quali_2012_13_c.rb
119
+ - db/world/quali_2012_13_i.rb
78
120
  - lib/sportdb.rb
79
121
  - lib/sportdb/cli/opts.rb
80
122
  - lib/sportdb/cli/runner.rb
81
123
  - lib/sportdb/loader.rb
82
- - lib/sportdb/models.rb
124
+ - lib/sportdb/models/country.rb
125
+ - lib/sportdb/models/event.rb
126
+ - lib/sportdb/models/event_team.rb
127
+ - lib/sportdb/models/game.rb
128
+ - lib/sportdb/models/group.rb
129
+ - lib/sportdb/models/group_team.rb
130
+ - lib/sportdb/models/prop.rb
131
+ - lib/sportdb/models/round.rb
132
+ - lib/sportdb/models/team.rb
83
133
  - lib/sportdb/schema.rb
84
134
  - lib/sportdb/utils.rb
85
135
  - lib/sportdb/version.rb
86
136
  homepage: http://geraldb.github.com/sport.db
87
137
  licenses: []
88
138
 
89
- post_install_message:
139
+ post_install_message: |
140
+ ******************************************************************************
141
+
142
+ Questions? Comments? Send them along to the mailing list.
143
+ https://groups.google.com/group/opensport
144
+
145
+ ******************************************************************************
146
+
90
147
  rdoc_options:
91
148
  - --main
92
149
  - README.markdown