sportdb 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,7 +10,8 @@ ofb = Event.create!( key: 'at.cup.2011/12',
10
10
  title: 'ÖFB Cup 2011/12',
11
11
  start_at: Time.cet( '2011-10-10 17:00' ),
12
12
  league: League.find_by_key!('at.cup'),
13
- season: Season.find_by_key!('2011/12'))
13
+ season: Season.find_by_key!('2011/12'),
14
+ team3: false ) # no game for 3rd/4th place
14
15
 
15
16
 
16
17
  sturm = Team.find_by_key!( 'sturm' )
@@ -7,7 +7,8 @@ cup = Event.create!( key: 'at.cup.2012/13',
7
7
  title: 'ÖFB Cup 2012/13',
8
8
  start_at: Time.cet( '2012-07-13 00:00' ),
9
9
  league: League.find_by_key!('at.cup'),
10
- season: Season.find_by_key!('2012/13'))
10
+ season: Season.find_by_key!('2012/13'),
11
+ team3: false ) # no game for 3rd/4th place)
11
12
 
12
13
 
13
14
  ## 10 Bundeliga Teams
@@ -54,7 +54,7 @@ LASK Linz - SV Grödig 2:0 2012-09-25 19:
54
54
  TSV St. Johann - FC Lustenau 0:3 2012-09-25 19:00
55
55
  SC Sollenau - FC Wacker Innsbruck 1:1 1:5nV 2012-09-25 19:00
56
56
  Villacher SV - SC Wiener Neustadt 3:1 2012-09-25 19:00
57
- FC Dornbirn - Austria Wien 2:3 2012-09-25 20:30
57
+ FC Dornbirn - Austria Wien 2:3 2012-09-25 20:30
58
58
  ASK Bad Vöslau - SV Mattersburg 2:3 2012-09-26 16:00
59
59
  Union St. Florian - SV Ried 1:1 1:1nV 5:6iE 2012-09-26 19:00
60
60
  USV Allerheiligen - Rapid Wien 1:4 2012-09-26 19:00
@@ -9,7 +9,8 @@ cl = Event.create!( key: 'cl.2011/12',
9
9
  title: 'Champions League 2011/12',
10
10
  start_at: Time.cet( '2011-10-10 17:00' ),
11
11
  league: League.find_by_key!('cl'),
12
- season: Season.find_by_key!('2011/12'))
12
+ season: Season.find_by_key!('2011/12'),
13
+ team3: false )
13
14
 
14
15
 
15
16
  inter = Team.find_by_key!( 'inter' )
@@ -9,7 +9,8 @@ el = Event.create!( key: 'el.2011/12',
9
9
  title: 'Europa League 2011/12',
10
10
  start_at: Time.cet( '2011-10-10 17:00' ),
11
11
  league: League.find_by_key!('el'),
12
- season: Season.find_by_key!('2011/12'))
12
+ season: Season.find_by_key!('2011/12'),
13
+ team3: false )
13
14
 
14
15
  az = Team.find_by_key!( 'az' )
15
16
  valencia = Team.find_by_key!( 'valencia' )
@@ -9,7 +9,8 @@ cl = Event.create!( key: 'cl.2012/13',
9
9
  title: 'Champions League 2012/13',
10
10
  start_at: Time.cet( '2012-09-18 18:30' ),
11
11
  league: League.find_by_key!('cl'),
12
- season: Season.find_by_key!('2012/13'))
12
+ season: Season.find_by_key!('2012/13'),
13
+ team3: false )
13
14
 
14
15
  porto = Team.find_by_key!( 'porto' )
15
16
  kiew = Team.find_by_key!( 'kiew' )
@@ -19,6 +19,27 @@ class Event < ActiveRecord::Base
19
19
  self.teams << team
20
20
  end
21
21
  end
22
+
23
+ ###########################
24
+ ## convenience helpers
25
+
26
+ def self.find_at_2012_13!
27
+ self.find_by_key!( 'at.2012/13' )
28
+ end
29
+
30
+ def self.find_at_cup_2012_13!
31
+ self.find_by_key!( 'at.cup.2012/13' )
32
+ end
33
+
34
+ def self.find_cl_2012_13!
35
+ self.find_by_key!( 'cl.2012/13' )
36
+ end
37
+
38
+ def self.find_euro_2012!
39
+ self.find_by_key!( 'euro.2012')
40
+ end
41
+
42
+
22
43
 
23
44
  end # class Event
24
45
 
@@ -6,8 +6,10 @@ class Team < ActiveRecord::Base
6
6
  has_many :home_games, :class_name => 'Game', :foreign_key => 'team1_id'
7
7
  has_many :away_games, :class_name => 'Game', :foreign_key => 'team2_id'
8
8
 
9
+ REGEX_CODE = /^[A-Z][A-Z0-9_]{2}$/ # must start w/ letter a-z (2 n 3 can be number or underscore _)
10
+
9
11
  validates :key, :format => { :with => /^[a-z]{2,}$/, :message => 'expected two or more lowercase letters a-z' }
10
- validates :code, :format => { :with => /^[A-Z_]{3}$/, :message => 'expected three uppercase letters A-Z (and _)' }, :allow_nil => true
12
+ validates :code, :format => { :with => REGEX_CODE, :message => 'expected three uppercase letters A-Z (and _)' }, :allow_nil => true
11
13
 
12
14
 
13
15
  ### fix - how to do it with has_many macro? use finder_sql?
@@ -46,7 +48,7 @@ class Team < ActiveRecord::Base
46
48
  attr[ :country_id ] = value.id
47
49
  elsif value.is_a? City
48
50
  attr[ :city_id ] = value.id
49
- elsif value =~ /^[A-Z_]{3}$/ ## assume its three letter code (e.g. ITA)
51
+ elsif value =~ REGEX_CODE ## assume its three letter code (e.g. ITA or S04 etc.)
50
52
  attr[ :code ] = value
51
53
  elsif value =~ /^city:/ ## city:
52
54
  value_city_key = value[5..-1] ## cut off city: prefix
@@ -1,4 +1,4 @@
1
1
 
2
2
  module SportDB
3
- VERSION = '0.8.0'
3
+ VERSION = '0.8.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: 63
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 0
10
- version: 0.8.0
9
+ - 1
10
+ version: 0.8.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gerald Bauer