sciolyff 0.4.1 → 0.5.1
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 +30 -2
- data/lib/sciolyff/scores.rb +19 -2
- data/lib/sciolyff.rb +13 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1df5842018efc9a43a221327ed3ab70da6b1f7a995a341351f5328445943106c
|
4
|
+
data.tar.gz: 9111707bd2043e8ce33c164913c33b3773f14de12ca281732eb9f53a44b23d99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e18866a3c37f6cc04783f70021f2ce0ffbd139765f0b2be376c3719b2dac3c16a8239fa2235e21ae64c6c9732dc4cff8754e4cba310a1eec26bfbcc800fd8ae1
|
7
|
+
data.tar.gz: 07421bcb80b5605bdcd7e96151f1080ff595ffb39136dbd2331016a4a7aecbaf0d8ee7354182dac014922bdf7e26e3b29af52b270204b1aa8a13f5a58c441540
|
data/bin/sciolyff
CHANGED
data/lib/sciolyff/placings.rb
CHANGED
@@ -21,7 +21,8 @@ module SciolyFF
|
|
21
21
|
|
22
22
|
def test_each_placing_does_not_have_extra_info
|
23
23
|
@placings.select { |p| p.instance_of? Hash }.each do |placing|
|
24
|
-
info = Set.new %i[event team participated disqualified place]
|
24
|
+
info = Set.new %i[event team participated disqualified exempt place]
|
25
|
+
info << :unknown
|
25
26
|
assert Set.new(placing.keys).subset? info
|
26
27
|
end
|
27
28
|
end
|
@@ -62,10 +63,37 @@ module SciolyFF
|
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
66
|
+
def test_each_placing_has_valid_exempt
|
67
|
+
@placings.select { |p| p.instance_of? Hash }.each do |placing|
|
68
|
+
if placing.key? :exempt
|
69
|
+
assert_includes [true, false], placing[:exempt]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_each_placing_has_valid_unknown
|
75
|
+
@placings.select { |p| p.instance_of? Hash }.each do |placing|
|
76
|
+
if placing.key? :unknown
|
77
|
+
assert_includes [true, false], placing[:unknown]
|
78
|
+
if placing[:unknown]
|
79
|
+
skip unless SciolyFF.rep[:Events].instance_of? Array
|
80
|
+
|
81
|
+
event = SciolyFF.rep[:Events].find do |e|
|
82
|
+
e[:name] == placing[:event]
|
83
|
+
end
|
84
|
+
assert event[:trial] || event[:trialed] || event.nil?,
|
85
|
+
'Cannot have unknown place for non-trial/trialed event'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
65
91
|
def test_each_placing_has_valid_place
|
66
92
|
@placings.select { |p| p.instance_of? Hash }.each do |placing|
|
67
93
|
next if placing[:disqualified] == true ||
|
68
|
-
placing.key?(:participated)
|
94
|
+
placing.key?(:participated) ||
|
95
|
+
placing[:unknown] == true ||
|
96
|
+
placing[:exempt] == true
|
69
97
|
|
70
98
|
assert_instance_of Integer, placing[:place]
|
71
99
|
max_place = @placings.count do |p|
|
data/lib/sciolyff/scores.rb
CHANGED
@@ -21,7 +21,7 @@ module SciolyFF
|
|
21
21
|
|
22
22
|
def test_each_score_does_not_have_extra_info
|
23
23
|
@scores.select { |s| s.instance_of? Hash }.each do |score|
|
24
|
-
a = %i[event team participated disqualified score tier]
|
24
|
+
a = %i[event team participated disqualified exempt unknown score tier]
|
25
25
|
a << :'tiebreaker place'
|
26
26
|
info = Set.new a
|
27
27
|
assert Set.new(score.keys).subset? info
|
@@ -64,10 +64,27 @@ module SciolyFF
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
def test_each_score_has_valid_exempt
|
68
|
+
@scores.select { |s| s.instance_of? Hash }.each do |score|
|
69
|
+
if score.key? :exempt
|
70
|
+
assert_includes [true, false], score[:exempt]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_each_score_has_valid_unknown
|
76
|
+
@scores.select { |s| s.instance_of? Hash }.each do |score|
|
77
|
+
if score.key? :unknown
|
78
|
+
assert_includes [true, false], score[:unknown]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
67
83
|
def test_each_score_has_valid_score
|
68
84
|
@scores.select { |s| s.instance_of? Hash }.each do |score|
|
69
85
|
next if score[:disqualified] == true ||
|
70
|
-
score
|
86
|
+
score.key?(:participated) ||
|
87
|
+
placing[:exempt] == true
|
71
88
|
|
72
89
|
assert_kind_of Numeric, score[:score]
|
73
90
|
end
|
data/lib/sciolyff.rb
CHANGED
@@ -55,6 +55,7 @@ module SciolyFF
|
|
55
55
|
def initialize(rep)
|
56
56
|
@rep = rep
|
57
57
|
@exhibition_teams_count = rep[:Teams].count { |t| t[:exhibition] }
|
58
|
+
@exempt_placings_count = rep[:Placings].count { |p| p[:exempt] }
|
58
59
|
@team_points_cache = {}
|
59
60
|
|
60
61
|
@tournament = rep[:Tournament]
|
@@ -75,8 +76,10 @@ module SciolyFF
|
|
75
76
|
placing = @placings_by_event[event_name][team_number]
|
76
77
|
number_of_teams = number_of_competing_teams(event_name)
|
77
78
|
|
78
|
-
if placing[:
|
79
|
+
if placing[:exempt] then 0
|
80
|
+
elsif placing[:disqualified] then number_of_teams + 2
|
79
81
|
elsif placing[:participated] == false then number_of_teams + 1
|
82
|
+
elsif placing[:unknown] then number_of_teams - 1
|
80
83
|
elsif placing[:place].nil? then number_of_teams
|
81
84
|
else calculate_event_points(placing)
|
82
85
|
end
|
@@ -136,11 +139,12 @@ module SciolyFF
|
|
136
139
|
def calculate_event_points(placing)
|
137
140
|
return placing[:place] if simple_placing?(placing)
|
138
141
|
|
139
|
-
# Points is place minus number of exhibition teams with a
|
142
|
+
# Points is place minus number of exhibition and exempt teams with a
|
143
|
+
# better place
|
140
144
|
placing[:place] -
|
141
145
|
@placings_by_event[placing[:event]]
|
142
146
|
.values
|
143
|
-
.select { |p|
|
147
|
+
.select { |p| p[:place] && exhibition_or_exempt_placing?(p) }
|
144
148
|
.count { |p| p[:place] < placing[:place] }
|
145
149
|
end
|
146
150
|
|
@@ -154,7 +158,12 @@ module SciolyFF
|
|
154
158
|
end
|
155
159
|
|
156
160
|
def simple_placing?(placing)
|
157
|
-
@
|
161
|
+
@events_by_name[placing[:event]][:trial] ||
|
162
|
+
(@exhibition_teams_count.zero? && @exempt_placings_count.zero?)
|
163
|
+
end
|
164
|
+
|
165
|
+
def exhibition_or_exempt_placing?(placing)
|
166
|
+
@teams_by_number[placing[:team]][:exhibition] || placing[:exempt]
|
158
167
|
end
|
159
168
|
|
160
169
|
def break_tie(team_number_a, team_number_b)
|
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.
|
4
|
+
version: 0.5.1
|
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-06
|
11
|
+
date: 2019-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|