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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 613cf2cec8c62733c496ae7d35b9eb6bb5f61bfdbd0de4c639fa4474a99277a0
|
4
|
+
data.tar.gz: 3b29332062927062d7da58bd71a5654205ba8de0beada33afefc2c70c1f9a00c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bf3fa55e11a4856e81b995e2d741e5df2b7bb8eaee9fd1eced89353a9f644cdb500be44cc61c3be96178a1ed59958913623bd47d59831628b62994ffc1a36ea
|
7
|
+
data.tar.gz: 614bd64bfdd779826113d343ff35d7fe906e9fd958ad87e386a1c9daf714cc1d164a0484a248c27205c1285f1a1d395bdddb001903aab7d622e6c880ad0214dd
|
data/bin/sciolyff
CHANGED
@@ -2,11 +2,10 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'optimist'
|
5
|
-
require 'yaml'
|
6
5
|
require 'sciolyff'
|
7
6
|
|
8
7
|
opts = Optimist.options do
|
9
|
-
version 'sciolyff 0.
|
8
|
+
version 'sciolyff 0.9.0'
|
10
9
|
banner <<~STRING
|
11
10
|
Checks if a given file is in the Scioly File Format
|
12
11
|
|
@@ -15,15 +14,13 @@ opts = Optimist.options do
|
|
15
14
|
|
16
15
|
where [options] are:
|
17
16
|
STRING
|
18
|
-
opt :
|
19
|
-
end
|
20
|
-
|
21
|
-
if ARGV.first.nil? || !File.exist?(ARGV.first)
|
22
|
-
puts "Error: file '#{ARGV.first}' not found."
|
23
|
-
puts 'Try --help for help.'
|
24
|
-
exit 1
|
17
|
+
opt :loglevel, 'Log verbosity from 0 to 3', default: 1
|
25
18
|
end
|
26
19
|
|
27
20
|
puts 'More than one file given, ignoring all but first.' if ARGV.length > 1
|
28
21
|
|
29
|
-
SciolyFF.
|
22
|
+
validator = SciolyFF::Validator.new opts[:loglevel]
|
23
|
+
validity = validator.valid? ARGV.first
|
24
|
+
print validator.last_log
|
25
|
+
|
26
|
+
exit validity
|
@@ -10,11 +10,10 @@ module SciolyFF
|
|
10
10
|
@placings = interpreter.placings.select { |p| p.event == self }
|
11
11
|
@placings_by_team =
|
12
12
|
@placings.group_by(&:team).transform_values!(&:first)
|
13
|
-
|
14
|
-
@placings.freeze
|
13
|
+
@raws = @placings.select(&:raw?).map(&:raw).sort
|
15
14
|
end
|
16
15
|
|
17
|
-
attr_reader :placings
|
16
|
+
attr_reader :placings, :raws
|
18
17
|
|
19
18
|
def name
|
20
19
|
@rep[:name]
|
@@ -29,11 +28,11 @@ module SciolyFF
|
|
29
28
|
end
|
30
29
|
|
31
30
|
def high_score_wins?
|
32
|
-
|
31
|
+
!low_score_wins?
|
33
32
|
end
|
34
33
|
|
35
34
|
def low_score_wins?
|
36
|
-
|
35
|
+
@rep[:scoring] == 'low'
|
37
36
|
end
|
38
37
|
|
39
38
|
def placing_for(team)
|
@@ -41,13 +40,26 @@ module SciolyFF
|
|
41
40
|
end
|
42
41
|
|
43
42
|
def maximum_place
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
@maximum_place ||=
|
44
|
+
if tournament.per_event_n?
|
45
|
+
competing_teams_count
|
46
|
+
elsif trial?
|
47
|
+
placings.size
|
48
|
+
else
|
49
|
+
tournament.maximum_place
|
50
|
+
end
|
47
51
|
end
|
48
52
|
|
49
53
|
def maximum_points
|
50
54
|
maximum_place + 2
|
51
55
|
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def competing_teams_count
|
60
|
+
return placings.count { |p| !p.place.nil? } if trial?
|
61
|
+
|
62
|
+
placings.count { |p| !(p.team.exhibition? || p.exempt? || p.place.nil?) }
|
63
|
+
end
|
52
64
|
end
|
53
65
|
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module SciolyFF
|
3
|
+
# Holds helper methods used in template.html.erb
|
4
|
+
class Interpreter::HTML::Helpers
|
5
|
+
def template
|
6
|
+
File.read(File.join(__dir__, 'template.html.erb'))
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_binding(interpreter)
|
10
|
+
i = interpreter
|
11
|
+
binding
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def tournament_title(t_info)
|
17
|
+
return t_info.name if t_info.name
|
18
|
+
|
19
|
+
case t_info.level
|
20
|
+
when 'Nationals'
|
21
|
+
'Science Olympiad National Tournament'
|
22
|
+
when 'States'
|
23
|
+
"#{expand_state_name(t_info.state)} Science Olympiad State Tournament"
|
24
|
+
when 'Regionals'
|
25
|
+
"#{t_info.location} Regional Tournament"
|
26
|
+
when 'Invitational'
|
27
|
+
"#{t_info.location} Invitational"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def tournament_title_short(t_info)
|
32
|
+
case t_info.level
|
33
|
+
when 'Nationals'
|
34
|
+
'National Tournament'
|
35
|
+
when 'States'
|
36
|
+
"#{t_info.state} State Tournament"
|
37
|
+
when 'Regionals', 'Invitational'
|
38
|
+
t_info.short_name
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def acronymize(phrase)
|
43
|
+
phrase.split(' ')
|
44
|
+
.select { |w| /^[[:upper:]]/.match(w) }
|
45
|
+
.map { |w| w[0] }
|
46
|
+
.join
|
47
|
+
end
|
48
|
+
|
49
|
+
def format_school(team)
|
50
|
+
if team.school_abbreviation
|
51
|
+
abbr_school(team.school_abbreviation)
|
52
|
+
else
|
53
|
+
abbr_school(team.school)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def abbr_school(school)
|
58
|
+
school.sub('Elementary School', 'Elementary')
|
59
|
+
.sub('Elementary/Middle School', 'E.M.S.')
|
60
|
+
.sub('Middle School', 'M.S.')
|
61
|
+
.sub('Junior High School', 'J.H.S.')
|
62
|
+
.sub(%r{Middle[ /-]High School}, 'M.H.S')
|
63
|
+
.sub('Junior/Senior High School', 'Jr./Sr. H.S.')
|
64
|
+
.sub('High School', 'H.S.')
|
65
|
+
.sub('Secondary School', 'Secondary')
|
66
|
+
end
|
67
|
+
|
68
|
+
def full_school_name(team)
|
69
|
+
location = if team.city then "(#{team.city}, #{team.state})"
|
70
|
+
else "(#{team.state})"
|
71
|
+
end
|
72
|
+
[team.school, location].join(' ')
|
73
|
+
end
|
74
|
+
|
75
|
+
def full_team_name(team)
|
76
|
+
location = if team.city then "(#{team.city}, #{team.state})"
|
77
|
+
else "(#{team.state})"
|
78
|
+
end
|
79
|
+
[team.school, team.suffix, location].join(' ')
|
80
|
+
end
|
81
|
+
|
82
|
+
def team_attended?(team)
|
83
|
+
team
|
84
|
+
.placings
|
85
|
+
.map(&:participated?)
|
86
|
+
.any?
|
87
|
+
end
|
88
|
+
|
89
|
+
def summary_titles
|
90
|
+
%w[
|
91
|
+
Champion
|
92
|
+
Runner-up
|
93
|
+
Third-place
|
94
|
+
Fourth-place
|
95
|
+
Fifth-place
|
96
|
+
Sixth-place
|
97
|
+
]
|
98
|
+
end
|
99
|
+
|
100
|
+
def sup_tag(placing)
|
101
|
+
exempt = placing.exempt? || placing.dropped_as_part_of_worst_placings?
|
102
|
+
tie = placing.tie? && !placing.points_limited_by_maximum_place?
|
103
|
+
return '' unless tie || exempt
|
104
|
+
|
105
|
+
"<sup>#{'◊' if exempt}#{'*' if tie}</sup>"
|
106
|
+
end
|
107
|
+
|
108
|
+
def placing_notes(placing)
|
109
|
+
place = placing.place
|
110
|
+
points = placing.isolated_points
|
111
|
+
[
|
112
|
+
('trial event' if placing.event.trial?),
|
113
|
+
('trialed event' if placing.event.trialed?),
|
114
|
+
('disqualified' if placing.disqualified?),
|
115
|
+
('did not participate' if placing.did_not_participate?),
|
116
|
+
('participation points only' if placing.participation_only?),
|
117
|
+
('tie' if placing.tie?),
|
118
|
+
('exempt' if placing.exempt?),
|
119
|
+
('points limited' if placing.points_limited_by_maximum_place?),
|
120
|
+
('unknown place' if placing.unknown?),
|
121
|
+
('placed behind exhibition team'\
|
122
|
+
if placing.points_affected_by_exhibition? && place - points == 1),
|
123
|
+
('placed behind exhibition teams'\
|
124
|
+
if placing.points_affected_by_exhibition? && place - points > 1),
|
125
|
+
('dropped'\
|
126
|
+
if placing.dropped_as_part_of_worst_placings?),
|
127
|
+
].compact.join(', ').capitalize
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|