sciolyff 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/sciolyff +7 -10
- data/lib/sciolyff/interpreter/event.rb +20 -8
- data/lib/sciolyff/interpreter/html/helpers.rb +130 -0
- data/lib/sciolyff/interpreter/html/template.html.erb +558 -0
- data/lib/sciolyff/interpreter/html.rb +47 -0
- data/lib/sciolyff/interpreter/placing.rb +31 -6
- data/lib/sciolyff/interpreter/raw.rb +50 -0
- data/lib/sciolyff/interpreter/subdivisions.rb +41 -0
- data/lib/sciolyff/interpreter/team.rb +16 -3
- data/lib/sciolyff/interpreter/tiebreaks.rb +34 -0
- data/lib/sciolyff/interpreter/tournament.rb +28 -5
- data/lib/sciolyff/interpreter.rb +34 -44
- data/lib/sciolyff/validator/checker.rb +20 -0
- data/lib/sciolyff/validator/events.rb +96 -0
- data/lib/sciolyff/validator/logger.rb +47 -0
- data/lib/sciolyff/validator/penalties.rb +19 -0
- data/lib/sciolyff/validator/placings.rb +120 -0
- data/lib/sciolyff/validator/raws.rb +19 -0
- data/lib/sciolyff/validator/sections.rb +32 -0
- data/lib/sciolyff/validator/teams.rb +81 -0
- data/lib/sciolyff/validator/top_level.rb +22 -0
- data/lib/sciolyff/validator/tournament.rb +72 -0
- data/lib/sciolyff/validator.rb +88 -0
- data/lib/sciolyff.rb +2 -45
- metadata +20 -25
- data/lib/sciolyff/events.rb +0 -66
- data/lib/sciolyff/penalties.rb +0 -52
- data/lib/sciolyff/placings.rb +0 -198
- data/lib/sciolyff/scores.rb +0 -148
- data/lib/sciolyff/sections.rb +0 -40
- data/lib/sciolyff/teams.rb +0 -96
- data/lib/sciolyff/top_level.rb +0 -13
- data/lib/sciolyff/tournament.rb +0 -94
data/lib/sciolyff/placings.rb
DELETED
@@ -1,198 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'minitest/test'
|
4
|
-
require 'set'
|
5
|
-
|
6
|
-
module SciolyFF
|
7
|
-
# Tests that also serve as the specification for the sciolyff file format
|
8
|
-
#
|
9
|
-
class Placings < Minitest::Test
|
10
|
-
def setup
|
11
|
-
skip unless SciolyFF.rep.instance_of? Hash
|
12
|
-
@placings = SciolyFF.rep[:Placings]
|
13
|
-
skip unless @placings.instance_of? Array
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_has_valid_placings
|
17
|
-
@placings.each do |placing|
|
18
|
-
assert_instance_of Hash, placing
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_each_placing_does_not_have_extra_info
|
23
|
-
@placings.select { |p| p.instance_of? Hash }.each do |placing|
|
24
|
-
info = Set.new %i[event team participated disqualified exempt place tie]
|
25
|
-
info << :unknown
|
26
|
-
assert Set.new(placing.keys).subset? info
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_each_placing_has_valid_event
|
31
|
-
@placings.select { |p| p.instance_of? Hash }.each do |placing|
|
32
|
-
assert_instance_of String, placing[:event]
|
33
|
-
skip unless SciolyFF.rep[:Events].instance_of? Array
|
34
|
-
|
35
|
-
event_names = SciolyFF.rep[:Events].map { |e| e[:name] }
|
36
|
-
assert_includes event_names, placing[:event]
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_each_placing_has_valid_team
|
41
|
-
@placings.select { |p| p.instance_of? Hash }.each do |placing|
|
42
|
-
assert_instance_of Integer, placing[:team]
|
43
|
-
skip unless SciolyFF.rep[:Teams].instance_of? Array
|
44
|
-
|
45
|
-
team_numbers = SciolyFF.rep[:Teams].map { |t| t[:number] }
|
46
|
-
assert_includes team_numbers, placing[:team]
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_each_placing_has_valid_participated
|
51
|
-
@placings.select { |p| p.instance_of? Hash }.each do |placing|
|
52
|
-
if placing.key? :participated
|
53
|
-
assert_includes [true, false], placing[:participated]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_each_placing_has_valid_disqualified
|
59
|
-
@placings.select { |p| p.instance_of? Hash }.each do |placing|
|
60
|
-
if placing.key? :disqualified
|
61
|
-
assert_includes [true, false], placing[:disqualified]
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_each_placing_has_valid_exempt
|
67
|
-
@placings.select { |p| p.instance_of? Hash }.each do |placing|
|
68
|
-
assert_includes [true, false], placing[:exempt] if placing.key? :exempt
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_each_team_has_correct_number_of_exempt_placings
|
73
|
-
skip unless SciolyFF.rep.instance_of? Hash
|
74
|
-
skip unless SciolyFF.rep[:Tournament].instance_of? Hash
|
75
|
-
|
76
|
-
exempt_placings = SciolyFF.rep[:Tournament][:'exempt placings']
|
77
|
-
exempt_placings = 0 if exempt_placings.nil?
|
78
|
-
skip unless exempt_placings.instance_of? Integer
|
79
|
-
|
80
|
-
@placings.select { |p| p.instance_of?(Hash) && p[:'exempt'] }
|
81
|
-
.group_by { |p| p[:team] }
|
82
|
-
.each do |team_number, placings|
|
83
|
-
assert placings.count == exempt_placings,
|
84
|
-
"Team number #{team_number} has the incorrect number of exempt "\
|
85
|
-
"placings (#{placings.count} instead of #{exempt_placings})"
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_each_placing_has_valid_tie
|
90
|
-
@placings.select { |p| p.instance_of? Hash }.each do |placing|
|
91
|
-
next unless placing.key? :tie
|
92
|
-
|
93
|
-
assert_includes [true, false], placing[:tie]
|
94
|
-
next unless placing[:tie]
|
95
|
-
|
96
|
-
all_paired = @placings.select do |p_other|
|
97
|
-
p_other.instance_of?(Hash) &&
|
98
|
-
p_other != placing &&
|
99
|
-
p_other[:event] == placing[:event] &&
|
100
|
-
p_other[:place] == placing[:place]
|
101
|
-
end.all? { |p_other| p_other[:tie] }
|
102
|
-
|
103
|
-
assert all_paired,
|
104
|
-
"The event #{placing[:event]} has unpaired ties at "\
|
105
|
-
"#{placing[:place]}"
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_each_placing_has_valid_unknown
|
110
|
-
skip if SciolyFF.rep[:Tournament]&.key? :'maximum place'
|
111
|
-
|
112
|
-
@placings.select { |p| p.instance_of? Hash }.each do |placing|
|
113
|
-
next unless placing.key? :unknown
|
114
|
-
|
115
|
-
assert_includes [true, false], placing[:unknown]
|
116
|
-
next unless placing[:unknown]
|
117
|
-
|
118
|
-
skip unless SciolyFF.rep[:Events].instance_of? Array
|
119
|
-
|
120
|
-
event = SciolyFF.rep[:Events].find do |e|
|
121
|
-
e[:name] == placing[:event]
|
122
|
-
end
|
123
|
-
assert event[:trial] || event[:trialed] || placing[:exempt],
|
124
|
-
'Cannot have unknown place for non-trial/trialed event '\
|
125
|
-
'or non-exempt place'
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_each_placing_has_valid_place
|
130
|
-
@placings.select { |p| p.instance_of? Hash }.each do |placing|
|
131
|
-
next if placing[:disqualified] == true ||
|
132
|
-
placing.key?(:participated) ||
|
133
|
-
placing[:unknown] == true ||
|
134
|
-
placing[:exempt] == true
|
135
|
-
|
136
|
-
assert_instance_of Integer, placing[:place]
|
137
|
-
max_place = @placings.count do |p|
|
138
|
-
p[:event] == placing[:event] &&
|
139
|
-
!p[:disqualified] &&
|
140
|
-
p[:participated] != false
|
141
|
-
end
|
142
|
-
assert_includes 1..max_place, placing[:place],
|
143
|
-
"The event #{placing[:event]} "\
|
144
|
-
'has an out-of-range placing'
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_placings_are_unique_for_event_and_place
|
149
|
-
skip unless SciolyFF.rep[:Events].instance_of? Array
|
150
|
-
|
151
|
-
SciolyFF.rep[:Events].each do |event|
|
152
|
-
next unless event.instance_of? Hash
|
153
|
-
|
154
|
-
places = @placings.select { |p| p[:event] == event[:name] }
|
155
|
-
.reject { |p| p[:tie] }
|
156
|
-
.map { |p| p[:place] }
|
157
|
-
.compact
|
158
|
-
|
159
|
-
dups = places.select.with_index do |p, i|
|
160
|
-
places.index(p) != i
|
161
|
-
end
|
162
|
-
|
163
|
-
assert_empty dups,
|
164
|
-
"The event #{event[:name]} has unmarked ties at #{dups}"
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
def test_placings_are_unique_for_event_and_team
|
169
|
-
skip unless SciolyFF.rep[:Teams].instance_of? Array
|
170
|
-
|
171
|
-
SciolyFF.rep[:Teams].each do |team|
|
172
|
-
next unless team.instance_of? Hash
|
173
|
-
|
174
|
-
assert_nil @placings.select { |p| p[:team] == team[:number] }
|
175
|
-
.map { |p| p[:event] }
|
176
|
-
.compact
|
177
|
-
.uniq!
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
def test_each_team_has_placings_for_all_events
|
182
|
-
skip unless SciolyFF.rep[:Teams].instance_of?(Array) &&
|
183
|
-
SciolyFF.rep[:Events].instance_of?(Array)
|
184
|
-
|
185
|
-
SciolyFF.rep[:Teams].select { |t| t.instance_of? Hash }.each do |team|
|
186
|
-
events = SciolyFF.rep[:Events].select { |e| e.instance_of? Hash }
|
187
|
-
.map { |e| e[:name] }
|
188
|
-
|
189
|
-
events_with_placings =
|
190
|
-
@placings.select { |p| p.instance_of? Hash }
|
191
|
-
.select { |p| p[:team] == team[:number] }
|
192
|
-
.map { |p| p[:event] }
|
193
|
-
|
194
|
-
assert_equal events.sort, events_with_placings.sort
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
data/lib/sciolyff/scores.rb
DELETED
@@ -1,148 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'minitest/test'
|
4
|
-
require 'set'
|
5
|
-
|
6
|
-
module SciolyFF
|
7
|
-
# Tests that also serve as the specification for the sciolyff file format
|
8
|
-
#
|
9
|
-
class Scores < Minitest::Test
|
10
|
-
def setup
|
11
|
-
skip unless SciolyFF.rep.instance_of? Hash
|
12
|
-
@scores = SciolyFF.rep[:Scores]
|
13
|
-
skip unless @scores.instance_of? Array
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_has_valid_scores
|
17
|
-
@scores.each do |score|
|
18
|
-
assert_instance_of Hash, score
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_each_score_does_not_have_extra_info
|
23
|
-
@scores.select { |s| s.instance_of? Hash }.each do |score|
|
24
|
-
a = %i[event team participated disqualified exempt unknown score tier]
|
25
|
-
a << :'tiebreaker place'
|
26
|
-
info = Set.new a
|
27
|
-
assert Set.new(score.keys).subset? info
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_each_score_has_valid_event
|
32
|
-
@scores.select { |s| s.instance_of? Hash }.each do |score|
|
33
|
-
assert_instance_of String, score[:event]
|
34
|
-
skip unless SciolyFF.rep[:Events].instance_of? Array
|
35
|
-
|
36
|
-
event_names = SciolyFF.rep[:Events].map { |e| e[:name] }
|
37
|
-
assert_includes event_names, score[:event]
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_each_score_has_valid_team
|
42
|
-
@scores.select { |s| s.instance_of? Hash }.each do |score|
|
43
|
-
assert_instance_of Integer, score[:team]
|
44
|
-
skip unless SciolyFF.rep[:Teams].instance_of? Array
|
45
|
-
|
46
|
-
team_numbers = SciolyFF.rep[:Teams].map { |t| t[:number] }
|
47
|
-
assert_includes team_numbers, score[:team]
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_each_score_has_valid_participated
|
52
|
-
@scores.select { |s| s.instance_of? Hash }.each do |score|
|
53
|
-
if score.key? :participated
|
54
|
-
assert_includes [true, false], score[:participated]
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_each_score_has_valid_disqualified
|
60
|
-
@scores.select { |s| s.instance_of? Hash }.each do |score|
|
61
|
-
if score.key? :disqualified
|
62
|
-
assert_includes [true, false], score[:disqualified]
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_each_score_has_valid_exempt
|
68
|
-
@scores.select { |s| s.instance_of? Hash }.each do |score|
|
69
|
-
assert_includes [true, false], score[:exempt] if score.key? :exempt
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_each_score_has_valid_unknown
|
74
|
-
@scores.select { |s| s.instance_of? Hash }.each do |score|
|
75
|
-
assert_includes [true, false], score[:unknown] if score.key? :unknown
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_each_score_has_valid_score
|
80
|
-
@scores.select { |s| s.instance_of? Hash }.each do |score|
|
81
|
-
next if score[:disqualified] == true ||
|
82
|
-
score.key?(:participated) ||
|
83
|
-
placing[:exempt] == true
|
84
|
-
|
85
|
-
assert_kind_of Numeric, score[:score]
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_each_score_has_valid_tiebreaker_place
|
90
|
-
@scores.select { |s| s.instance_of? Hash }.each do |score|
|
91
|
-
next unless score.key? 'tiebreaker place'
|
92
|
-
|
93
|
-
max_place = @scores.count do |s|
|
94
|
-
s[:event] == score[:event] &&
|
95
|
-
s[:score] == score[:score]
|
96
|
-
end
|
97
|
-
assert_instance_of Integer, score['tiebreaker place']
|
98
|
-
assert_includes 1..max_place, score['tiebreaker place']
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_each_score_has_valid_tier
|
103
|
-
skip unless SciolyFF.rep[:Events].instance_of? Array
|
104
|
-
|
105
|
-
@scores.select { |s| s.instance_of? Hash }.each do |score|
|
106
|
-
next unless score.key? :tier
|
107
|
-
|
108
|
-
assert_instance_of Integer, score[:tier]
|
109
|
-
|
110
|
-
max_tier = SciolyFF.rep[:Events].find do |event|
|
111
|
-
event[:name] == score[:event]
|
112
|
-
end&.[](:tiers)
|
113
|
-
|
114
|
-
refute_nil max_tier, "#{score[:event]} does not have tiers"
|
115
|
-
assert_includes 1..max_tier, score[:tier]
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_scores_are_unique_for_event_and_team
|
120
|
-
skip unless SciolyFF.rep[:Teams].instance_of? Array
|
121
|
-
|
122
|
-
SciolyFF.rep[:Teams].each do |team|
|
123
|
-
next unless team.instance_of? Hash
|
124
|
-
|
125
|
-
assert_nil @scores.select { |s| s[:team] == team[:number] }
|
126
|
-
.map { |s| s[:event] }
|
127
|
-
.compact
|
128
|
-
.uniq!
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_each_team_has_scores_for_all_events
|
133
|
-
skip unless SciolyFF.rep[:Teams].instance_of?(Array) &&
|
134
|
-
SciolyFF.rep[:Events].instance_of?(Array)
|
135
|
-
|
136
|
-
SciolyFF.rep[:Teams].select { |t| t.instance_of? Hash }.each do |team|
|
137
|
-
events = SciolyFF.rep[:Events].select { |e| e.instance_of? Hash }
|
138
|
-
.map { |e| e[:name] }
|
139
|
-
|
140
|
-
events_with_scores = @scores.select { |s| s.instance_of? Hash }
|
141
|
-
.select { |s| s[:team] == team[:number] }
|
142
|
-
.map { |s| s[:event] }
|
143
|
-
|
144
|
-
assert_equal events, events_with_scores
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
data/lib/sciolyff/sections.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'minitest/test'
|
4
|
-
require 'set'
|
5
|
-
|
6
|
-
module SciolyFF
|
7
|
-
# Tests that also serve as the specification for the sciolyff file format
|
8
|
-
#
|
9
|
-
class Sections < Minitest::Test
|
10
|
-
def setup
|
11
|
-
@rep = SciolyFF.rep
|
12
|
-
skip unless @rep.instance_of? Hash
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_has_tournament
|
16
|
-
assert_instance_of Hash, @rep[:Tournament]
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_has_events
|
20
|
-
assert_instance_of Array, @rep[:Events]
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_has_teams
|
24
|
-
assert_instance_of Array, @rep[:Teams]
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_has_placings
|
28
|
-
assert_instance_of Array, @rep[:Placings]
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_has_penalties
|
32
|
-
assert_instance_of Array, @rep[:Penalties] if @rep.key? :Penalties
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_does_not_have_extra_sections
|
36
|
-
sections = Set.new %i[Tournament Events Teams Placings Scores Penalties]
|
37
|
-
assert Set.new(@rep.keys).subset? sections
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
data/lib/sciolyff/teams.rb
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'minitest/test'
|
4
|
-
require 'set'
|
5
|
-
|
6
|
-
module SciolyFF
|
7
|
-
# Tests that also serve as the specification for the sciolyff file format
|
8
|
-
#
|
9
|
-
class Teams < Minitest::Test
|
10
|
-
def setup
|
11
|
-
skip unless SciolyFF.rep.instance_of? Hash
|
12
|
-
@teams = SciolyFF.rep[:Teams]
|
13
|
-
skip unless @teams.instance_of? Array
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_has_valid_teams
|
17
|
-
@teams.each do |team|
|
18
|
-
assert_instance_of Hash, team
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_each_team_does_not_have_extra_info
|
23
|
-
@teams.select { |t| t.instance_of? Hash }.each do |team|
|
24
|
-
fo = Set.new %i[school suffix subdivision exhibition number city state]
|
25
|
-
fo << :'school abbreviation'
|
26
|
-
assert Set.new(team.keys).subset? fo
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_each_team_has_valid_school
|
31
|
-
@teams.select { |t| t.instance_of? Hash }.each do |team|
|
32
|
-
assert_instance_of String, team[:school]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_each_team_has_valid_school_abbreviation
|
37
|
-
@teams.select { |t| t.instance_of? Hash }.each do |team|
|
38
|
-
assert_instance_of String, team[:'school abbreviation'] \
|
39
|
-
if team.key? :'school abbreviation'
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_each_team_has_valid_suffix
|
44
|
-
@teams.select { |t| t.instance_of? Hash }.each do |team|
|
45
|
-
assert_instance_of String, team[:suffix] if team.key? :suffix
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_each_team_has_valid_subdivision
|
50
|
-
@teams.select { |t| t.instance_of? Hash }.each do |team|
|
51
|
-
assert_instance_of String, team[:subdivision] \
|
52
|
-
if team.key? :subdivision
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_each_team_has_valid_exhibition
|
57
|
-
@teams.select { |t| t.instance_of? Hash }.each do |team|
|
58
|
-
assert_includes [true, false], team[:exhibition] \
|
59
|
-
if team.key? :exhibition
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_each_team_has_valid_number
|
64
|
-
@teams.select { |t| t.instance_of? Hash }.each do |team|
|
65
|
-
assert_instance_of Integer, team[:number]
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_each_team_has_valid_city
|
70
|
-
@teams.select { |t| t.instance_of? Hash }.each do |team|
|
71
|
-
assert_instance_of String, team[:city] if team.key? :city
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_each_team_has_valid_state
|
76
|
-
@teams.select { |t| t.instance_of? Hash }.each do |team|
|
77
|
-
assert_instance_of String, team[:state]
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_each_team_has_unique_number
|
82
|
-
numbers = @teams.select { |t| t.instance_of? Hash }
|
83
|
-
.map { |t| t[:number] }
|
84
|
-
assert_nil numbers.uniq!
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_each_suffix_is_unique_per_school
|
88
|
-
@teams.select { |t| t.instance_of? Hash }
|
89
|
-
.group_by { |t| [t[:school], t[:state], t[:city]] }
|
90
|
-
.each do |group, teams|
|
91
|
-
assert_nil teams.map { |t| t[:suffix] }.compact.uniq!,
|
92
|
-
"#{group} has the same suffix for multiple teams"
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
data/lib/sciolyff/top_level.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'minitest/test'
|
4
|
-
|
5
|
-
module SciolyFF
|
6
|
-
# Tests that also serve as the specification for the sciolyff file format
|
7
|
-
#
|
8
|
-
class TopLevel < Minitest::Test
|
9
|
-
def test_is_hash
|
10
|
-
assert_instance_of Hash, SciolyFF.rep
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/lib/sciolyff/tournament.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'minitest/test'
|
4
|
-
require 'set'
|
5
|
-
|
6
|
-
module SciolyFF
|
7
|
-
# Tests that also serve as the specification for the sciolyff file format
|
8
|
-
#
|
9
|
-
class Tournament < Minitest::Test
|
10
|
-
def setup
|
11
|
-
skip unless SciolyFF.rep.instance_of? Hash
|
12
|
-
@tournament = SciolyFF.rep[:Tournament]
|
13
|
-
skip unless @tournament.instance_of? Hash
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_has_info
|
17
|
-
refute_nil @tournament[:location]
|
18
|
-
refute_nil @tournament[:level]
|
19
|
-
refute_nil @tournament[:division]
|
20
|
-
refute_nil @tournament[:year]
|
21
|
-
refute_nil @tournament[:date]
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_does_not_have_extra_info
|
25
|
-
info = Set.new %i[name location level division state year date]
|
26
|
-
info << :'short name' << :'worst placings dropped' << :'exempt placings'
|
27
|
-
info << :'maximum place'
|
28
|
-
assert Set.new(@tournament.keys).subset? info
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_has_valid_name
|
32
|
-
skip unless @tournament.key? :name
|
33
|
-
assert_instance_of String, @tournament[:name]
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_has_valid_short_name
|
37
|
-
skip unless @tournament.key? :'short name'
|
38
|
-
assert @tournament.key?(:name), 'Cannot have short name without name'
|
39
|
-
assert_instance_of String, @tournament[:'short name']
|
40
|
-
|
41
|
-
skip unless @tournament[:name].instance_of? String
|
42
|
-
assert @tournament[:'short name'].length < @tournament[:name].length,
|
43
|
-
'Length of short name must be shorter than length of name'
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_has_valid_location
|
47
|
-
skip unless @tournament.key? :location
|
48
|
-
assert_instance_of String, @tournament[:location]
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_has_valid_level
|
52
|
-
skip unless @tournament.key? :level
|
53
|
-
level = @tournament[:level]
|
54
|
-
assert_includes %w[Invitational Regionals States Nationals], level
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_has_valid_division
|
58
|
-
skip unless @tournament.key? :division
|
59
|
-
assert_includes %w[A B C], @tournament[:division]
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_has_valid_state
|
63
|
-
skip unless @tournament.key? :level
|
64
|
-
level = @tournament[:level]
|
65
|
-
skip unless %w[Regionals States].include? level
|
66
|
-
assert_instance_of String, @tournament[:state]
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_has_valid_year
|
70
|
-
skip unless @tournament.key? :year
|
71
|
-
assert_instance_of Integer, @tournament[:year]
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_has_valid_date
|
75
|
-
skip unless @tournament.key? :date
|
76
|
-
assert_instance_of Date, @tournament[:date]
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_has_valid_worst_placings_dropped
|
80
|
-
skip unless @tournament.key? :'worst placings dropped'
|
81
|
-
assert_instance_of Integer, @tournament[:'worst placings dropped']
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_has_valid_exempt_placings
|
85
|
-
skip unless @tournament.key? :'exempt placings'
|
86
|
-
assert_instance_of Integer, @tournament[:'exempt placings']
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_has_valid_maximum_place
|
90
|
-
skip unless @tournament.key? :'maximum place'
|
91
|
-
assert_instance_of Integer, @tournament[:'maximum place']
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|