sciolyff-duosmium 0.13.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 +7 -0
- data/LICENSE +21 -0
- data/README.md +92 -0
- data/bin/sciolyff +38 -0
- data/lib/sciolyff.rb +9 -0
- data/lib/sciolyff/interpreter.rb +89 -0
- data/lib/sciolyff/interpreter/bids.rb +24 -0
- data/lib/sciolyff/interpreter/event.rb +69 -0
- data/lib/sciolyff/interpreter/html.rb +65 -0
- data/lib/sciolyff/interpreter/html/helpers.rb +230 -0
- data/lib/sciolyff/interpreter/html/main.css +1 -0
- data/lib/sciolyff/interpreter/html/main.js +74 -0
- data/lib/sciolyff/interpreter/html/template.html.erb +480 -0
- data/lib/sciolyff/interpreter/model.rb +29 -0
- data/lib/sciolyff/interpreter/penalty.rb +19 -0
- data/lib/sciolyff/interpreter/placing.rb +127 -0
- data/lib/sciolyff/interpreter/raw.rb +50 -0
- data/lib/sciolyff/interpreter/subdivisions.rb +72 -0
- data/lib/sciolyff/interpreter/team.rb +111 -0
- data/lib/sciolyff/interpreter/tiebreaks.rb +34 -0
- data/lib/sciolyff/interpreter/tournament.rb +194 -0
- data/lib/sciolyff/validator.rb +89 -0
- data/lib/sciolyff/validator/canonical.rb +23 -0
- data/lib/sciolyff/validator/checker.rb +33 -0
- data/lib/sciolyff/validator/events.rb +106 -0
- data/lib/sciolyff/validator/logger.rb +48 -0
- data/lib/sciolyff/validator/penalties.rb +19 -0
- data/lib/sciolyff/validator/placings.rb +136 -0
- data/lib/sciolyff/validator/range.rb +15 -0
- data/lib/sciolyff/validator/raws.rb +40 -0
- data/lib/sciolyff/validator/sections.rb +56 -0
- data/lib/sciolyff/validator/subdivisions.rb +64 -0
- data/lib/sciolyff/validator/teams.rb +108 -0
- data/lib/sciolyff/validator/top_level.rb +23 -0
- data/lib/sciolyff/validator/tournament.rb +138 -0
- data/sciolyff.gemspec +22 -0
- metadata +121 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sciolyff/validator/checker'
|
4
|
+
require 'sciolyff/validator/sections'
|
5
|
+
|
6
|
+
module SciolyFF
|
7
|
+
# Top-level sections of a SciolyFF file
|
8
|
+
class Validator::TopLevel < Validator::Checker
|
9
|
+
include Validator::Sections
|
10
|
+
|
11
|
+
REQUIRED = {
|
12
|
+
Tournament: Hash,
|
13
|
+
Events: Array,
|
14
|
+
Teams: Array,
|
15
|
+
Placings: Array
|
16
|
+
}.freeze
|
17
|
+
|
18
|
+
OPTIONAL = {
|
19
|
+
Subdivisions: Array,
|
20
|
+
Penalties: Array
|
21
|
+
}.freeze
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sciolyff/validator/checker'
|
4
|
+
require 'sciolyff/validator/sections'
|
5
|
+
require 'sciolyff/validator/range'
|
6
|
+
|
7
|
+
module SciolyFF
|
8
|
+
# Checks for Tournament section of a SciolyFF file
|
9
|
+
class Validator::Tournament < Validator::Checker
|
10
|
+
include Validator::Sections
|
11
|
+
|
12
|
+
REQUIRED = {
|
13
|
+
location: String,
|
14
|
+
level: %w[Invitational Regionals States Nationals],
|
15
|
+
division: %w[A B C],
|
16
|
+
year: Integer
|
17
|
+
}.freeze
|
18
|
+
|
19
|
+
OPTIONAL = {
|
20
|
+
name: String,
|
21
|
+
state: String,
|
22
|
+
medals: Integer,
|
23
|
+
trophies: Integer,
|
24
|
+
bids: Integer,
|
25
|
+
'bids per school': Integer,
|
26
|
+
'short name': String,
|
27
|
+
'worst placings dropped': Integer,
|
28
|
+
'exempt placings': Integer,
|
29
|
+
'maximum place': Integer,
|
30
|
+
'per-event n': %w[place participation],
|
31
|
+
'n offset': Integer,
|
32
|
+
date: Date,
|
33
|
+
'start date': Date,
|
34
|
+
'end date': Date,
|
35
|
+
'awards date': Date
|
36
|
+
}.freeze
|
37
|
+
|
38
|
+
def initialize(rep)
|
39
|
+
@maximum_place = rep[:Teams].count { |t| !t[:exhibition] }
|
40
|
+
@schools_count = rep[:Teams].uniq do |t|
|
41
|
+
[t[:school], t[:city], t[:state]]
|
42
|
+
end.count
|
43
|
+
end
|
44
|
+
|
45
|
+
def name_for_not_states_or_nationals?(tournament, logger)
|
46
|
+
level = tournament[:level]
|
47
|
+
return true if %w[States Nationals].include?(level) || tournament[:name]
|
48
|
+
|
49
|
+
logger.error 'name for Tournament required '\
|
50
|
+
"('level: #{level}' is not States or Nationals)"
|
51
|
+
end
|
52
|
+
|
53
|
+
def state_for_not_nationals?(tournament, logger)
|
54
|
+
return true if tournament[:level] == 'Nationals' || tournament[:state]
|
55
|
+
|
56
|
+
logger.error 'state for Tournament required '\
|
57
|
+
"('level: #{tournament[:level]}' is not Nationals)"
|
58
|
+
end
|
59
|
+
|
60
|
+
def bids_for_regionals_or_states?(tournament, logger)
|
61
|
+
level = tournament[:level]
|
62
|
+
|
63
|
+
if %w[Regionals States].include?(level)
|
64
|
+
return true if tournament.key? :bids
|
65
|
+
|
66
|
+
logger.warn "field 'bids:' recommended for level: #{level}"
|
67
|
+
else
|
68
|
+
return true unless tournament.key? :bids
|
69
|
+
|
70
|
+
logger.error "bids: does not make sense for level: #{level}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def bids_per_school_positive?(tournament, logger)
|
75
|
+
bids = tournament[:'bids per school']
|
76
|
+
return true if bids.nil? || tournament[:'bids per school'].positive?
|
77
|
+
|
78
|
+
logger.error "'bids per school: #{bids}' is not positive"
|
79
|
+
end
|
80
|
+
|
81
|
+
def bids_per_school_relevant?(tournament, logger)
|
82
|
+
return true unless tournament[:'bids per school'] &&
|
83
|
+
!tournament.key?(:bids)
|
84
|
+
|
85
|
+
logger.error "field 'bids per school:' not relevant without field 'bids:'"
|
86
|
+
end
|
87
|
+
|
88
|
+
def short_name_is_relevant?(tournament, logger)
|
89
|
+
return true unless tournament[:'short name'] && !tournament[:name]
|
90
|
+
|
91
|
+
logger.error "'short name: #{tournament[:'short name']}' for Tournament "\
|
92
|
+
"requires a normal 'name:' as well"
|
93
|
+
end
|
94
|
+
|
95
|
+
def short_name_is_short?(tournament, logger)
|
96
|
+
return true if tournament[:'short name'].nil? ||
|
97
|
+
tournament[:'short name'].length < tournament[:name].length
|
98
|
+
|
99
|
+
logger.error "'short name: #{tournament[:'short name']}' for Tournament "\
|
100
|
+
"is longer than normal 'name: #{tournament[:name]}'"
|
101
|
+
end
|
102
|
+
|
103
|
+
include Validator::Range
|
104
|
+
|
105
|
+
def n_offset_within_range?(tournament, logger)
|
106
|
+
# not a perfect check, can still have event maximum place be lower
|
107
|
+
# probably should add warning for use of n offset anyways?
|
108
|
+
min = -[@maximum_place, tournament[:'maximum place']].compact.min
|
109
|
+
within_range?(tournament, :'n offset', logger, min, Float::INFINITY)
|
110
|
+
end
|
111
|
+
|
112
|
+
def maximum_place_within_range?(tournament, logger)
|
113
|
+
within_range?(tournament, :'maximum place', logger, 1, @maximum_place)
|
114
|
+
end
|
115
|
+
|
116
|
+
def medals_within_range?(tournament, logger)
|
117
|
+
max = [@maximum_place, tournament[:'maximum place']].compact.min
|
118
|
+
within_range?(tournament, :medals, logger, 1, max)
|
119
|
+
end
|
120
|
+
|
121
|
+
def trophies_within_range?(tournament, logger)
|
122
|
+
within_range?(tournament, :trophies, logger, 1, @maximum_place)
|
123
|
+
end
|
124
|
+
|
125
|
+
def bids_within_range?(tournament, logger)
|
126
|
+
within_range?(tournament, :bids, logger, 1, @schools_count)
|
127
|
+
end
|
128
|
+
|
129
|
+
def date_included?(tournament, logger)
|
130
|
+
if !tournament[:date].is_a?(Date) || (!tournament[:'start date'].is_a?(Date) && !tournament[:'end date'].is_a?(Date))
|
131
|
+
return true
|
132
|
+
end
|
133
|
+
|
134
|
+
logger.error 'You need either a date for the tournament (if it took place in one day) '\
|
135
|
+
'or beginning and end dates (if it took place over the course of multiple days).'
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
data/sciolyff.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.authors = ['Em Zhan', 'Shreyas Mayya']
|
5
|
+
s.homepage = 'https://github.com/duosmium/sciolyff'
|
6
|
+
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
7
|
+
f.start_with? 'examples/', '.'
|
8
|
+
end
|
9
|
+
s.license = 'MIT'
|
10
|
+
s.name = 'sciolyff-duosmium'
|
11
|
+
s.summary = 'A file format for Science Olympiad tournament results.'
|
12
|
+
s.version = '0.13.0'
|
13
|
+
s.executables << 'sciolyff'
|
14
|
+
s.add_runtime_dependency 'erubi', '~> 1.9'
|
15
|
+
s.add_runtime_dependency 'optimist', '~> 3.0'
|
16
|
+
if Gem.win_platform?
|
17
|
+
s.required_ruby_version = '>= 2.6'
|
18
|
+
else
|
19
|
+
s.add_runtime_dependency 'psych', '~> 3.1'
|
20
|
+
s.required_ruby_version = '>= 2.5'
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sciolyff-duosmium
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.13.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Em Zhan
|
8
|
+
- Shreyas Mayya
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2020-12-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: erubi
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.9'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.9'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: optimist
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '3.0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '3.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: psych
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3.1'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '3.1'
|
56
|
+
description:
|
57
|
+
email:
|
58
|
+
executables:
|
59
|
+
- sciolyff
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- LICENSE
|
64
|
+
- README.md
|
65
|
+
- bin/sciolyff
|
66
|
+
- lib/sciolyff.rb
|
67
|
+
- lib/sciolyff/interpreter.rb
|
68
|
+
- lib/sciolyff/interpreter/bids.rb
|
69
|
+
- lib/sciolyff/interpreter/event.rb
|
70
|
+
- lib/sciolyff/interpreter/html.rb
|
71
|
+
- lib/sciolyff/interpreter/html/helpers.rb
|
72
|
+
- lib/sciolyff/interpreter/html/main.css
|
73
|
+
- lib/sciolyff/interpreter/html/main.js
|
74
|
+
- lib/sciolyff/interpreter/html/template.html.erb
|
75
|
+
- lib/sciolyff/interpreter/model.rb
|
76
|
+
- lib/sciolyff/interpreter/penalty.rb
|
77
|
+
- lib/sciolyff/interpreter/placing.rb
|
78
|
+
- lib/sciolyff/interpreter/raw.rb
|
79
|
+
- lib/sciolyff/interpreter/subdivisions.rb
|
80
|
+
- lib/sciolyff/interpreter/team.rb
|
81
|
+
- lib/sciolyff/interpreter/tiebreaks.rb
|
82
|
+
- lib/sciolyff/interpreter/tournament.rb
|
83
|
+
- lib/sciolyff/validator.rb
|
84
|
+
- lib/sciolyff/validator/canonical.rb
|
85
|
+
- lib/sciolyff/validator/checker.rb
|
86
|
+
- lib/sciolyff/validator/events.rb
|
87
|
+
- lib/sciolyff/validator/logger.rb
|
88
|
+
- lib/sciolyff/validator/penalties.rb
|
89
|
+
- lib/sciolyff/validator/placings.rb
|
90
|
+
- lib/sciolyff/validator/range.rb
|
91
|
+
- lib/sciolyff/validator/raws.rb
|
92
|
+
- lib/sciolyff/validator/sections.rb
|
93
|
+
- lib/sciolyff/validator/subdivisions.rb
|
94
|
+
- lib/sciolyff/validator/teams.rb
|
95
|
+
- lib/sciolyff/validator/top_level.rb
|
96
|
+
- lib/sciolyff/validator/tournament.rb
|
97
|
+
- sciolyff.gemspec
|
98
|
+
homepage: https://github.com/duosmium/sciolyff
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
metadata: {}
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.5'
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubygems_version: 3.1.4
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: A file format for Science Olympiad tournament results.
|
121
|
+
test_files: []
|