icu_tournament 1.5.13 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,6 +8,7 @@ module ICU
8
8
  #
9
9
  # Event,"Isle of Man Masters, 2007"
10
10
  # Start,2007-09-22
11
+ # End,2007-09-30
11
12
  # Rounds,9
12
13
  # Website,http://www.bcmchess.co.uk/monarch2007/
13
14
  #
@@ -33,6 +34,7 @@ module ICU
33
34
  #
34
35
  # tournament.name # => "Isle of Man Masters, 2007"
35
36
  # tournament.start # => "2007-09-22"
37
+ # tournament.finish # => "2007-09-30"
36
38
  # tournament.rounds # => 9
37
39
  # tournament.website # => "http://www.bcmchess.co.uk/monarch2007/"
38
40
  #
@@ -77,7 +79,7 @@ module ICU
77
79
  #
78
80
  # Extra condtions, over and above the normal validation rules, apply before any tournament validates or can be serialized in this format.
79
81
  #
80
- # * the tournament must have a _site_ attribute
82
+ # * the tournament must have a _site_ attribute and a _finish_ date
81
83
  # * there must be at least one player with an _id_ (ICU ID number)
82
84
  # * all foreign players (those without an ICU ID) must have a _fed_ attribute (federation)
83
85
  # * all ICU players must have a result in every round (even if it is just bye or is unrateable)
@@ -94,7 +96,7 @@ module ICU
94
96
  # For example, here are the commands to reproduce the example above. Note that in this format
95
97
  # opponents' ratings are FIDE.
96
98
  #
97
- # t = ICU::Tournament.new("Isle of Man Masters, 2007", '2007-09-22', :rounds => 9)
99
+ # t = ICU::Tournament.new("Isle of Man Masters, 2007", '2007-09-22', :finish => '2007-09-30', :rounds => 9)
98
100
  # t.site = 'http://www.bcmchess.co.uk/monarch2007/'
99
101
  # t.add_player(ICU::Player.new('Anthony', 'Fox', 1, :fide_rating => 2100, :fed => 'IRL', :id => 456))
100
102
  # t.add_player(ICU::Player.new('Peter P.', 'Taylor', 2, :fide_rating => 2209, :fed => 'ENG'))
@@ -136,11 +138,12 @@ module ICU
136
138
  case @state
137
139
  when 0 then event
138
140
  when 1 then start
139
- when 2 then rounds
140
- when 3 then website
141
- when 4 then player
142
- when 5 then result
143
- when 6 then total
141
+ when 2 then finish
142
+ when 3 then rounds
143
+ when 4 then website
144
+ when 5 then player
145
+ when 6 then result
146
+ when 7 then total
144
147
  else raise "internal error - state #{@state} does not exist"
145
148
  end
146
149
  rescue => err
@@ -149,14 +152,15 @@ module ICU
149
152
  end
150
153
  end
151
154
 
152
- unless @state == 4
155
+ unless @state == 5
153
156
  exp = case @state
154
157
  when 0 then "the event name"
155
158
  when 1 then "the start date"
156
- when 2 then "the number of rounds"
157
- when 3 then "the website address"
158
- when 5 then "a result for round #{@round+1}"
159
- when 6 then "a total score"
159
+ when 2 then "the end date"
160
+ when 3 then "the number of rounds"
161
+ when 4 then "the website address"
162
+ when 6 then "a result for round #{@round+1}"
163
+ when 7 then "a total score"
160
164
  end
161
165
  raise "line #{@line}: premature termination - expected #{exp}"
162
166
  end
@@ -200,6 +204,7 @@ module ICU
200
204
  CSV.generate do |csv|
201
205
  csv << ["Event", t.name]
202
206
  csv << ["Start", t.start]
207
+ csv << ["End", t.finish]
203
208
  csv << ["Rounds", t.rounds]
204
209
  csv << ["Website", t.site]
205
210
  t.players.each do |p|
@@ -232,6 +237,7 @@ module ICU
232
237
 
233
238
  # Additional tournament validation rules for this specific type.
234
239
  def validate!(t)
240
+ raise "missing end date" unless t.finish
235
241
  raise "missing site" unless t.site.to_s.length > 0
236
242
  icu = t.players.find_all { |p| p.id }
237
243
  raise "there must be at least one ICU player (with an ID number)" if icu.size == 0
@@ -266,24 +272,31 @@ module ICU
266
272
  end
267
273
 
268
274
  def start
269
- abort "the 'Start' keyword", 0 unless @r[0].match(/^(Start(\s+Date)?|Date)$/i)
275
+ abort "the 'Start' keyword", 0 unless @r[0].match(/^(Start(\s+Date)?)$/i)
270
276
  abort "the start date", 1 unless @r.size > 1 && @r[1] != ''
271
277
  @tournament.start = @r[1]
272
278
  @state = 2
273
279
  end
274
280
 
281
+ def finish
282
+ abort "the 'End' keyword", 0 unless @r[0].match(/^(End(\s+Date)?)$/i)
283
+ abort "the end date", 1 unless @r.size > 1 && @r[1] != ''
284
+ @tournament.finish = @r[1]
285
+ @state = 3
286
+ end
287
+
275
288
  def rounds
276
289
  abort "the 'Rounds' keyword", 0 unless @r[0].match(/(Number of )?Rounds$/)
277
290
  abort "the number of rounds", 1 unless @r.size > 1 && @r[1].match(/^[1-9]\d*/)
278
291
  @tournament.rounds = @r[1]
279
- @state = 3
292
+ @state = 4
280
293
  end
281
294
 
282
295
  def website
283
296
  abort "the 'Website' keyword", 0 unless @r[0].match(/^(Web(\s?site)?|Site)$/i)
284
297
  abort "the event website", 1 unless @r.size > 1 && @r[1] != ''
285
298
  @tournament.site = @r[1]
286
- @state = 4
299
+ @state = 5
287
300
  end
288
301
 
289
302
  def player
@@ -302,7 +315,7 @@ module ICU
302
315
  @tournament.add_player(@player)
303
316
  end
304
317
  @round = 0
305
- @state = 5
318
+ @state = 6
306
319
  end
307
320
 
308
321
  def result
@@ -336,14 +349,14 @@ module ICU
336
349
  @tournament.add_result(result)
337
350
  end
338
351
  end
339
- @state = 6 if @round == @tournament.rounds
352
+ @state = 7 if @round == @tournament.rounds
340
353
  end
341
354
 
342
355
  def total
343
356
  points = @player.points
344
357
  abort "the 'Total' keyword", 0 unless @r[0].match(/^Total$/i)
345
358
  abort "the player's (#{@player.object_id}, #{@player.results.size}) total points to be #{points}", 1 unless @r[1].to_f == points
346
- @state = 4
359
+ @state = 5
347
360
  end
348
361
 
349
362
  def abort(expected, cell)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ICU
4
4
  class Tournament
5
- VERSION = "1.5.13"
5
+ VERSION = "1.6.0"
6
6
  end
7
7
  end
@@ -22,6 +22,7 @@ module ICU
22
22
  @csv = <<CSV
23
23
  Event,"Bangor Open, 2003"
24
24
  Start,1st July 2003
25
+ End,2003-07-03
25
26
  Rounds,4
26
27
  Website,http://www.icu.ie/tournaments/display.php?id=371
27
28
 
@@ -73,6 +74,7 @@ CSV
73
74
  @csv = <<CSV
74
75
  Event,"Isle of Man Masters, 2007"
75
76
  Start,2007-09-22
77
+ End,2007-09-29
76
78
  Rounds,9
77
79
  Website,http://www.bcmchess.co.uk/monarch2007/
78
80
 
@@ -127,6 +129,7 @@ CSV
127
129
  @csv = <<CSV
128
130
  Event,"Edinburgh Masters, 2007"
129
131
  Start,3rd January 2007
132
+ End,3rd January 2007
130
133
  Rounds,2
131
134
  Website,http://www.chesscenter.com/twic/twic.html
132
135
 
@@ -169,6 +172,7 @@ CSV
169
172
  @csv = <<CSV
170
173
  Event,"Bratto Open, 2001"
171
174
  Start,7th March 2001
175
+ End,09/03/2001
172
176
  Rounds,2
173
177
  Website,http://www.federscacchi.it/
174
178
 
@@ -211,6 +215,7 @@ CSV
211
215
 
212
216
  Event," Bratto Open, 2001 "
213
217
  Start, 7th March 2001
218
+ End ,2001/03/ 07
214
219
  Rounds, 2
215
220
  Website, http://www.federscacchi.it/
216
221
  Player ,3364 , ui Laighleis, gearoidin
@@ -258,6 +263,7 @@ CSV
258
263
  csv = <<CSV
259
264
  Event,"Bratto Open, 2001"
260
265
  Start,7th March 2001
266
+ End,7th March 2001
261
267
  Rounds,2
262
268
  Website,http://www.federscacchi.it/
263
269
 
@@ -288,6 +294,7 @@ CSV
288
294
  it "the event should come first" do
289
295
  csv = <<CSV
290
296
  Start,7th March 2001
297
+ End,7th March 2001
291
298
  Event,"Bratto Open, 2001"
292
299
  Rounds,2
293
300
  Website,http://www.federscacchi.it/
@@ -295,9 +302,10 @@ CSV
295
302
  lambda { @f.parse!(csv) }.should raise_error(/line 1.*event/i)
296
303
  end
297
304
 
298
- it "the start should come second" do
305
+ it "the start should come next" do
299
306
  csv = <<CSV
300
307
  Event,"Bratto Open, 2001"
308
+ End,7th March 2001
301
309
  Rounds,2
302
310
  Start,7th March 2001
303
311
  Website,http://www.federscacchi.it/
@@ -305,52 +313,69 @@ CSV
305
313
  lambda { @f.parse!(csv) }.should raise_error(/line 2.*start/i)
306
314
  end
307
315
 
308
- it "the number of rounds should come third" do
316
+ it "the end should come next" do
309
317
  csv = <<CSV
310
318
  Event,"Bratto Open, 2001"
311
319
  Start,7th March 2001
320
+ Rounds,2
321
+ Start,7th March 2001
322
+ Website,http://www.federscacchi.it/
323
+ CSV
324
+ lambda { @f.parse!(csv) }.should raise_error(/line 3.*end/i)
325
+ end
326
+
327
+ it "the number of rounds should come next" do
328
+ csv = <<CSV
329
+ Event,"Bratto Open, 2001"
330
+ Start,7th March 2001
331
+ End,7th March 2001
312
332
  Website,http://www.federscacchi.it/
313
333
  Rounds,2
314
334
  CSV
315
- lambda { @f.parse!(csv) }.should raise_error(/line 3.*rounds/i)
335
+ lambda { @f.parse!(csv) }.should raise_error(/line 4.*rounds/i)
316
336
  end
317
337
 
318
338
  it "there should be a web site" do
319
339
  csv = <<CSV
320
340
  Event,"Bratto Open, 2001"
321
341
  Start,7th March 2001
342
+ End,7th March 2001
322
343
  Rounds,2
323
344
 
324
345
  CSV
325
- lambda { @f.parse!(csv) }.should raise_error(/line 4.*site/i)
346
+ lambda { @f.parse!(csv) }.should raise_error(/line 5.*site/i)
326
347
  end
327
348
 
328
349
  it "should have at least one player" do
329
350
  csv = <<CSV
330
351
  Event,"Bratto Open, 2001"
331
352
  Start,7th March 2001
353
+ End,7th March 2001
332
354
  Rounds,2
333
355
  Website,http://www.federscacchi.it/
356
+
334
357
  CSV
335
- lambda { @f.parse!(csv) }.should raise_error(/line 4.*no players/i)
358
+ lambda { @f.parse!(csv) }.should raise_error(/line 6.*no players/i)
336
359
  end
337
360
 
338
361
  it "the player needs to have a valid ID number" do
339
362
  csv = <<CSV
340
363
  Event,"Bratto Open, 2001"
341
364
  Start,7th March 2001
365
+ End,7th March 2001
342
366
  Rounds,2
343
367
  Website,http://www.federscacchi.it/
344
368
 
345
369
  Player,0,Ui Laighleis,Gearoidin
346
370
  CSV
347
- lambda { @f.parse!(csv) }.should raise_error(/line 6.*number/i)
371
+ lambda { @f.parse!(csv) }.should raise_error(/line 7.*number/i)
348
372
  end
349
373
 
350
374
  it "should have the right number of results for each player" do
351
375
  csv = <<CSV
352
376
  Event,"Bratto Open, 2001"
353
377
  Start,7th March 2001
378
+ End,7th March 2001
354
379
  Rounds,2
355
380
  Website,http://www.federscacchi.it/
356
381
 
@@ -358,13 +383,14 @@ Player,3364,Ui Laighleis,Gearoidin
358
383
  1,=,W,Kasparov,Gary,2800,GM,RUS
359
384
  Total,0.5
360
385
  CSV
361
- lambda { @f.parse!(csv) }.should raise_error(/line 8.*round/i)
386
+ lambda { @f.parse!(csv) }.should raise_error(/line 9.*round/i)
362
387
  end
363
388
 
364
389
  it "should have correct totals" do
365
390
  csv = <<CSV
366
391
  Event,"Bratto Open, 2001"
367
392
  Start,7th March 2001
393
+ End,7th March 2001
368
394
  Rounds,2
369
395
  Website,http://www.federscacchi.it/
370
396
 
@@ -373,14 +399,14 @@ Player,3364,Ui Laighleis,Gearoidin
373
399
  2,=,B,Orr,Mark,2100,IM,IRL
374
400
  Total,1.5
375
401
  CSV
376
- lambda { @f.parse!(csv) }.should raise_error(/line 9.*total/i)
402
+ lambda { @f.parse!(csv) }.should raise_error(/line 10.*total/i)
377
403
  end
378
404
 
379
-
380
405
  it "players who match by name and federation should match in all other details" do
381
406
  csv = <<CSV
382
407
  Event,"Bratto Open, 2001"
383
408
  Start,7th March 2001
409
+ End,7th March 2001
384
410
  Rounds,2
385
411
  Website,http://www.federscacchi.it/
386
412
 
@@ -394,7 +420,7 @@ Player,1350,Orr,Mark
394
420
  2,=,B,Kasparov,Gary,2850,GM,RUS
395
421
  Total,1.0
396
422
  CSV
397
- lambda { @f.parse!(csv) }.should raise_error(/line 13.*same name.*conflicting/i)
423
+ lambda { @f.parse!(csv) }.should raise_error(/line 14.*same name.*conflicting/i)
398
424
  end
399
425
  end
400
426
 
@@ -403,6 +429,7 @@ CSV
403
429
  @csv = <<CSV
404
430
  Event,"Edinburgh Masters, 2007"
405
431
  Start,2007-08-09
432
+ End,2007-08-09
406
433
  Rounds,2
407
434
  Website,http://www.chesscenter.com/twic/twic.html
408
435
 
@@ -430,6 +457,7 @@ CSV
430
457
  @csv = <<CSV
431
458
  Event,"Isle of Man Masters, 2007"
432
459
  Start,2007-09-22
460
+ End,2007-09-30
433
461
  Rounds,9
434
462
  Website,http://www.bcmchess.co.uk/monarch2007/
435
463
 
@@ -457,7 +485,8 @@ Player,159,Cafolla,Peter
457
485
  9,0,W,Grant,Alan,2223,,SCO
458
486
  Total,3.0
459
487
  CSV
460
- @t = ICU::Tournament.new("Isle of Man Masters, 2007", '2007-09-22')
488
+ @t = ICU::Tournament.new('Isle of Man Masters, 2007', '2007-09-22')
489
+ @t.finish = '2007-09-30'
461
490
  @t.site = 'http://www.bcmchess.co.uk/monarch2007/'
462
491
  @t.rounds = 9
463
492
  @t.add_player(ICU::Player.new('Anthony', 'Fox', 1, :id => 456, :fide_rating => 2100, :fed => 'IRL'))
@@ -507,6 +536,7 @@ CSV
507
536
  @csv = <<CSV
508
537
  Event,"Isle of Man Masters, 2007"
509
538
  Start,2007-09-22
539
+ End,2007-09-30
510
540
  Rounds,9
511
541
  Website,http://www.bcmchess.co.uk/monarch2007/
512
542
 
@@ -522,7 +552,8 @@ Player,456,Fox,Anthony
522
552
  9,=,W,Phillips,Roy,2271,,MAU
523
553
  Total,4.0
524
554
  CSV
525
- @t = ICU::Tournament.new("Isle of Man Masters, 2007", '2007-09-22')
555
+ @t = ICU::Tournament.new('Isle of Man Masters, 2007', '2007-09-22')
556
+ @t.finish = '2007-09-30'
526
557
  @t.site = 'http://www.bcmchess.co.uk/monarch2007/'
527
558
  @t.add_player(ICU::Player.new('Anthony', 'Fox', 1, :id => 456, :fide_rating => 2100, :fed => 'IRL'))
528
559
  @t.add_player(ICU::Player.new('Peter P.', 'Taylor', 2, :fide_rating => 2209, :fed => 'ENG'))
@@ -555,6 +586,7 @@ CSV
555
586
  @csv = <<CSV
556
587
  Event,"Brätto Open, 2001"
557
588
  Start,7th March 2001
589
+ End,9th March 2001
558
590
  Rounds,2
559
591
  Website,http://www.federscacchi.it/
560
592
 
@@ -643,6 +675,7 @@ CSV
643
675
  before(:each) do
644
676
  @p = ICU::Tournament::ForeignCSV.new
645
677
  @t = ICU::Tournament.new("Isle of Man Masters, 2007", '2007-09-22')
678
+ @t.finish = '2007-09-30'
646
679
  @t.site = 'http://www.bcmchess.co.uk/monarch2007/'
647
680
  @t.add_player(ICU::Player.new('Anthony', 'Fox', 1, :id => 456))
648
681
  @t.add_player(ICU::Player.new('Peter', 'Cafolla', 2, :id => 159))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icu_tournament
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.13
4
+ version: 1.6.0
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: 2012-05-02 00:00:00.000000000Z
12
+ date: 2012-06-17 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dbf
16
- requirement: &70135277126160 !ruby/object:Gem::Requirement
16
+ requirement: &70184876559320 !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: *70135277126160
24
+ version_requirements: *70184876559320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rubyzip
27
- requirement: &70135277125480 !ruby/object:Gem::Requirement
27
+ requirement: &70184876558560 !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: *70135277125480
35
+ version_requirements: *70184876558560
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: icu_name
38
- requirement: &70135277124700 !ruby/object:Gem::Requirement
38
+ requirement: &70184876557580 !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: *70135277124700
46
+ version_requirements: *70184876557580
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &70135277123960 !ruby/object:Gem::Requirement
49
+ requirement: &70184876556580 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70135277123960
57
+ version_requirements: *70184876556580
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &70135277112660 !ruby/object:Gem::Requirement
60
+ requirement: &70184876555960 !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: :development
67
67
  prerelease: false
68
- version_requirements: *70135277112660
68
+ version_requirements: *70184876555960
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &70135277111900 !ruby/object:Gem::Requirement
71
+ requirement: &70184876555020 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70135277111900
79
+ version_requirements: *70184876555020
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rdoc
82
- requirement: &70135277111340 !ruby/object:Gem::Requirement
82
+ requirement: &70184876553900 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70135277111340
90
+ version_requirements: *70184876553900
91
91
  description: Convert files of chess tournament data in different formats to ruby classes
92
92
  and vice-versa.
93
93
  email: mark.j.l.orr@googlemail.com
@@ -138,7 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  segments:
140
140
  - 0
141
- hash: -1249342061197821456
141
+ hash: 4507010155843698143
142
142
  required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  none: false
144
144
  requirements:
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  segments:
149
149
  - 0
150
- hash: -1249342061197821456
150
+ hash: 4507010155843698143
151
151
  requirements: []
152
152
  rubyforge_project: icu_tournament
153
153
  rubygems_version: 1.8.10