sportdb-models 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,23 +1,23 @@
1
- # encoding: utf-8
2
-
3
- module SportDb
4
-
5
- # collection of regex patterns for reuse (SportDb specific)
6
-
7
- ### todo: add a patterns.md page to github ??
8
- ## - add regexper pics??
9
-
10
- TEAM_KEY_RE = %r{ \A
11
- [a-z_][a-z0-9_]*
12
- \z}x
13
- TEAM_KEY_MESSAGE = "expected one or more lowercase letters a-z (or 0-9 or _; must start with a-z or _)"
14
-
15
-
16
- # must start w/ letter A-Z (2nd,3rd,4th or 5th can be number)
17
- TEAM_CODE_RE = %r{ \A
18
- [A-Z_][A-Z0-9_]*
19
- \z}x
20
- TEAM_CODE_MESSAGE = "expected one or more uppercase letters A-Z (or 0-9 or _; must start with A-Z or _)"
21
-
22
-
23
- end # module SportDb
1
+ # encoding: utf-8
2
+
3
+ module SportDb
4
+
5
+ # collection of regex patterns for reuse (SportDb specific)
6
+
7
+ ### todo: add a patterns.md page to github ??
8
+ ## - add regexper pics??
9
+
10
+ TEAM_KEY_RE = %r{ \A
11
+ [a-z_][a-z0-9_]*
12
+ \z}x
13
+ TEAM_KEY_MESSAGE = "expected one or more lowercase letters a-z (or 0-9 or _; must start with a-z or _)"
14
+
15
+
16
+ # must start w/ letter A-Z (2nd,3rd,4th or 5th can be number)
17
+ TEAM_CODE_RE = %r{ \A
18
+ [A-Z_][A-Z0-9_]*
19
+ \z}x
20
+ TEAM_CODE_MESSAGE = "expected one or more uppercase letters A-Z (or 0-9 or _; must start with A-Z or _)"
21
+
22
+
23
+ end # module SportDb
@@ -1,38 +1,38 @@
1
- module SportDb
2
- module Model
3
-
4
- class Assoc < ActiveRecord::Base
5
-
6
-
7
- has_many :parent_assoc_assocs, class_name: 'AssocAssoc', foreign_key: 'assoc2_id'
8
- ## child_assocs - use child_assocs? - (direct) member/child assocs instead of member?
9
- has_many :member_assoc_assocs, class_name: 'AssocAssoc', foreign_key: 'assoc1_id'
10
-
11
-
12
- ## note: split member_assocs into two sets (into national=true and national=false)
13
- # e.g. fifa has six member confederations (non-national) and 216 national assocs
14
- ## note: includes all member (sub assocs + national assocs) - rename to member_assocs?
15
- has_many :all_assocs, class_name: 'Assoc', :source => :assoc2, :through => :member_assoc_assocs
16
- ## use zone/region as name instead of sub ( for confederatons,zones,etc.)
17
- has_many :sub_assocs, -> { where( national: false ) }, class_name: 'Assoc', :source => :assoc2, :through => :member_assoc_assocs
18
- has_many :national_assocs, -> { where( national: true ) }, class_name: 'Assoc', :source => :assoc2, :through => :member_assoc_assocs
19
-
20
- ## for now can have more than one (direct) parent assoc
21
- ## e.g. Africa Fed and Arab League Fed
22
- has_many :parent_assocs, class_name: 'Assoc', :source => :assoc1, :through => :parent_assoc_assocs
23
-
24
- # assoc only can have one direct team for now (uses belongs_to on other side)
25
- # has_one :team
26
- end # class Assoc
27
-
28
-
29
- class AssocAssoc < ActiveRecord::Base
30
- self.table_name = 'assocs_assocs'
31
-
32
- belongs_to :assoc1, class_name: 'Assoc', foreign_key: 'assoc1_id' # parent assoc
33
- belongs_to :assoc2, class_name: 'Assoc', foreign_key: 'assoc2_id' # child assoc is_member_of parent assoc
34
-
35
- end # class AssocAssoc
36
-
37
- end # module Model
38
- end # module SportDb
1
+ module SportDb
2
+ module Model
3
+
4
+ class Assoc < ActiveRecord::Base
5
+
6
+
7
+ has_many :parent_assoc_assocs, class_name: 'AssocAssoc', foreign_key: 'assoc2_id'
8
+ ## child_assocs - use child_assocs? - (direct) member/child assocs instead of member?
9
+ has_many :member_assoc_assocs, class_name: 'AssocAssoc', foreign_key: 'assoc1_id'
10
+
11
+
12
+ ## note: split member_assocs into two sets (into national=true and national=false)
13
+ # e.g. fifa has six member confederations (non-national) and 216 national assocs
14
+ ## note: includes all member (sub assocs + national assocs) - rename to member_assocs?
15
+ has_many :all_assocs, class_name: 'Assoc', :source => :assoc2, :through => :member_assoc_assocs
16
+ ## use zone/region as name instead of sub ( for confederatons,zones,etc.)
17
+ has_many :sub_assocs, -> { where( national: false ) }, class_name: 'Assoc', :source => :assoc2, :through => :member_assoc_assocs
18
+ has_many :national_assocs, -> { where( national: true ) }, class_name: 'Assoc', :source => :assoc2, :through => :member_assoc_assocs
19
+
20
+ ## for now can have more than one (direct) parent assoc
21
+ ## e.g. Africa Fed and Arab League Fed
22
+ has_many :parent_assocs, class_name: 'Assoc', :source => :assoc1, :through => :parent_assoc_assocs
23
+
24
+ # assoc only can have one direct team for now (uses belongs_to on other side)
25
+ # has_one :team
26
+ end # class Assoc
27
+
28
+
29
+ class AssocAssoc < ActiveRecord::Base
30
+ self.table_name = 'assocs_assocs'
31
+
32
+ belongs_to :assoc1, class_name: 'Assoc', foreign_key: 'assoc1_id' # parent assoc
33
+ belongs_to :assoc2, class_name: 'Assoc', foreign_key: 'assoc2_id' # child assoc is_member_of parent assoc
34
+
35
+ end # class AssocAssoc
36
+
37
+ end # module Model
38
+ end # module SportDb
@@ -1,14 +1,14 @@
1
- module SportDb
2
- module Model
3
-
4
- class Badge < ActiveRecord::Base
5
-
6
- belongs_to :team
7
- belongs_to :league
8
- belongs_to :season
9
-
10
- end # class Badge
11
-
12
-
13
- end # module Model
14
- end # module SportDb
1
+ module SportDb
2
+ module Model
3
+
4
+ class Badge < ActiveRecord::Base
5
+
6
+ belongs_to :team
7
+ belongs_to :league
8
+ belongs_to :season
9
+
10
+ end # class Badge
11
+
12
+
13
+ end # module Model
14
+ end # module SportDb
@@ -1,55 +1,55 @@
1
-
2
- ### forward references
3
- ## require first to resolve circular references
4
-
5
- module SportDb
6
- module Model
7
-
8
- Prop = ConfDb::Model::Prop
9
-
10
- ## todo: why? why not use include WorldDb::Models here???
11
- Continent = WorldDb::Model::Continent
12
- Country = WorldDb::Model::Country
13
- State = WorldDb::Model::State
14
- City = WorldDb::Model::City
15
-
16
- Person = PersonDb::Model::Person
17
-
18
- ## note: for now only team and league use worlddb tables
19
- # e.g. with belongs_to assoc (country,region)
20
-
21
- class Assoc < ActiveRecord::Base ; end
22
- class Team < ActiveRecord::Base ; end
23
- class League < ActiveRecord::Base ; end
24
- class Ground < ActiveRecord::Base ; end
25
- class Goal < ActiveRecord::Base ; end
26
-
27
- end
28
-
29
- ## add backwards compatible n convenience namespace
30
- Models = Model
31
- end # module SportDb
32
-
33
-
34
- module WorldDb
35
- module Model
36
-
37
- # add alias? why? why not? # is there a better way?
38
- # - just include SportDb::Models - why? why not?
39
- # - just include once in loader??
40
- Assoc = SportDb::Model::Assoc
41
- Team = SportDb::Model::Team
42
- League = SportDb::Model::League
43
- Ground = SportDb::Model::Ground
44
-
45
- end
46
- end
47
-
48
-
49
- module PersonDb
50
- module Model
51
- Goal = SportDb::Model::Goal
52
- end
53
- end
54
-
55
-
1
+
2
+ ### forward references
3
+ ## require first to resolve circular references
4
+
5
+ module SportDb
6
+ module Model
7
+
8
+ Prop = ConfDb::Model::Prop
9
+
10
+ ## todo: why? why not use include WorldDb::Models here???
11
+ Continent = WorldDb::Model::Continent
12
+ Country = WorldDb::Model::Country
13
+ State = WorldDb::Model::State
14
+ City = WorldDb::Model::City
15
+
16
+ Person = PersonDb::Model::Person
17
+
18
+ ## note: for now only team and league use worlddb tables
19
+ # e.g. with belongs_to assoc (country,region)
20
+
21
+ class Assoc < ActiveRecord::Base ; end
22
+ class Team < ActiveRecord::Base ; end
23
+ class League < ActiveRecord::Base ; end
24
+ class Ground < ActiveRecord::Base ; end
25
+ class Goal < ActiveRecord::Base ; end
26
+
27
+ end
28
+
29
+ ## add backwards compatible n convenience namespace
30
+ Models = Model
31
+ end # module SportDb
32
+
33
+
34
+ module WorldDb
35
+ module Model
36
+
37
+ # add alias? why? why not? # is there a better way?
38
+ # - just include SportDb::Models - why? why not?
39
+ # - just include once in loader??
40
+ Assoc = SportDb::Model::Assoc
41
+ Team = SportDb::Model::Team
42
+ League = SportDb::Model::League
43
+ Ground = SportDb::Model::Ground
44
+
45
+ end
46
+ end
47
+
48
+
49
+ module PersonDb
50
+ module Model
51
+ Goal = SportDb::Model::Goal
52
+ end
53
+ end
54
+
55
+
@@ -1,15 +1,15 @@
1
-
2
- module SportDb
3
- module Model
4
-
5
-
6
- class Goal < ActiveRecord::Base
7
-
8
- belongs_to :match
9
- belongs_to :person, class_name: 'PersonDb::Model::Person', foreign_key: 'person_id'
10
-
11
- end # class Goal
12
-
13
-
14
- end # module Model
15
- end # module SportDb
1
+
2
+ module SportDb
3
+ module Model
4
+
5
+
6
+ class Goal < ActiveRecord::Base
7
+
8
+ belongs_to :match
9
+ belongs_to :person, class_name: 'PersonDb::Model::Person', foreign_key: 'person_id'
10
+
11
+ end # class Goal
12
+
13
+
14
+ end # module Model
15
+ end # module SportDb
@@ -1,20 +1,20 @@
1
- module SportDb
2
- module Model
3
-
4
-
5
- class League < ActiveRecord::Base
6
-
7
- ## leagues also used for conferences, world series, cups, etc.
8
- #
9
- ## league (or cup/conference/series/etc.) + season (or year) = event
10
-
11
- has_many :events
12
- has_many :seasons, :through => :events
13
-
14
- belongs_to :country, :class_name => 'WorldDb::Model::Country', :foreign_key => 'country_id'
15
-
16
- end # class League
17
-
18
-
19
- end # module Model
20
- end # module SportDb
1
+ module SportDb
2
+ module Model
3
+
4
+
5
+ class League < ActiveRecord::Base
6
+
7
+ ## leagues also used for conferences, world series, cups, etc.
8
+ #
9
+ ## league (or cup/conference/series/etc.) + season (or year) = event
10
+
11
+ has_many :events
12
+ has_many :seasons, :through => :events
13
+
14
+ belongs_to :country, :class_name => 'WorldDb::Model::Country', :foreign_key => 'country_id'
15
+
16
+ end # class League
17
+
18
+
19
+ end # module Model
20
+ end # module SportDb
@@ -1,17 +1,17 @@
1
-
2
- module SportDb
3
- module Model
4
-
5
- ### use Squad for name? - alias??
6
-
7
- class Lineup < ActiveRecord::Base
8
-
9
- belongs_to :event
10
- belongs_to :team
11
- belongs_to :person, class_name: 'PersonDb::Model::Person', foreign_key: 'person_id'
12
-
13
- end # class Lineup
14
-
15
- end # module Model
16
- end # module SportDb
17
-
1
+
2
+ module SportDb
3
+ module Model
4
+
5
+ ### use Squad for name? - alias??
6
+
7
+ class Lineup < ActiveRecord::Base
8
+
9
+ belongs_to :event
10
+ belongs_to :team
11
+ belongs_to :person, class_name: 'PersonDb::Model::Person', foreign_key: 'person_id'
12
+
13
+ end # class Lineup
14
+
15
+ end # module Model
16
+ end # module SportDb
17
+
@@ -1,21 +1,21 @@
1
-
2
- #### note ---
3
- ## uses PersonDb namespace!!!!!
4
- #
5
- # move to models/person/person.rb - why? why not??
6
-
7
-
8
- module PersonDb
9
- module Model
10
-
11
- ### extends "basic" person model in PersonDb
12
- class Person
13
-
14
- has_many :goals
15
-
16
- end # class Person
17
-
18
-
19
- end # module Model
20
- end # module PersonDb
21
-
1
+
2
+ #### note ---
3
+ ## uses PersonDb namespace!!!!!
4
+ #
5
+ # move to models/person/person.rb - why? why not??
6
+
7
+
8
+ module PersonDb
9
+ module Model
10
+
11
+ ### extends "basic" person model in PersonDb
12
+ class Person
13
+
14
+ has_many :goals
15
+
16
+ end # class Person
17
+
18
+
19
+ end # module Model
20
+ end # module PersonDb
21
+
@@ -1,15 +1,15 @@
1
-
2
- module SportDb
3
- module Model
4
-
5
-
6
- class Season < ActiveRecord::Base
7
-
8
- has_many :events
9
- has_many :leagues, :through => :events
10
-
11
- end # class Season
12
-
13
-
14
- end # module Model
15
- end # module SportDb
1
+
2
+ module SportDb
3
+ module Model
4
+
5
+
6
+ class Season < ActiveRecord::Base
7
+
8
+ has_many :events
9
+ has_many :leagues, :through => :events
10
+
11
+ end # class Season
12
+
13
+
14
+ end # module Model
15
+ end # module SportDb