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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c122cfd4febace838879f0f46ec1e1890f7983ad05548407a8c4916e6bf2fcb9
4
- data.tar.gz: 32742a12ef12038b920d7fd653ffb4619feeb54d1f8c0e0ebb5fd83a8f3364d4
3
+ metadata.gz: 9d439db52050ce2e14cdefb6e5d2520d1105dbea5dbe49a4cf5a5e83323a30bd
4
+ data.tar.gz: 1f6611b0af9696973430b849c5241a61ef9d23fa254db9cba12b4b08d3c8647d
5
5
  SHA512:
6
- metadata.gz: 7e8cf97567888b8c91419f0bae5710146b98b5672e6843f4362aa3d6bfe73bcec4eb1e2eacdd2220c3bba26b3e431d100a9b8766b9de5d55598d71b6e00bf0cc
7
- data.tar.gz: de698eeeeae99948b6bff356f255e9f8bcbe253c3c03e7628eb89fb4956ec7f2f7666d92b04f1da3fc0d2d3fc4b5b6042b5b2f4d21fe4dd9a3ab34bb30efeae6
6
+ metadata.gz: 2901fb2fdb8e8e7aa26e9cc97cd1c2c0989d1cc18233f1cd9b038c724dae54530b64be62d812abc03a753f92bed46763df2d487a7b377471d9559bfc809049d9
7
+ data.tar.gz: 61b9fca3f88e142116e211cf576b6751d98e99ba7a464433a96af2ec401b9f6a71acf4879ea247f6612965a65e5672b81264790e812cfb8006252e128190879c
data/bin/sciolyff CHANGED
@@ -6,7 +6,7 @@ require 'yaml'
6
6
  require 'sciolyff'
7
7
 
8
8
  opts = Optimist.options do
9
- version 'sciolyff 0.5.2'
9
+ version 'sciolyff 0.5.3'
10
10
  banner <<~STRING
11
11
  Checks if a given file is in the Scioly File Format
12
12
 
@@ -76,15 +76,14 @@ module SciolyFF
76
76
  assert_includes [true, false], placing[:tie]
77
77
  next unless placing[:tie]
78
78
 
79
- has_pair = @placings.find do |p_other|
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[:event] == placing[:event] &&
84
- p_other[:place] == placing[:place] &&
85
- p_other[:tie]
86
- end
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
@@ -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
@@ -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.2
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-10 00:00:00.000000000 Z
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: '0'
84
+ version: 2.6.0
85
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="