sportdb 1.8.21 → 1.8.22

Sign up to get free protection for your applications and to get access to all the features.
@@ -653,23 +653,36 @@ class GameReader
653
653
  end
654
654
 
655
655
  unless @patch_round_ids_pos.empty?
656
+
657
+ # step 0: check for offset (last_round_pos)
658
+ if @last_round_pos
659
+ offset = @last_round_pos
660
+ logger.info " +++ patch round pos - use offset; start w/ #{offset}"
661
+ else
662
+ offset = 0
663
+ logger.debug " patch round pos - no offset; start w/ 0"
664
+ end
665
+
656
666
  # step 1: sort by date
657
667
  # step 2: update pos
658
668
  # note: use uniq - to allow multiple round headers (possible?)
659
669
  Round.order( 'start_at asc').find( @patch_round_ids_pos.uniq ).each_with_index do |r,idx|
660
670
  # note: starts counting w/ zero(0)
661
- logger.debug "[#{idx+1}] patch round pos for #{r.title}:"
671
+ logger.debug "[#{idx+1}] patch round pos >#{offset+idx+1}< for #{r.title}:"
662
672
  round_attribs = {
663
- pos: idx+1
673
+ pos: offset+idx+1
664
674
  }
665
675
 
666
676
  # update title if Matchday XXXX e.g. use Matchday 1 etc.
667
677
  if r.title.starts_with?('Matchday')
668
- round_attribs[:title] = "Matchday #{idx+1}"
678
+ round_attribs[:title] = "Matchday #{offset+idx+1}"
669
679
  end
670
680
 
671
681
  logger.debug round_attribs.to_json
672
682
  r.update_attributes!( round_attribs )
683
+
684
+ # update last_round_pos offset too
685
+ @last_round_pos = [offset+idx+1,@last_round_pos||0].max
673
686
  end
674
687
  end
675
688
 
@@ -115,21 +115,11 @@ module SportDb
115
115
 
116
116
 
117
117
  def find_round_pos!( line )
118
- ## fix/todo:
119
- ## if no round found assume last_pos+1 ??? why? why not?
120
-
121
- # extract optional round pos from line
118
+ # pass #1) extract optional round pos from line
122
119
  # e.g. (1) - must start line
123
120
  regex_pos = /^[ \t]*\((\d{1,3})\)[ \t]+/
124
121
 
125
-
126
- #### fix:
127
- ## use/make keywords required
128
- # e.g. Round of 16 -> should NOT match 16!
129
- # Round 16 - ok
130
- # thus, check for required keywords
131
-
132
- ## find free standing number
122
+ # pass #2) find free standing number e.g. Matchday 3 or Round 5 or 3. Spieltag etc.
133
123
  # note: /\b(\d{1,3})\b/
134
124
  # will match -12
135
125
  # thus, use space required - will NOT match -2 e.g. Group-2 Play-off
@@ -145,8 +135,25 @@ module SportDb
145
135
  elsif line =~ regex_num
146
136
  ## assume number in title is pos (e.g. Jornada 3, 3 Runde etc.)
147
137
  ## NB: do NOT remove pos from string (will get removed by round title)
148
- logger.debug " pos: >#{$1}<"
149
- return $1.to_i
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
150
157
  else
151
158
  ## fix: add logger.warn no round pos found in line
152
159
  return nil
@@ -1,6 +1,6 @@
1
1
 
2
2
  module SportDb
3
- VERSION = '1.8.21'
3
+ VERSION = '1.8.22'
4
4
  end
5
5
 
6
6
 
data/test/test_lang.rb CHANGED
@@ -23,18 +23,18 @@ class TestLang < MiniTest::Unit::TestCase
23
23
  round << '|Quarterfinals|Quarter-finals|Quarters|Quarterfinal|Last 8'
24
24
  round << '|Semifinals|Semi-finals|Semis|Last 4'
25
25
  round << '|Fifth place match|Fifth place|5th place match|5th place final|5th place|Match for fifth place|Match for 5th place'
26
- round << '|Third place match|Third place|3rd place match|3rd place final|3rd place|Match for third place|Match for 3rd place|Third-place play-off|Third place play-off'
26
+ round << '|Third place match|Third-place match|Third place|3rd place match|3rd place final|3rd place|Match for third place|Match for 3rd place|Third-place play-off|Third place play-off'
27
27
  round << '|Final|Finals'
28
- round << '|Play-off|Play-offs|Play-off for quarter-finals'
28
+ round << '|Playoff|Playoffs|Play-off|Play-offs|Play-off for quarter-finals'
29
29
 
30
30
  knockout_round = 'Round of 32|Last 32'
31
31
  knockout_round << '|Round of 16|Last 16|8th finals'
32
32
  knockout_round << '|Quarterfinals|Quarter-finals|Quarters|Quarterfinal|Last 8'
33
33
  knockout_round << '|Semifinals|Semi-finals|Semis|Last 4'
34
34
  knockout_round << '|Fifth place match|Fifth place|5th place match|5th place final|5th place|Match for fifth place|Match for 5th place'
35
- knockout_round << '|Third place match|Third place|3rd place match|3rd place final|3rd place|Match for third place|Match for 3rd place|Third-place play-off|Third place play-off'
35
+ knockout_round << '|Third place match|Third-place match|Third place|3rd place match|3rd place final|3rd place|Match for third place|Match for 3rd place|Third-place play-off|Third place play-off'
36
36
  knockout_round << '|Final|Finals'
37
- knockout_round << '|Play-off|Play-offs|Play-off for quarter-finals'
37
+ knockout_round << '|Playoff|Playoffs|Play-off|Play-offs|Play-off for quarter-finals'
38
38
 
39
39
  assert_equal group, lang.group
40
40
  assert_equal round, lang.round
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.21
4
+ version: 1.8.22
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2014-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: props
16
- requirement: &74073370 !ruby/object:Gem::Requirement
16
+ requirement: &68241960 !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: *74073370
24
+ version_requirements: *68241960
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: logutils
27
- requirement: &74073050 !ruby/object:Gem::Requirement
27
+ requirement: &68241240 !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: *74073050
35
+ version_requirements: *68241240
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: textutils
38
- requirement: &74072750 !ruby/object:Gem::Requirement
38
+ requirement: &68255670 !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: *74072750
46
+ version_requirements: *68255670
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: worlddb
49
- requirement: &74072350 !ruby/object:Gem::Requirement
49
+ requirement: &68255160 !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: *74072350
57
+ version_requirements: *68255160
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: tagutils
60
- requirement: &74071960 !ruby/object:Gem::Requirement
60
+ requirement: &68254520 !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: *74071960
68
+ version_requirements: *68254520
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: fetcher
71
- requirement: &74071660 !ruby/object:Gem::Requirement
71
+ requirement: &68254010 !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: *74071660
79
+ version_requirements: *68254010
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: gli
82
- requirement: &74071320 !ruby/object:Gem::Requirement
82
+ requirement: &68253470 !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: *74071320
90
+ version_requirements: *68253470
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: activerecord
93
- requirement: &74071090 !ruby/object:Gem::Requirement
93
+ requirement: &68253190 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *74071090
101
+ version_requirements: *68253190
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rdoc
104
- requirement: &74070660 !ruby/object:Gem::Requirement
104
+ requirement: &68252660 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '4.0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *74070660
112
+ version_requirements: *68252660
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: hoe
115
- requirement: &74070340 !ruby/object:Gem::Requirement
115
+ requirement: &68252210 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: '3.11'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *74070340
123
+ version_requirements: *68252210
124
124
  description: sportdb - sport.db command line tool
125
125
  email: opensport@googlegroups.com
126
126
  executables: