sciolyff 0.5.1 → 0.5.2
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 +40 -18
- data/lib/sciolyff.rb +2 -2
- 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: c122cfd4febace838879f0f46ec1e1890f7983ad05548407a8c4916e6bf2fcb9
|
4
|
+
data.tar.gz: 32742a12ef12038b920d7fd653ffb4619feeb54d1f8c0e0ebb5fd83a8f3364d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e8cf97567888b8c91419f0bae5710146b98b5672e6843f4362aa3d6bfe73bcec4eb1e2eacdd2220c3bba26b3e431d100a9b8766b9de5d55598d71b6e00bf0cc
|
7
|
+
data.tar.gz: de698eeeeae99948b6bff356f255e9f8bcbe253c3c03e7628eb89fb4956ec7f2f7666d92b04f1da3fc0d2d3fc4b5b6042b5b2f4d21fe4dd9a3ab34bb30efeae6
|
data/bin/sciolyff
CHANGED
data/lib/sciolyff/placings.rb
CHANGED
@@ -21,7 +21,7 @@ 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 exempt place]
|
24
|
+
info = Set.new %i[event team participated disqualified exempt place tie]
|
25
25
|
info << :unknown
|
26
26
|
assert Set.new(placing.keys).subset? info
|
27
27
|
end
|
@@ -65,26 +65,45 @@ module SciolyFF
|
|
65
65
|
|
66
66
|
def test_each_placing_has_valid_exempt
|
67
67
|
@placings.select { |p| p.instance_of? Hash }.each do |placing|
|
68
|
-
if placing.key? :exempt
|
69
|
-
|
68
|
+
assert_includes [true, false], placing[:exempt] if placing.key? :exempt
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_each_placing_has_valid_tie
|
73
|
+
@placings.select { |p| p.instance_of? Hash }.each do |placing|
|
74
|
+
next unless placing.key? :tie
|
75
|
+
|
76
|
+
assert_includes [true, false], placing[:tie]
|
77
|
+
next unless placing[:tie]
|
78
|
+
|
79
|
+
has_pair = @placings.find do |p_other|
|
80
|
+
p_other.instance_of?(Hash) &&
|
81
|
+
p_other != placing &&
|
82
|
+
p_other[:event] == placing[:event] &&
|
83
|
+
p_other[:event] == placing[:event] &&
|
84
|
+
p_other[:place] == placing[:place] &&
|
85
|
+
p_other[:tie]
|
70
86
|
end
|
87
|
+
assert has_pair,
|
88
|
+
"The event #{placing[:event]} has unpaired ties at "\
|
89
|
+
"#{placing[:place]}"
|
71
90
|
end
|
72
91
|
end
|
73
92
|
|
74
93
|
def test_each_placing_has_valid_unknown
|
75
94
|
@placings.select { |p| p.instance_of? Hash }.each do |placing|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
'Cannot have unknown place for non-trial/trialed event'
|
86
|
-
end
|
95
|
+
next unless placing.key? :unknown
|
96
|
+
|
97
|
+
assert_includes [true, false], placing[:unknown]
|
98
|
+
next unless placing[:unknown]
|
99
|
+
|
100
|
+
skip unless SciolyFF.rep[:Events].instance_of? Array
|
101
|
+
|
102
|
+
event = SciolyFF.rep[:Events].find do |e|
|
103
|
+
e[:name] == placing[:event]
|
87
104
|
end
|
105
|
+
assert event[:trial] || event[:trialed] || event.nil?,
|
106
|
+
'Cannot have unknown place for non-trial/trialed event'
|
88
107
|
end
|
89
108
|
end
|
90
109
|
|
@@ -98,11 +117,12 @@ module SciolyFF
|
|
98
117
|
assert_instance_of Integer, placing[:place]
|
99
118
|
max_place = @placings.count do |p|
|
100
119
|
p[:event] == placing[:event] &&
|
101
|
-
|
102
|
-
|
120
|
+
!p[:disqualified] &&
|
121
|
+
p[:participated] != false
|
103
122
|
end
|
104
123
|
assert_includes 1..max_place, placing[:place],
|
105
|
-
|
124
|
+
"The event #{placing[:event]} "\
|
125
|
+
'has an out-of-range placing'
|
106
126
|
end
|
107
127
|
end
|
108
128
|
|
@@ -113,6 +133,7 @@ module SciolyFF
|
|
113
133
|
next unless event.instance_of? Hash
|
114
134
|
|
115
135
|
places = @placings.select { |p| p[:event] == event[:name] }
|
136
|
+
.reject { |p| p[:tie] }
|
116
137
|
.map { |p| p[:place] }
|
117
138
|
.compact
|
118
139
|
|
@@ -120,7 +141,8 @@ module SciolyFF
|
|
120
141
|
places.index(p) != i
|
121
142
|
end
|
122
143
|
|
123
|
-
assert_empty dups,
|
144
|
+
assert_empty dups,
|
145
|
+
"The event #{event[:name]} has unmarked ties at #{dups}"
|
124
146
|
end
|
125
147
|
end
|
126
148
|
|
data/lib/sciolyff.rb
CHANGED
@@ -76,8 +76,7 @@ module SciolyFF
|
|
76
76
|
placing = @placings_by_event[event_name][team_number]
|
77
77
|
number_of_teams = number_of_competing_teams(event_name)
|
78
78
|
|
79
|
-
if placing[:
|
80
|
-
elsif placing[:disqualified] then number_of_teams + 2
|
79
|
+
if placing[:disqualified] then number_of_teams + 2
|
81
80
|
elsif placing[:participated] == false then number_of_teams + 1
|
82
81
|
elsif placing[:unknown] then number_of_teams - 1
|
83
82
|
elsif placing[:place].nil? then number_of_teams
|
@@ -153,6 +152,7 @@ module SciolyFF
|
|
153
152
|
.values
|
154
153
|
.reject { |p| @events_by_name[p[:event]][:trial] }
|
155
154
|
.reject { |p| @events_by_name[p[:event]][:trialed] }
|
155
|
+
.reject { |p| p[:exempt] }
|
156
156
|
.sum { |p| event_points(team_number, p[:event]) } \
|
157
157
|
+ team_points_from_penalties(team_number)
|
158
158
|
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.2
|
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-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|