sportdb 1.6.4 → 1.6.5

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -24,9 +24,11 @@ lib/sportdb/models/event.rb
24
24
  lib/sportdb/models/event_team.rb
25
25
  lib/sportdb/models/forward.rb
26
26
  lib/sportdb/models/game.rb
27
+ lib/sportdb/models/goal.rb
27
28
  lib/sportdb/models/group.rb
28
29
  lib/sportdb/models/group_team.rb
29
30
  lib/sportdb/models/league.rb
31
+ lib/sportdb/models/player.rb
30
32
  lib/sportdb/models/prop.rb
31
33
  lib/sportdb/models/region.rb
32
34
  lib/sportdb/models/round.rb
data/lib/sportdb.rb CHANGED
@@ -36,9 +36,11 @@ require 'sportdb/models/continent'
36
36
  require 'sportdb/models/event'
37
37
  require 'sportdb/models/event_team'
38
38
  require 'sportdb/models/game'
39
+ require 'sportdb/models/goal'
39
40
  require 'sportdb/models/group'
40
41
  require 'sportdb/models/group_team'
41
42
  require 'sportdb/models/league'
43
+ require 'sportdb/models/player'
42
44
  require 'sportdb/models/prop'
43
45
  require 'sportdb/models/region'
44
46
  require 'sportdb/models/round'
@@ -8,6 +8,8 @@ class Game < ActiveRecord::Base
8
8
 
9
9
  belongs_to :round
10
10
  belongs_to :group # group is optional
11
+
12
+ has_many :goals
11
13
 
12
14
  before_save :calc_toto12x
13
15
 
@@ -0,0 +1,12 @@
1
+ module SportDb::Models
2
+
3
+
4
+ class Goal < ActiveRecord::Base
5
+
6
+ belongs_to :game
7
+ belongs_to :player
8
+
9
+ end # class Goal
10
+
11
+
12
+ end # module SportDb::Models
@@ -0,0 +1,11 @@
1
+ module SportDb::Models
2
+
3
+
4
+ class Player < ActiveRecord::Base
5
+
6
+ has_many :goals
7
+
8
+ end # class Player
9
+
10
+
11
+ end # module SportDb::Models
@@ -529,9 +529,18 @@ private
529
529
  team1_key = find_team1!( line )
530
530
  team2_key = find_team2!( line )
531
531
 
532
- date = find_date!( line )
532
+ if is_postponed?( line )
533
+ postponed = true
534
+ date_v2 = find_date!( line )
535
+ date = find_date!( line )
536
+ else
537
+ postponed = false
538
+ date_v2 = nil
539
+ date = find_date!( line )
540
+ end
541
+
533
542
  scores = find_scores!( line )
534
-
543
+
535
544
  logger.debug " line: >#{line}<"
536
545
 
537
546
 
@@ -553,7 +562,9 @@ private
553
562
  score2ot: scores[3],
554
563
  score1p: scores[4],
555
564
  score2p: scores[5],
556
- play_at: date,
565
+ play_at: date,
566
+ play_at_v2: date_v2,
567
+ postponed: postponed,
557
568
  knockout: @knockout_flag,
558
569
  group_id: @group.present? ? @group.id : nil
559
570
  }
@@ -23,6 +23,32 @@ end
23
23
  add_index :teams, :key, :unique => true
24
24
 
25
25
 
26
+ create_table :players do |t|
27
+ t.string :key, :null => false # import/export key
28
+ t.string :name, :null => false
29
+ t.string :synonyms # comma separated list of synonyms
30
+
31
+ t.date :born_at # optional date of birth (birthday)
32
+ t.references :country, :null => false
33
+ t.timestamps
34
+ end
35
+
36
+ create_table :goals do |t|
37
+ t.references :player, :null => false
38
+ t.references :game, :null => false
39
+ t.integer :minute
40
+ t.integer :offset # e.g. 45' +3 or 90' +2
41
+ t.integer :score1
42
+ t.integer :score2
43
+
44
+ ## type of goal (penalty, owngoal)
45
+ t.boolean :penalty, :null => false, :default => false
46
+ t.boolean :owngoal, :null => false, :default => false # de: Eigentor -> # todo: find better name?
47
+
48
+ t.timestamps
49
+ end
50
+
51
+
26
52
  create_table :events do |t|
27
53
  t.string :key, :null => false # import/export key
28
54
  t.references :league, :null => false
@@ -68,7 +94,12 @@ create_table :games do |t|
68
94
  t.references :group # note: group is optional
69
95
  t.references :team1, :null => false
70
96
  t.references :team2, :null => false
71
- t.datetime :play_at, :null => false
97
+
98
+ t.datetime :play_at, :null => false
99
+ t.boolean :postponed, :null => false, :default => false
100
+ t.datetime :play_at_v2 # optional old date (when postponed)
101
+ t.datetime :play_at_v3 # optional odl date (when postponed twice)
102
+
72
103
  t.boolean :knockout, :null => false, :default => false
73
104
  t.boolean :home, :null => false, :default => true # is team1 play at home (that is, at its home stadium)
74
105
  t.integer :score1
@@ -84,6 +115,8 @@ create_table :games do |t|
84
115
  t.references :next_game # for hinspiel bei rueckspiel in knockout game
85
116
  t.references :prev_game
86
117
 
118
+
119
+
87
120
  ### todo> find a better name (toto is not international/english?)
88
121
  ## rename to score12x or pt12x or result12x
89
122
  t.string :toto12x # 1,2,X,nil calculate on save
@@ -133,6 +166,8 @@ create_table :leagues do |t| ## also for cups/conferences/tournaments/world ser
133
166
  t.string :key, :null => false
134
167
  t.string :title, :null => false # e.g. Premier League, Deutsche Bundesliga, World Cup, Champions League, etc.
135
168
  t.references :country ## optional for now , :null => false ### todo: create "virtual" country for international leagues e.g. use int? or world (ww?)/europe (eu)/etc. similar? already taken??
169
+
170
+ ## fix: rename to :clubs from :club
136
171
  t.boolean :club, :null => false, :default => false # club teams or national teams?
137
172
  ## todo: add t.boolean :national flag? for national teams?
138
173
  ## t.boolean :international, :null => false, :default => false # national league or international?
data/lib/sportdb/utils.rb CHANGED
@@ -5,6 +5,11 @@
5
5
 
6
6
  module SportDb::FixtureHelpers
7
7
 
8
+ def is_postponed?( line )
9
+ # check if line include postponed marker e.g. =>
10
+ line =~ /=>/
11
+ end
12
+
8
13
  def is_round?( line )
9
14
  line =~ SportDb.lang.regex_round
10
15
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  module SportDb
3
- VERSION = '1.6.4'
3
+ VERSION = '1.6.5'
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.6.4
4
+ version: 1.6.5
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: 2013-03-11 00:00:00.000000000 Z
12
+ date: 2013-03-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: worlddb
16
- requirement: &81413720 !ruby/object:Gem::Requirement
16
+ requirement: &74970830 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.6'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *81413720
24
+ version_requirements: *74970830
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: commander
27
- requirement: &81413460 !ruby/object:Gem::Requirement
27
+ requirement: &74970610 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 4.1.3
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *81413460
35
+ version_requirements: *74970610
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rdoc
38
- requirement: &81413240 !ruby/object:Gem::Requirement
38
+ requirement: &74970390 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '3.10'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *81413240
46
+ version_requirements: *74970390
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: hoe
49
- requirement: &81413020 !ruby/object:Gem::Requirement
49
+ requirement: &74970170 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '3.3'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *81413020
57
+ version_requirements: *74970170
58
58
  description: sportdb - sport.db command line tool
59
59
  email: opensport@googlegroups.com
60
60
  executables:
@@ -89,9 +89,11 @@ files:
89
89
  - lib/sportdb/models/event_team.rb
90
90
  - lib/sportdb/models/forward.rb
91
91
  - lib/sportdb/models/game.rb
92
+ - lib/sportdb/models/goal.rb
92
93
  - lib/sportdb/models/group.rb
93
94
  - lib/sportdb/models/group_team.rb
94
95
  - lib/sportdb/models/league.rb
96
+ - lib/sportdb/models/player.rb
95
97
  - lib/sportdb/models/prop.rb
96
98
  - lib/sportdb/models/region.rb
97
99
  - lib/sportdb/models/round.rb