sportdb 1.8.12 → 1.8.13
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +1 -0
- data/lib/sportdb.rb +3 -1
- data/lib/sportdb/models/team.rb +3 -6
- data/lib/sportdb/patterns.rb +37 -0
- data/lib/sportdb/version.rb +1 -1
- metadata +28 -25
data/Manifest.txt
CHANGED
@@ -46,6 +46,7 @@ lib/sportdb/models/world/city.rb
|
|
46
46
|
lib/sportdb/models/world/continent.rb
|
47
47
|
lib/sportdb/models/world/country.rb
|
48
48
|
lib/sportdb/models/world/region.rb
|
49
|
+
lib/sportdb/patterns.rb
|
49
50
|
lib/sportdb/reader.rb
|
50
51
|
lib/sportdb/readers/event.rb
|
51
52
|
lib/sportdb/readers/game.rb
|
data/lib/sportdb.rb
CHANGED
@@ -29,6 +29,7 @@ require 'fetcher' # for fetching/downloading fixtures via HTTP/HTTPS etc.
|
|
29
29
|
|
30
30
|
require 'sportdb/version'
|
31
31
|
|
32
|
+
require 'sportdb/patterns'
|
32
33
|
require 'sportdb/models/forward'
|
33
34
|
require 'sportdb/models/world/city'
|
34
35
|
require 'sportdb/models/world/country'
|
@@ -56,7 +57,8 @@ require 'sportdb/models/track'
|
|
56
57
|
|
57
58
|
require 'sportdb/models/utils' # e.g. GameCursor
|
58
59
|
|
59
|
-
## add backwards compatible
|
60
|
+
## add backwards compatible n convenience namespace
|
61
|
+
### move to forward.rb ?? - why? why not??
|
60
62
|
module SportDb
|
61
63
|
Models = Model
|
62
64
|
end
|
data/lib/sportdb/models/team.rb
CHANGED
@@ -16,12 +16,9 @@ class Team < ActiveRecord::Base
|
|
16
16
|
has_many :home_games, class_name: 'Game', foreign_key: 'team1_id'
|
17
17
|
has_many :away_games, class_name: 'Game', foreign_key: 'team2_id'
|
18
18
|
|
19
|
-
REGEX_KEY = /^[a-z]{3,}$/
|
20
|
-
REGEX_CODE = /^[A-Z][A-Z0-9][A-Z0-9_]?$/ # must start w/ letter a-z (2 n 3 can be number or underscore _)
|
21
|
-
|
22
19
|
## todo/fix: must be 3 or more letters (plus allow digits e.g. salzburgii, muenchen1980, etc.) - why? why not??
|
23
|
-
validates :key, :
|
24
|
-
validates :code, :
|
20
|
+
validates :key, format: { with: /#{TEAM_KEY_PATTERN}/, message: TEAM_KEY_PATTERN_MESSAGE }
|
21
|
+
validates :code, format: { with: /#{TEAM_CODE_PATTERN}/, message: TEAM_CODE_PATTERN_MESSAGE }, allow_nil: true
|
25
22
|
|
26
23
|
has_many :event_teams, class_name: 'EventTeam' # join table (events+teams)
|
27
24
|
has_many :events, :through => :event_teams
|
@@ -132,7 +129,7 @@ class Team < ActiveRecord::Base
|
|
132
129
|
attr[ :country_id ] = value.id
|
133
130
|
elsif value.is_a? City
|
134
131
|
attr[ :city_id ] = value.id
|
135
|
-
elsif value =~
|
132
|
+
elsif value =~ /#{TEAM_CODE_PATTERN}/ ## assume its three letter code (e.g. ITA or S04 etc.)
|
136
133
|
attr[ :code ] = value
|
137
134
|
elsif value =~ /^city:/ ## city:
|
138
135
|
value_city_key = value[5..-1] ## cut off city: prefix
|
@@ -0,0 +1,37 @@
|
|
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
|
+
############
|
11
|
+
# about ruby regexps
|
12
|
+
#
|
13
|
+
# try the rubular - Ruby regular expression editor and tester
|
14
|
+
# -> http://rubular.com
|
15
|
+
# code -> ?? by ??
|
16
|
+
#
|
17
|
+
#
|
18
|
+
# Jeff Avallone's Regexper - Shows State-Automata Diagrams
|
19
|
+
# try -> http://regexper.com
|
20
|
+
# code -> https://github.com/javallone/regexper
|
21
|
+
#
|
22
|
+
#
|
23
|
+
# Regular Expressions | The Bastards Book of Ruby by Dan Nguyen
|
24
|
+
# http://ruby.bastardsbook.com/chapters/regexes/
|
25
|
+
#
|
26
|
+
# move to notes regex|patterns on geraldb.github.io ??
|
27
|
+
#
|
28
|
+
|
29
|
+
TEAM_KEY_PATTERN = '\A[a-z]{3,}\z'
|
30
|
+
TEAM_KEY_PATTERN_MESSAGE = "expected three or more lowercase letters a-z /#{TEAM_KEY_PATTERN}/"
|
31
|
+
|
32
|
+
# must start w/ letter a-z (2 n 3 can be number or underscore _)
|
33
|
+
TEAM_CODE_PATTERN = '\A[A-Z][A-Z0-9][A-Z0-9_]?\z'
|
34
|
+
TEAM_CODE_PATTERN_MESSAGE = "expected two or three uppercase letters A-Z (and 0-9_; must start with A-Z) /#{TEAM_CODE_PATTERN}/"
|
35
|
+
|
36
|
+
end # module SportDb
|
37
|
+
|
data/lib/sportdb/version.rb
CHANGED
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.
|
4
|
+
version: 1.8.13
|
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-04-
|
12
|
+
date: 2014-04-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: props
|
16
|
-
requirement: &
|
16
|
+
requirement: &77469600 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *77469600
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: logutils
|
27
|
-
requirement: &
|
27
|
+
requirement: &77468760 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *77468760
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: textutils
|
38
|
-
requirement: &
|
38
|
+
requirement: &77468390 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *77468390
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: worlddb
|
49
|
-
requirement: &
|
49
|
+
requirement: &77468000 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 2.0.2
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *77468000
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: tagutils
|
60
|
-
requirement: &
|
60
|
+
requirement: &77467680 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *77467680
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: fetcher
|
71
|
-
requirement: &
|
71
|
+
requirement: &77467090 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0.3'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *77467090
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: gli
|
82
|
-
requirement: &
|
82
|
+
requirement: &77466740 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 2.5.6
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *77466740
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: activerecord
|
93
|
-
requirement: &
|
93
|
+
requirement: &77466550 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,36 +98,38 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *77466550
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rdoc
|
104
|
-
requirement: &
|
104
|
+
requirement: &77466140 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
109
|
+
version: '4.0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *77466140
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: hoe
|
115
|
-
requirement: &
|
115
|
+
requirement: &77465690 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ~>
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version: '3.
|
120
|
+
version: '3.11'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *77465690
|
124
124
|
description: sportdb - sport.db command line tool
|
125
125
|
email: opensport@googlegroups.com
|
126
126
|
executables:
|
127
127
|
- sportdb
|
128
128
|
extensions: []
|
129
129
|
extra_rdoc_files:
|
130
|
+
- HISTORY.md
|
130
131
|
- Manifest.txt
|
132
|
+
- README.md
|
131
133
|
files:
|
132
134
|
- HISTORY.md
|
133
135
|
- Manifest.txt
|
@@ -177,6 +179,7 @@ files:
|
|
177
179
|
- lib/sportdb/models/world/continent.rb
|
178
180
|
- lib/sportdb/models/world/country.rb
|
179
181
|
- lib/sportdb/models/world/region.rb
|
182
|
+
- lib/sportdb/patterns.rb
|
180
183
|
- lib/sportdb/reader.rb
|
181
184
|
- lib/sportdb/readers/event.rb
|
182
185
|
- lib/sportdb/readers/game.rb
|
@@ -285,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
285
288
|
- !ruby/object:Gem::Version
|
286
289
|
version: '0'
|
287
290
|
requirements: []
|
288
|
-
rubyforge_project:
|
291
|
+
rubyforge_project:
|
289
292
|
rubygems_version: 1.8.17
|
290
293
|
signing_key:
|
291
294
|
specification_version: 3
|