sportdb 1.9.16 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +2 -19
- data/Manifest.txt +1 -137
- data/README.md +2 -21
- data/Rakefile +14 -25
- data/lib/sportdb.rb +9 -260
- data/lib/sportdb/cli/main.rb +5 -14
- data/lib/sportdb/cli/opts.rb +2 -0
- data/lib/sportdb/cli/version.rb +26 -0
- metadata +10 -278
- data/.gemtest +0 -0
- data/config/fixtures/de.yml +0 -46
- data/config/fixtures/en.yml +0 -54
- data/config/fixtures/es.yml +0 -48
- data/config/fixtures/fr.yml +0 -53
- data/config/fixtures/it.yml +0 -55
- data/config/fixtures/pt.yml +0 -46
- data/config/fixtures/ro.yml +0 -55
- data/data/seasons.txt +0 -74
- data/data/setups/all.txt +0 -5
- data/lib/sportdb/calc.rb +0 -279
- data/lib/sportdb/deleter.rb +0 -52
- data/lib/sportdb/finders/date.rb +0 -374
- data/lib/sportdb/finders/goals.rb +0 -260
- data/lib/sportdb/finders/scores.rb +0 -122
- data/lib/sportdb/lang.rb +0 -216
- data/lib/sportdb/matcher.rb +0 -31
- data/lib/sportdb/models/assoc.rb +0 -106
- data/lib/sportdb/models/assoc_assoc.rb +0 -15
- data/lib/sportdb/models/badge.rb +0 -14
- data/lib/sportdb/models/event.rb +0 -65
- data/lib/sportdb/models/event_ground.rb +0 -15
- data/lib/sportdb/models/event_team.rb +0 -16
- data/lib/sportdb/models/forward.rb +0 -55
- data/lib/sportdb/models/game.rb +0 -244
- data/lib/sportdb/models/goal.rb +0 -15
- data/lib/sportdb/models/ground.rb +0 -100
- data/lib/sportdb/models/group.rb +0 -23
- data/lib/sportdb/models/group_team.rb +0 -14
- data/lib/sportdb/models/league.rb +0 -83
- data/lib/sportdb/models/person.rb +0 -21
- data/lib/sportdb/models/roster.rb +0 -18
- data/lib/sportdb/models/round.rb +0 -22
- data/lib/sportdb/models/season.rb +0 -14
- data/lib/sportdb/models/stats/alltime_standing.rb +0 -44
- data/lib/sportdb/models/stats/alltime_standing_entry.rb +0 -23
- data/lib/sportdb/models/stats/event_standing.rb +0 -55
- data/lib/sportdb/models/stats/event_standing_entry.rb +0 -21
- data/lib/sportdb/models/stats/group_standing.rb +0 -50
- data/lib/sportdb/models/stats/group_standing_entry.rb +0 -22
- data/lib/sportdb/models/team.rb +0 -119
- data/lib/sportdb/models/team_comp.rb +0 -64
- data/lib/sportdb/models/utils.rb +0 -78
- data/lib/sportdb/models/world/city.rb +0 -21
- data/lib/sportdb/models/world/continent.rb +0 -20
- data/lib/sportdb/models/world/country.rb +0 -19
- data/lib/sportdb/models/world/region.rb +0 -19
- data/lib/sportdb/patterns.rb +0 -38
- data/lib/sportdb/reader.rb +0 -130
- data/lib/sportdb/reader_file.rb +0 -123
- data/lib/sportdb/reader_zip.rb +0 -165
- data/lib/sportdb/readers/assoc.rb +0 -54
- data/lib/sportdb/readers/event.rb +0 -200
- data/lib/sportdb/readers/game.rb +0 -877
- data/lib/sportdb/readers/ground.rb +0 -53
- data/lib/sportdb/readers/league.rb +0 -54
- data/lib/sportdb/readers/season.rb +0 -83
- data/lib/sportdb/readers/squad_club.rb +0 -201
- data/lib/sportdb/readers/squad_national_team.rb +0 -173
- data/lib/sportdb/readers/team.rb +0 -53
- data/lib/sportdb/schema.rb +0 -373
- data/lib/sportdb/standings.rb +0 -178
- data/lib/sportdb/stats.rb +0 -27
- data/lib/sportdb/utils.rb +0 -89
- data/lib/sportdb/utils_date.rb +0 -26
- data/lib/sportdb/utils_goals.rb +0 -20
- data/lib/sportdb/utils_group.rb +0 -63
- data/lib/sportdb/utils_map.rb +0 -44
- data/lib/sportdb/utils_round.rb +0 -165
- data/lib/sportdb/utils_scores.rb +0 -17
- data/lib/sportdb/utils_teams.rb +0 -43
- data/lib/sportdb/version.rb +0 -22
- data/test/data/at-austria/2013_14/bl.txt +0 -227
- data/test/data/at-austria/2013_14/bl.yml +0 -30
- data/test/data/at-austria/2013_14/bl_ii.txt +0 -154
- data/test/data/at-austria/2013_14/el.txt +0 -4
- data/test/data/at-austria/2013_14/el.yml +0 -25
- data/test/data/at-austria/2013_14/squads/austria.txt +0 -40
- data/test/data/at-austria/2013_14/squads/salzburg.txt +0 -35
- data/test/data/at-austria/leagues.txt +0 -11
- data/test/data/at-austria/teams.txt +0 -75
- data/test/data/at-austria/teams_2.txt +0 -34
- data/test/data/national-teams/assocs.txt +0 -231
- data/test/data/national-teams/europe/assocs.txt +0 -13
- data/test/data/national-teams/europe/teams.txt +0 -13
- data/test/data/national-teams/north-america/assocs.txt +0 -10
- data/test/data/national-teams/north-america/teams.txt +0 -7
- data/test/data/national-teams/teams.txt +0 -19
- data/test/data/players/europe/at-austria/players.txt +0 -45
- data/test/data/players/europe/de-deutschland/players.txt +0 -41
- data/test/data/players/south-america/br-brazil/players.txt +0 -51
- data/test/data/world-cup/1930/cup.txt +0 -71
- data/test/data/world-cup/1930/cup.yml +0 -23
- data/test/data/world-cup/1930/cup_goals.txt +0 -47
- data/test/data/world-cup/1930/cup_goals.yml +0 -23
- data/test/data/world-cup/1954/cup.txt +0 -90
- data/test/data/world-cup/1954/cup.yml +0 -30
- data/test/data/world-cup/1962/cup.txt +0 -86
- data/test/data/world-cup/1962/cup.yml +0 -32
- data/test/data/world-cup/1974/cup.yml +0 -35
- data/test/data/world-cup/1974/cup_finals.txt +0 -14
- data/test/data/world-cup/1974/cup_i.txt +0 -55
- data/test/data/world-cup/1974/cup_ii.txt +0 -34
- data/test/data/world-cup/2014/cup.txt +0 -5
- data/test/data/world-cup/2014/cup.yml +0 -54
- data/test/data/world-cup/2014/squads/br-brazil.txt +0 -46
- data/test/data/world-cup/2014/squads/de-deutschland.txt +0 -8
- data/test/data/world-cup/2014/squads/jp-japan.txt +0 -30
- data/test/data/world-cup/2014/squads/uy-uruguay.txt +0 -32
- data/test/data/world-cup/leagues.txt +0 -5
- data/test/data/world-cup/seasons_1930.txt +0 -4
- data/test/data/world-cup/seasons_1954.txt +0 -4
- data/test/data/world-cup/seasons_1962.txt +0 -4
- data/test/data/world-cup/seasons_1974.txt +0 -5
- data/test/data/world-cup/teams_1930.txt +0 -26
- data/test/data/world-cup/teams_1954.txt +0 -30
- data/test/data/world-cup/teams_1962.txt +0 -29
- data/test/data/world-cup/teams_1974.txt +0 -29
- data/test/helper.rb +0 -120
- data/test/test_assoc_reader.rb +0 -201
- data/test/test_changes.rb +0 -74
- data/test/test_cursor.rb +0 -50
- data/test/test_date.rb +0 -100
- data/test/test_goals.rb +0 -109
- data/test/test_lang.rb +0 -130
- data/test/test_load.rb +0 -61
- data/test/test_reader.rb +0 -88
- data/test/test_reader_from_string.rb +0 -65
- data/test/test_round_auto.rb +0 -370
- data/test/test_round_def.rb +0 -109
- data/test/test_round_header.rb +0 -183
- data/test/test_scores.rb +0 -70
- data/test/test_squad_club_reader.rb +0 -76
- data/test/test_squad_national_team_reader.rb +0 -116
- data/test/test_standings.rb +0 -279
- data/test/test_standings_ii.rb +0 -46
- data/test/test_utils.rb +0 -124
- data/test/test_winner.rb +0 -95
data/lib/sportdb/stats.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
|
2
|
-
module SportDb
|
3
|
-
|
4
|
-
class Stats
|
5
|
-
include Models
|
6
|
-
|
7
|
-
def tables
|
8
|
-
puts " #{League.count} leagues / #{Season.count} seasons"
|
9
|
-
puts " #{Event.count} events (league+season recs) / #{Round.count} rounds / #{Group.count} groups"
|
10
|
-
puts " #{Team.count} teams"
|
11
|
-
puts " #{Game.count} games"
|
12
|
-
puts " #{Badge.count} badges"
|
13
|
-
|
14
|
-
puts " #{Roster.count} rosters (person+team+event recs)"
|
15
|
-
puts " #{Goal.count} goals (person+game recs)"
|
16
|
-
|
17
|
-
puts " #{Assoc.count} assocs|orgs"
|
18
|
-
puts " #{Ground.count} grounds|stadiums"
|
19
|
-
|
20
|
-
## note: moved to racing.db -- remove/delete!!
|
21
|
-
## puts " #{Track.count} tracks / #{Race.count} races (track+event recs) / #{Run.count} runs"
|
22
|
-
## puts " #{Record.count} records (race|run+person recs)"
|
23
|
-
end
|
24
|
-
|
25
|
-
end # class Stats
|
26
|
-
|
27
|
-
end # module SportDb
|
data/lib/sportdb/utils.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
### note: some utils moved to worldbdb/utils for reuse
|
4
|
-
|
5
|
-
|
6
|
-
####
|
7
|
-
## move to folder matcher(s)/finder(s)
|
8
|
-
# -- rename to FixtureFinder or FixtureFinders
|
9
|
-
# or just GeneralFinder
|
10
|
-
# TeamFinder etc. ???
|
11
|
-
|
12
|
-
|
13
|
-
module SportDb
|
14
|
-
module FixtureHelpers
|
15
|
-
|
16
|
-
|
17
|
-
def cut_off_end_of_line_comment!( line )
|
18
|
-
# cut off (that is, remove) optional end of line comment starting w/ #
|
19
|
-
|
20
|
-
line.sub!( /#.*$/ ) do |_|
|
21
|
-
logger.debug " cutting off end of line comment - >>#{$&}<<"
|
22
|
-
''
|
23
|
-
end
|
24
|
-
|
25
|
-
# NB: line = line.sub will NOT work - thus, lets use line.sub!
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
def find_nationality!( line )
|
30
|
-
# extract optional nationality - three-letter country code from line e.g. Lionel Messi (ARG)
|
31
|
-
# and return it
|
32
|
-
# NB: side effect - removes num from line string
|
33
|
-
|
34
|
-
regex = /\(([A-Z]{3})\)/ # e.g. (ARG)
|
35
|
-
if line =~ regex
|
36
|
-
logger.debug " nationality: >#{$1}<"
|
37
|
-
|
38
|
-
line.sub!( regex, '[NATIONALITY]' )
|
39
|
-
return $1.to_s
|
40
|
-
else
|
41
|
-
return nil
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
def find_leading_num!( line )
|
47
|
-
# extract optional leading num from line e.g. 9 Lionel Messi
|
48
|
-
# and return it
|
49
|
-
# NB: side effect - removes num from line string
|
50
|
-
|
51
|
-
# e.g. 9 Lionel Messi - must start line
|
52
|
-
## note: use lookahead (?=) for trailing spaces - do NOT cosume
|
53
|
-
regex = /^[ \t]*(\d{1,3})(?=[ \t]+)/
|
54
|
-
if line =~ regex
|
55
|
-
logger.debug " num: >#{$1}<"
|
56
|
-
|
57
|
-
line.sub!( regex, '[NUM]' )
|
58
|
-
return $1.to_i
|
59
|
-
else
|
60
|
-
return nil
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def find_leading_pos!( line )
|
65
|
-
# extract optional game pos from line
|
66
|
-
# and return it
|
67
|
-
# NB: side effect - removes pos from line string
|
68
|
-
|
69
|
-
# e.g. (1) - must start line
|
70
|
-
regex = /^[ \t]*\((\d{1,3})\)[ \t]+/
|
71
|
-
if line =~ regex
|
72
|
-
logger.debug " pos: >#{$1}<"
|
73
|
-
|
74
|
-
line.sub!( regex, '[POS] ' ) # NB: add trailing space
|
75
|
-
return $1.to_i
|
76
|
-
else
|
77
|
-
return nil
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def find_game_pos!( line )
|
82
|
-
## fix: add depreciation warning - remove - use find_leading_pos!
|
83
|
-
find_leading_pos!( line )
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end # module FixtureHelpers
|
89
|
-
end # module SportDb
|
data/lib/sportdb/utils_date.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module SportDb
|
4
|
-
module FixtureHelpers
|
5
|
-
|
6
|
-
def is_postponed?( line )
|
7
|
-
# check if line include postponed marker e.g. =>
|
8
|
-
line =~ /=>/
|
9
|
-
end
|
10
|
-
|
11
|
-
|
12
|
-
def find_date!( line, opts={} )
|
13
|
-
## NB: lets us pass in start_at/end_at date (for event)
|
14
|
-
# for auto-complete year
|
15
|
-
|
16
|
-
# extract date from line
|
17
|
-
# and return it
|
18
|
-
# NB: side effect - removes date from line string
|
19
|
-
|
20
|
-
finder = DateFinder.new
|
21
|
-
finder.find!( line, opts )
|
22
|
-
end
|
23
|
-
|
24
|
-
end # module FixtureHelpers
|
25
|
-
end # module SportDb
|
26
|
-
|
data/lib/sportdb/utils_goals.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module SportDb
|
4
|
-
module FixtureHelpers
|
5
|
-
|
6
|
-
def is_goals?( line )
|
7
|
-
# check if is goals line
|
8
|
-
# e.g. looks like
|
9
|
-
# Neymar 29', 71' (pen.) Oscar 90+1'; Marcelo 11' (o.g.)
|
10
|
-
# check for
|
11
|
-
# <space>90' or
|
12
|
-
# <space>90+1'
|
13
|
-
|
14
|
-
line =~ /[ ](\d{1,3}\+)?\d{1,3}'/
|
15
|
-
end
|
16
|
-
|
17
|
-
|
18
|
-
end # module FixtureHelpers
|
19
|
-
end # module SportDb
|
20
|
-
|
data/lib/sportdb/utils_group.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module SportDb
|
4
|
-
module FixtureHelpers
|
5
|
-
|
6
|
-
def is_group_def?( line )
|
7
|
-
# NB: check after is_round? (round may contain group reference!)
|
8
|
-
## must include bar (|) marker (make required)
|
9
|
-
line =~ /\|/ && is_group?( line )
|
10
|
-
end
|
11
|
-
|
12
|
-
def is_group?( line )
|
13
|
-
# NB: check after is_round? (round may contain group reference!)
|
14
|
-
## note: =~ return nil if not match found, and 0,1, etc for match
|
15
|
-
(line =~ SportDb.lang.regex_group) != nil
|
16
|
-
end
|
17
|
-
|
18
|
-
def find_group_title_and_pos!( line )
|
19
|
-
## group pos - for now support single digit e.g 1,2,3 or letter e.g. A,B,C or HEX
|
20
|
-
## nb: (?:) = is for non-capturing group(ing)
|
21
|
-
|
22
|
-
## fix:
|
23
|
-
## get Group|Gruppe|Grupo from lang!!!! do NOT hardcode in place
|
24
|
-
|
25
|
-
## todo:
|
26
|
-
## check if Group A: or [Group A] works e.g. : or ] get matched by \b ???
|
27
|
-
regex = /(?:Group|Gruppe|Grupo)\s+((?:\d{1}|[A-Z]{1,3}))\b/
|
28
|
-
|
29
|
-
match = regex.match( line )
|
30
|
-
|
31
|
-
return [nil,nil] if match.nil?
|
32
|
-
|
33
|
-
pos = case match[1]
|
34
|
-
when 'A' then 1
|
35
|
-
when 'B' then 2
|
36
|
-
when 'C' then 3
|
37
|
-
when 'D' then 4
|
38
|
-
when 'E' then 5
|
39
|
-
when 'F' then 6
|
40
|
-
when 'G' then 7
|
41
|
-
when 'H' then 8
|
42
|
-
when 'I' then 9
|
43
|
-
when 'J' then 10
|
44
|
-
when 'K' then 11
|
45
|
-
when 'L' then 12
|
46
|
-
when 'HEX' then 666 # HEX for Hexagonal - todo/check: map to something else ??
|
47
|
-
else match[1].to_i
|
48
|
-
end
|
49
|
-
|
50
|
-
title = match[0]
|
51
|
-
|
52
|
-
logger.debug " title: >#{title}<"
|
53
|
-
logger.debug " pos: >#{pos}<"
|
54
|
-
|
55
|
-
line.sub!( regex, '[GROUP.TITLE+POS]' )
|
56
|
-
|
57
|
-
return [title,pos]
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end # module FixtureHelpers
|
63
|
-
end # module SportDb
|
data/lib/sportdb/utils_map.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module SportDb
|
4
|
-
module FixtureHelpers
|
5
|
-
|
6
|
-
|
7
|
-
def find_ground!( line )
|
8
|
-
TextUtils.find_key_for!( 'ground', line )
|
9
|
-
end
|
10
|
-
|
11
|
-
## todo/fix: pass in known_grounds as a parameter? why? why not?
|
12
|
-
### todo/fix:
|
13
|
-
## remove =nil in para - make param required w/o fallback
|
14
|
-
|
15
|
-
def map_ground!( line, known_grounds=nil )
|
16
|
-
if known_grounds.nil?
|
17
|
-
puts "depreciated API call map_ground! (pass in mapping table as 2nd param)"
|
18
|
-
known_grounds = @known_grounds
|
19
|
-
end
|
20
|
-
|
21
|
-
TextUtils.map_titles_for!( 'ground', line, known_grounds )
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
def find_person!( line )
|
27
|
-
TextUtils.find_key_for!( 'person', line )
|
28
|
-
end
|
29
|
-
|
30
|
-
### todo/fix:
|
31
|
-
## remove =nil in para - make param required w/o fallback
|
32
|
-
def map_person!( line, known_persons=nil )
|
33
|
-
if known_persons.nil?
|
34
|
-
puts "depreciated API call map_person! (pass in mapping table as 2nd param)"
|
35
|
-
known_persons = @known_persons
|
36
|
-
end
|
37
|
-
|
38
|
-
TextUtils.map_titles_for!( 'person', line, known_persons )
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
end # module FixtureHelpers
|
43
|
-
end # module SportDb
|
44
|
-
|
data/lib/sportdb/utils_round.rb
DELETED
@@ -1,165 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module SportDb
|
4
|
-
module FixtureHelpers
|
5
|
-
|
6
|
-
def is_round_def?( line )
|
7
|
-
## must include bar (|) marker (make required)
|
8
|
-
line =~ /\|/ && is_round?( line )
|
9
|
-
end
|
10
|
-
|
11
|
-
def is_round?( line )
|
12
|
-
## note: =~ return nil if not match found, and 0,1, etc for match
|
13
|
-
(line =~ SportDb.lang.regex_round) != nil
|
14
|
-
end
|
15
|
-
|
16
|
-
def is_knockout_round?( line )
|
17
|
-
|
18
|
-
## todo: check for adding ignore case for regex (e.g. 1st leg/1st Leg)
|
19
|
-
|
20
|
-
if line =~ SportDb.lang.regex_leg1
|
21
|
-
logger.debug " two leg knockout; skip knockout flag on first leg"
|
22
|
-
false
|
23
|
-
elsif line =~ SportDb.lang.regex_knockout_round
|
24
|
-
logger.debug " setting knockout flag to true"
|
25
|
-
true
|
26
|
-
elsif line =~ /K\.O\.|K\.o\.|Knockout/
|
27
|
-
## NB: add two language independent markers, that is, K.O. and Knockout
|
28
|
-
logger.debug " setting knockout flag to true (lang independent marker)"
|
29
|
-
true
|
30
|
-
else
|
31
|
-
false
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
##
|
37
|
-
## fix/todo: check that [ROUND.TITLE2] and friends do NOT use pipes (|)
|
38
|
-
## change all pipes (|) to dot (.)
|
39
|
-
## - pipes get used for def markers!!!
|
40
|
-
|
41
|
-
def find_round_header_title2!( line )
|
42
|
-
## todo/fix:
|
43
|
-
## cleanup method
|
44
|
-
## use buf.index( '//' ) to split string (see found_round_def)
|
45
|
-
## why? simpler why not?
|
46
|
-
## - do we currently allow groups if title2 present? add example if it works?
|
47
|
-
|
48
|
-
|
49
|
-
# assume everything after // is title2 - strip off leading n trailing whitespaces
|
50
|
-
regex = /\/{2,}\s*(.+)\s*$/
|
51
|
-
if line =~ regex
|
52
|
-
logger.debug " title2: >#{$1}<"
|
53
|
-
|
54
|
-
line.sub!( regex, '[ROUND.TITLE2]' )
|
55
|
-
return $1
|
56
|
-
else
|
57
|
-
return nil # no round title2 found (title2 is optional)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
def find_round_header_title!( line )
|
63
|
-
# assume everything left is the round title
|
64
|
-
# extract all other items first (round title2, round pos, group title n pos, etc.)
|
65
|
-
|
66
|
-
## todo/fix:
|
67
|
-
## cleanup method
|
68
|
-
## use buf.index( '//' ) to split string (see found_round_def)
|
69
|
-
## why? simpler why not?
|
70
|
-
## - do we currently allow groups if title2 present? add example if it works?
|
71
|
-
|
72
|
-
buf = line.dup
|
73
|
-
logger.debug " find_round_header_title! line-before: >>#{buf}<<"
|
74
|
-
|
75
|
-
buf.gsub!( /\[[^\]]+\]/, '' ) # e.g. remove [ROUND.POS], [ROUND.TITLE2], [GROUP.TITLE+POS] etc.
|
76
|
-
buf.sub!( /\s+[\/\-]{1,}\s+$/, '' ) # remove optional trailing / or / chars (left over from group)
|
77
|
-
buf.strip! # remove leading and trailing whitespace
|
78
|
-
|
79
|
-
logger.debug " find_round_title! line-after: >>#{buf}<<"
|
80
|
-
|
81
|
-
### bingo - assume what's left is the round title
|
82
|
-
|
83
|
-
logger.debug " title: >>#{buf}<<"
|
84
|
-
line.sub!( buf, '[ROUND.TITLE]' )
|
85
|
-
|
86
|
-
buf
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
def find_round_def_title!( line )
|
91
|
-
# assume everything before pipe (\) is the round title
|
92
|
-
# strip [ROUND.POS], todo:?? [ROUND.TITLE2]
|
93
|
-
|
94
|
-
# todo/fix: add title2 w/ // or / why? why not?
|
95
|
-
# -- strip / or / chars
|
96
|
-
|
97
|
-
buf = line.dup
|
98
|
-
logger.debug " find_round_def_title! line-before: >>#{buf}<<"
|
99
|
-
|
100
|
-
## cut-off everything after (including) pipe (|)
|
101
|
-
buf = buf[ 0...buf.index('|') ]
|
102
|
-
|
103
|
-
# e.g. remove [ROUND.POS], [ROUND.TITLE2], [GROUP.TITLE+POS] etc.
|
104
|
-
buf.gsub!( /\[[^\]]+\]/, '' ) ## fix: use helper for (re)use e.g. remove_match_placeholder/marker or similar?
|
105
|
-
# remove leading and trailing whitespace
|
106
|
-
buf.strip!
|
107
|
-
|
108
|
-
logger.debug " find_round_def_title! line-after: >>#{buf}<<"
|
109
|
-
|
110
|
-
logger.debug " title: >>#{buf}<<"
|
111
|
-
line.sub!( buf, '[ROUND.TITLE]' )
|
112
|
-
|
113
|
-
buf
|
114
|
-
end
|
115
|
-
|
116
|
-
|
117
|
-
def find_round_pos!( line )
|
118
|
-
# pass #1) extract optional round pos from line
|
119
|
-
# e.g. (1) - must start line
|
120
|
-
regex_pos = /^[ \t]*\((\d{1,3})\)[ \t]+/
|
121
|
-
|
122
|
-
# pass #2) find free standing number e.g. Matchday 3 or Round 5 or 3. Spieltag etc.
|
123
|
-
# note: /\b(\d{1,3})\b/
|
124
|
-
# will match -12
|
125
|
-
# thus, use space required - will NOT match -2 e.g. Group-2 Play-off
|
126
|
-
# note: allow 1. Runde n
|
127
|
-
# 1^ Giornata
|
128
|
-
regex_num = /(?:^|\s)(\d{1,3})(?:[.\^\s]|$)/
|
129
|
-
|
130
|
-
if line =~ regex_pos
|
131
|
-
logger.debug " pos: >#{$1}<"
|
132
|
-
|
133
|
-
line.sub!( regex_pos, '[ROUND.POS] ' ) ## NB: add back trailing space that got swallowed w/ regex -> [ \t]+
|
134
|
-
return $1.to_i
|
135
|
-
elsif line =~ regex_num
|
136
|
-
## assume number in title is pos (e.g. Jornada 3, 3 Runde etc.)
|
137
|
-
## NB: do NOT remove pos from string (will get removed by round title)
|
138
|
-
|
139
|
-
num = $1.to_i # note: clone capture; keep a copy (another regex follows; will redefine $1)
|
140
|
-
|
141
|
-
#### fix:
|
142
|
-
# use/make keywords required
|
143
|
-
# e.g. Round of 16 -> should NOT match 16!
|
144
|
-
# Spiel um Platz 3 (or 5) etc -> should NOT match 3!
|
145
|
-
# Round 16 - ok
|
146
|
-
# thus, check for required keywords
|
147
|
-
|
148
|
-
## quick hack for round of 16
|
149
|
-
# todo: mask match e.g. Round of xxx ... and try again - might include something
|
150
|
-
# reuse pattern for Group XX Replays for example
|
151
|
-
if line =~ /^\s*Round of \d{1,3}\b/
|
152
|
-
return nil
|
153
|
-
end
|
154
|
-
|
155
|
-
logger.debug " pos: >#{num}<"
|
156
|
-
return num
|
157
|
-
else
|
158
|
-
## fix: add logger.warn no round pos found in line
|
159
|
-
return nil
|
160
|
-
end
|
161
|
-
end # method find_round_pos!
|
162
|
-
|
163
|
-
|
164
|
-
end # module FixtureHelpers
|
165
|
-
end # module SportDb
|
data/lib/sportdb/utils_scores.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module SportDb
|
4
|
-
module FixtureHelpers
|
5
|
-
|
6
|
-
|
7
|
-
def find_scores!( line, opts={} )
|
8
|
-
# note: always call after find_dates !!!
|
9
|
-
# scores match date-like patterns!! e.g. 10-11 or 10:00 etc.
|
10
|
-
# -- note: score might have two digits too
|
11
|
-
|
12
|
-
finder = ScoresFinder.new
|
13
|
-
finder.find!( line, opts )
|
14
|
-
end
|
15
|
-
|
16
|
-
end # module FixtureHelpers
|
17
|
-
end # module SportDb
|