icu_tournament 1.5.8 → 1.5.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -406,8 +406,8 @@ module ICU
406
406
  # Convenience method to parse a file.
407
407
  def self.parse_file!(file, format, opts={})
408
408
  type = format.to_s
409
- raise "Invalid format" unless type.match(/^(SwissPerfect|SPExport|Krause|ForeignCSV)$/);
410
- parser = "ICU::Tournament::#{format}".constantize.new
409
+ raise "Invalid format" unless klass = factory(format) #type.match(/^(SwissPerfect|SPExport|Krause|ForeignCSV)$/);
410
+ parser = klass.new
411
411
  if type == 'ForeignCSV'
412
412
  # Doesn't take options.
413
413
  parser.parse_file!(file)
@@ -433,6 +433,17 @@ module ICU
433
433
 
434
434
  # :enddoc:
435
435
  private
436
+
437
+ # Return a class given a format.
438
+ def self.factory(format)
439
+ case format
440
+ when "SwissPerfect" then ICU::Tournament::SwissPerfect
441
+ when "SPExport" then ICU::Tournament::SPExport
442
+ when "Krause" then ICU::Tournament::Krause
443
+ when "ForeignCSV" then ICU::Tournament::ForeignCSV
444
+ else nil
445
+ end
446
+ end
436
447
 
437
448
  # Check players.
438
449
  def check_players
@@ -544,8 +555,8 @@ module ICU
544
555
  def check_type(type)
545
556
  if type.respond_to?(:validate!)
546
557
  type.validate!(self)
547
- elsif type.to_s.match(/^(ForeignCSV|Krause|SwissPerfect|SPExport)$/)
548
- "ICU::Tournament::#{type.to_s}".constantize.new.validate!(self)
558
+ elsif klass = self.class.factory(type.to_s)
559
+ klass.new.validate!(self)
549
560
  else
550
561
  raise "invalid type supplied for validation check"
551
562
  end
@@ -554,7 +565,6 @@ module ICU
554
565
  # Return an array of tie break rules and an array of tie break orders (+1 for asc, -1 for desc).
555
566
  # The first and most important method is always "score", the last and least important is always "name".
556
567
  def tie_break_data
557
-
558
568
  # Construct the arrays and hashes to be returned.
559
569
  methods, order, data = Array.new, Hash.new, Hash.new
560
570
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ICU
4
4
  class Tournament
5
- VERSION = "1.5.8"
5
+ VERSION = "1.5.9"
6
6
  end
7
7
  end
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.8
4
+ version: 1.5.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,44 +9,44 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-08 00:00:00.000000000Z
12
+ date: 2012-03-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dbf
16
- requirement: &70317952906900 !ruby/object:Gem::Requirement
16
+ requirement: &70364479562300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.2.5
21
+ version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70317952906900
24
+ version_requirements: *70364479562300
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rubyzip
27
- requirement: &70317952906400 !ruby/object:Gem::Requirement
27
+ requirement: &70364479561540 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
- - - ~>
30
+ - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 0.9.4
32
+ version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70317952906400
35
+ version_requirements: *70364479561540
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: icu_name
38
- requirement: &70317952905940 !ruby/object:Gem::Requirement
38
+ requirement: &70364479560720 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
42
42
  - !ruby/object:Gem::Version
43
- version: 1.0.0
43
+ version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70317952905940
46
+ version_requirements: *70364479560720
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &70317952905560 !ruby/object:Gem::Requirement
49
+ requirement: &70364479560020 !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: *70317952905560
57
+ version_requirements: *70364479560020
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &70317952905100 !ruby/object:Gem::Requirement
60
+ requirement: &70364479559300 !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: *70317952905100
68
+ version_requirements: *70364479559300
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &70317952904680 !ruby/object:Gem::Requirement
71
+ requirement: &70364479558680 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,43 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70317952904680
80
- - !ruby/object:Gem::Dependency
81
- name: guard-rspec
82
- requirement: &70317952904260 !ruby/object:Gem::Requirement
83
- none: false
84
- requirements:
85
- - - ! '>='
86
- - !ruby/object:Gem::Version
87
- version: '0'
88
- type: :development
89
- prerelease: false
90
- version_requirements: *70317952904260
79
+ version_requirements: *70364479558680
91
80
  - !ruby/object:Gem::Dependency
92
81
  name: rdoc
93
- requirement: &70317952903840 !ruby/object:Gem::Requirement
94
- none: false
95
- requirements:
96
- - - ! '>='
97
- - !ruby/object:Gem::Version
98
- version: '0'
99
- type: :development
100
- prerelease: false
101
- version_requirements: *70317952903840
102
- - !ruby/object:Gem::Dependency
103
- name: rb-fsevent
104
- requirement: &70317952903380 !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- type: :development
111
- prerelease: false
112
- version_requirements: *70317952903380
113
- - !ruby/object:Gem::Dependency
114
- name: growl
115
- requirement: &70317952902960 !ruby/object:Gem::Requirement
82
+ requirement: &70364479557880 !ruby/object:Gem::Requirement
116
83
  none: false
117
84
  requirements:
118
85
  - - ! '>='
@@ -120,7 +87,7 @@ dependencies:
120
87
  version: '0'
121
88
  type: :development
122
89
  prerelease: false
123
- version_requirements: *70317952902960
90
+ version_requirements: *70364479557880
124
91
  description: Convert files of chess tournament data in different formats to ruby classes
125
92
  and vice-versa.
126
93
  email: mark.j.l.orr@googlemail.com
@@ -171,7 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
138
  version: '0'
172
139
  segments:
173
140
  - 0
174
- hash: 708722901899167522
141
+ hash: -3628031802817703572
175
142
  required_rubygems_version: !ruby/object:Gem::Requirement
176
143
  none: false
177
144
  requirements:
@@ -180,10 +147,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
147
  version: '0'
181
148
  segments:
182
149
  - 0
183
- hash: 708722901899167522
150
+ hash: -3628031802817703572
184
151
  requirements: []
185
152
  rubyforge_project: icu_tournament
186
- rubygems_version: 1.8.6
153
+ rubygems_version: 1.8.10
187
154
  signing_key:
188
155
  specification_version: 3
189
156
  summary: For reading and writing files of chess tournament data.