sportdb 1.6.13 → 1.6.14
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/sportdb +0 -0
- data/lib/sportdb/lang.rb +1 -5
- data/lib/sportdb/reader.rb +50 -36
- data/lib/sportdb/version.rb +1 -1
- metadata +15 -13
data/bin/sportdb
CHANGED
File without changes
|
data/lib/sportdb/lang.rb
CHANGED
@@ -206,12 +206,8 @@ class LangChecker
|
|
206
206
|
def initialize
|
207
207
|
end
|
208
208
|
|
209
|
-
def analyze(
|
209
|
+
def analyze( path )
|
210
210
|
# return lang code e.g. en, de, es
|
211
|
-
|
212
|
-
path = "#{include_path}/#{name}.txt"
|
213
|
-
|
214
|
-
logger.info "parsing data '#{name}' (#{path})..."
|
215
211
|
|
216
212
|
text = File.read_utf8( path )
|
217
213
|
|
data/lib/sportdb/reader.rb
CHANGED
@@ -2,13 +2,30 @@
|
|
2
2
|
|
3
3
|
module SportDb
|
4
4
|
|
5
|
+
module Matcher
|
6
|
+
|
7
|
+
def match_leagues_for_country( name, &blk )
|
8
|
+
match_xxx_for_country( name, 'leagues', blk )
|
9
|
+
end
|
10
|
+
|
11
|
+
def match_teams_for_country( name, &blk )
|
12
|
+
match_xxx_for_country( name, 'teams', blk )
|
13
|
+
end
|
14
|
+
|
15
|
+
end # module Matcher
|
16
|
+
|
17
|
+
|
5
18
|
class Reader
|
6
19
|
|
7
20
|
include LogUtils::Logging
|
8
21
|
|
22
|
+
|
9
23
|
## make models available in sportdb module by default with namespace
|
10
24
|
# e.g. lets you use Team instead of Models::Team
|
11
|
-
include
|
25
|
+
include SportDb::Models
|
26
|
+
|
27
|
+
include WorldDb::Matcher
|
28
|
+
include SportDb::Matcher # lets us use match_teams_for_country etc.
|
12
29
|
|
13
30
|
|
14
31
|
attr_reader :include_path
|
@@ -98,7 +115,7 @@ class Reader
|
|
98
115
|
# NB: assume @event is set from previous load
|
99
116
|
race = Race.find_by_event_id_and_pos( @event.id, race_pos )
|
100
117
|
load_records( name, race_id: race.id ) # e.g. 2013/04-gp-monaco.txt in formula1.db
|
101
|
-
elsif name =~
|
118
|
+
elsif name =~ /(?:^|\/)seasons/ # NB: ^seasons or also possible at-austria!/seasons
|
102
119
|
load_seasons( name )
|
103
120
|
elsif name =~ /^leagues/
|
104
121
|
if name =~ /club/
|
@@ -108,18 +125,18 @@ class Reader
|
|
108
125
|
# e.g. leagues
|
109
126
|
load_leagues( name )
|
110
127
|
end
|
111
|
-
elsif name =~ /^([a-z]{2})\/leagues/
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
elsif name =~ /^([a-z]{2})\/teams/
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
128
|
+
elsif match_leagues_for_country( name ) do |country_key| # name =~ /^([a-z]{2})\/leagues/
|
129
|
+
# auto-add country code (from folder structure) for country-specific leagues
|
130
|
+
# e.g. at/leagues
|
131
|
+
country = Country.find_by_key!( country_key )
|
132
|
+
load_leagues( name, club: true, country_id: country.id )
|
133
|
+
end
|
134
|
+
elsif match_teams_for_country( name ) do |country_key| # name =~ /^([a-z]{2})\/teams/
|
135
|
+
# auto-add country code (from folder structure) for country-specific teams
|
136
|
+
# e.g. at/teams at/teams.2 de/teams etc.
|
137
|
+
country = Country.find_by_key!( country_key )
|
138
|
+
load_teams( name, club: true, country_id: country.id )
|
139
|
+
end
|
123
140
|
elsif name =~ /\/teams/
|
124
141
|
if name =~ /club/
|
125
142
|
# club teams (many countries)
|
@@ -190,11 +207,7 @@ class Reader
|
|
190
207
|
|
191
208
|
def load_seasons( name )
|
192
209
|
|
193
|
-
|
194
|
-
|
195
|
-
logger.info "parsing data '#{name}' (#{path})..."
|
196
|
-
|
197
|
-
reader = HashReader.new( path )
|
210
|
+
reader = HashReaderV2.new( name, include_path )
|
198
211
|
|
199
212
|
####
|
200
213
|
## fix!!!!!
|
@@ -239,22 +252,17 @@ class Reader
|
|
239
252
|
|
240
253
|
end # each key,value
|
241
254
|
|
242
|
-
Prop.create_from_fixture!( name, path )
|
243
|
-
|
244
255
|
end # load_seasons
|
245
256
|
|
246
257
|
|
247
258
|
def fetch_event( name )
|
248
259
|
# get/fetch/find event from yml file
|
249
260
|
|
250
|
-
path = "#{include_path}/#{name}.yml"
|
251
|
-
|
252
|
-
logger.info "parsing data '#{name}' (#{path})..."
|
253
|
-
|
254
|
-
|
255
261
|
## todo/fix: use h = HashFile.load( path ) or similar instead of HashReader!!
|
256
262
|
|
257
|
-
|
263
|
+
## todo/fix: add option for not adding prop automatically?? w/ HashReaderV2
|
264
|
+
|
265
|
+
reader = HashReaderV2.new( name, include_path )
|
258
266
|
|
259
267
|
event_attribs = {}
|
260
268
|
|
@@ -289,11 +297,7 @@ class Reader
|
|
289
297
|
## use Event.create_or_update_from_hash_reader?? or similar
|
290
298
|
# move parsing code to model
|
291
299
|
|
292
|
-
|
293
|
-
|
294
|
-
logger.info "parsing data '#{name}' (#{path})..."
|
295
|
-
|
296
|
-
reader = HashReader.new( path )
|
300
|
+
reader = HashReaderV2.new( name, include_path )
|
297
301
|
|
298
302
|
event_attribs = {}
|
299
303
|
|
@@ -375,8 +379,6 @@ class Reader
|
|
375
379
|
|
376
380
|
event.update_attributes!( event_attribs )
|
377
381
|
|
378
|
-
Prop.create_from_fixture!( name, path )
|
379
|
-
|
380
382
|
end # load_event
|
381
383
|
|
382
384
|
|
@@ -392,12 +394,24 @@ class Reader
|
|
392
394
|
end
|
393
395
|
|
394
396
|
def load_fixtures( event_key, name ) # load from file system
|
397
|
+
|
398
|
+
## todo: move name_real_path code to LineReaderV2 ????
|
399
|
+
pos = name.index( '!/')
|
400
|
+
if pos.nil?
|
401
|
+
name_real_path = name # not found; real path is the same as name
|
402
|
+
else
|
403
|
+
# cut off everything until !/ e.g.
|
404
|
+
# at-austria!/w-wien/beers becomes
|
405
|
+
# w-wien/beers
|
406
|
+
name_real_path = name[ (pos+2)..-1 ]
|
407
|
+
end
|
408
|
+
|
395
409
|
|
396
|
-
path = "#{include_path}/#{
|
410
|
+
path = "#{include_path}/#{name_real_path}.txt"
|
397
411
|
|
398
412
|
logger.info "parsing data '#{name}' (#{path})..."
|
399
413
|
|
400
|
-
SportDB.lang.lang = LangChecker.new.analyze(
|
414
|
+
SportDB.lang.lang = LangChecker.new.analyze( path )
|
401
415
|
|
402
416
|
reader = LineReader.new( path )
|
403
417
|
|
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.6.
|
4
|
+
version: 1.6.14
|
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-06-
|
12
|
+
date: 2013-06-24 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: worlddb
|
16
|
-
requirement: &
|
16
|
+
requirement: &18220920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '1.7'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *18220920
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: commander
|
27
|
-
requirement: &
|
27
|
+
requirement: &18220452 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,36 +32,38 @@ dependencies:
|
|
32
32
|
version: 4.1.3
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *18220452
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rdoc
|
38
|
-
requirement: &
|
38
|
+
requirement: &18219588 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
43
|
+
version: '4.0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *18219588
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: hoe
|
49
|
-
requirement: &
|
49
|
+
requirement: &18219000 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.6'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *18219000
|
58
58
|
description: sportdb - sport.db command line tool
|
59
59
|
email: opensport@googlegroups.com
|
60
60
|
executables:
|
61
61
|
- sportdb
|
62
62
|
extensions: []
|
63
63
|
extra_rdoc_files:
|
64
|
+
- History.md
|
64
65
|
- Manifest.txt
|
66
|
+
- README.md
|
65
67
|
files:
|
66
68
|
- History.md
|
67
69
|
- Manifest.txt
|
@@ -149,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
151
|
version: '0'
|
150
152
|
requirements: []
|
151
153
|
rubyforge_project: sportdb
|
152
|
-
rubygems_version: 1.
|
154
|
+
rubygems_version: 1.7.2
|
153
155
|
signing_key:
|
154
156
|
specification_version: 3
|
155
157
|
summary: sportdb - sport.db command line tool
|