Class: Judges::Pack
- Inherits:
-
Object
- Object
- Judges::Pack
- Defined in:
- lib/judges/pack.rb
Overview
A single pack.
- Author
-
Yegor Bugayenko (yegor256@gmail.com)
- Copyright
-
Copyright © 2024 Yegor Bugayenko
- License
-
MIT
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
Instance Method Summary collapse
-
#initialize(dir, loog) ⇒ Pack
constructor
A new instance of Pack.
-
#run(fbase, options) ⇒ Object
Run it with the given Factbase and environment variables.
-
#script ⇒ Object
Get the name of the .rb script in the pack.
-
#tests ⇒ Object
Iterate over .yml tests.
Constructor Details
#initialize(dir, loog) ⇒ Pack
Returns a new instance of Pack.
35 36 37 38 |
# File 'lib/judges/pack.rb', line 35 def initialize(dir, loog) @dir = dir @loog = loog end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
33 34 35 |
# File 'lib/judges/pack.rb', line 33 def dir @dir end |
Instance Method Details
#run(fbase, options) ⇒ Object
Run it with the given Factbase and environment variables.
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/judges/pack.rb', line 41 def run(fbase, ) $fb = fbase $judge = File.basename(@dir) $options = $loog = @loog s = File.join(@dir, script) raise "Can't load '#{s}'" unless File.exist?(s) begin load s ensure $fb = $judge = $options = $loog = nil end end |
#script ⇒ Object
Get the name of the .rb script in the pack.
56 57 58 |
# File 'lib/judges/pack.rb', line 56 def script File.basename(Dir.glob(File.join(@dir, '*.rb')).first) end |
#tests ⇒ Object
Iterate over .yml tests.
61 62 63 64 65 |
# File 'lib/judges/pack.rb', line 61 def tests Dir.glob(File.join(@dir, '*.yml')).map do |f| YAML.load_file(f, permitted_classes: [Time]) end end |