sciolyff 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/sciolyff +1 -1
- data/lib/sciolyff/placings.rb +5 -6
- data/lib/sciolyff/teams.rb +9 -0
- data/lib/sciolyff/tournament.rb +11 -0
- data/lib/sciolyff.rb +29 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d439db52050ce2e14cdefb6e5d2520d1105dbea5dbe49a4cf5a5e83323a30bd
|
4
|
+
data.tar.gz: 1f6611b0af9696973430b849c5241a61ef9d23fa254db9cba12b4b08d3c8647d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2901fb2fdb8e8e7aa26e9cc97cd1c2c0989d1cc18233f1cd9b038c724dae54530b64be62d812abc03a753f92bed46763df2d487a7b377471d9559bfc809049d9
|
7
|
+
data.tar.gz: 61b9fca3f88e142116e211cf576b6751d98e99ba7a464433a96af2ec401b9f6a71acf4879ea247f6612965a65e5672b81264790e812cfb8006252e128190879c
|
data/bin/sciolyff
CHANGED
data/lib/sciolyff/placings.rb
CHANGED
@@ -76,15 +76,14 @@ module SciolyFF
|
|
76
76
|
assert_includes [true, false], placing[:tie]
|
77
77
|
next unless placing[:tie]
|
78
78
|
|
79
|
-
|
79
|
+
all_paired = @placings.select do |p_other|
|
80
80
|
p_other.instance_of?(Hash) &&
|
81
81
|
p_other != placing &&
|
82
82
|
p_other[:event] == placing[:event] &&
|
83
|
-
p_other[:
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
assert has_pair,
|
83
|
+
p_other[:place] == placing[:place]
|
84
|
+
end.all? { |p_other| p_other[:tie] }
|
85
|
+
|
86
|
+
assert all_paired,
|
88
87
|
"The event #{placing[:event]} has unpaired ties at "\
|
89
88
|
"#{placing[:place]}"
|
90
89
|
end
|
data/lib/sciolyff/teams.rb
CHANGED
@@ -83,5 +83,14 @@ module SciolyFF
|
|
83
83
|
.map { |t| t[:number] }
|
84
84
|
assert_nil numbers.uniq!
|
85
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
|
86
95
|
end
|
87
96
|
end
|
data/lib/sciolyff/tournament.rb
CHANGED
@@ -23,6 +23,7 @@ module SciolyFF
|
|
23
23
|
|
24
24
|
def test_does_not_have_extra_info
|
25
25
|
info = Set.new %i[name location level division state year date]
|
26
|
+
info << :'short name'
|
26
27
|
assert Set.new(@tournament.keys).subset? info
|
27
28
|
end
|
28
29
|
|
@@ -31,6 +32,16 @@ module SciolyFF
|
|
31
32
|
assert_instance_of String, @tournament[:name]
|
32
33
|
end
|
33
34
|
|
35
|
+
def test_has_valid_short_name
|
36
|
+
skip unless @tournament.key? :'short name'
|
37
|
+
assert @tournament.key?(:name), 'Cannot have short name without name'
|
38
|
+
assert_instance_of String, @tournament[:'short name']
|
39
|
+
|
40
|
+
skip unless @tournament[:name].instance_of? String
|
41
|
+
assert @tournament[:'short name'].length < @tournament[:name].length,
|
42
|
+
'Length of short name must be shorter than length of name'
|
43
|
+
end
|
44
|
+
|
34
45
|
def test_has_valid_location
|
35
46
|
skip unless @tournament.key? :location
|
36
47
|
assert_instance_of String, @tournament[:location]
|
data/lib/sciolyff.rb
CHANGED
@@ -170,7 +170,36 @@ module SciolyFF
|
|
170
170
|
medal_counts(team_number_a)
|
171
171
|
.zip(medal_counts(team_number_b))
|
172
172
|
.map { |count| count.last - count.first }
|
173
|
+
.find(proc { break_second_tie(team_number_a, team_number_b) },
|
174
|
+
&:nonzero?)
|
175
|
+
end
|
176
|
+
|
177
|
+
def break_second_tie(team_number_a, team_number_b)
|
178
|
+
cmp = points_from_trial(team_number_a) - points_from_trial(team_number_b)
|
179
|
+
cmp.zero? ? break_third_tie(team_number_a, team_number_b) : cmp
|
180
|
+
end
|
181
|
+
|
182
|
+
def break_third_tie(team_number_a, team_number_b)
|
183
|
+
medal_counts_from_trial(team_number_a)
|
184
|
+
.zip(medal_counts_from_trial(team_number_b))
|
185
|
+
.map { |count| count.last - count.first }
|
173
186
|
.find(proc { team_number_a <=> team_number_b }, &:nonzero?)
|
174
187
|
end
|
188
|
+
|
189
|
+
def points_from_trial(team_number)
|
190
|
+
@placings_by_team[team_number]
|
191
|
+
.values
|
192
|
+
.select { |p| @events_by_name[p[:event]][:trial] }
|
193
|
+
.sum { |p| event_points(team_number, p[:event]) }
|
194
|
+
end
|
195
|
+
|
196
|
+
def medal_counts_from_trial(team_number)
|
197
|
+
(1..(@teams_by_number.count + 2)).map do |m|
|
198
|
+
@events_by_name
|
199
|
+
.values
|
200
|
+
.select { |e| e[:trial] }
|
201
|
+
.count { |e| event_points(team_number, e[:name]) == m }
|
202
|
+
end
|
203
|
+
end
|
175
204
|
end
|
176
205
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sciolyff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Em Zhan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -81,7 +81,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
81
|
requirements:
|
82
82
|
- - ">="
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
84
|
+
version: 2.6.0
|
85
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|