Class: Judges::Pack

Inherits:
Object show all
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

Instance Method Summary collapse

Constructor Details

#initialize(dir, loog) ⇒ Pack

Returns a new instance of Pack.



36
37
38
39
# File 'lib/judges/pack.rb', line 36

def initialize(dir, loog)
  @dir = dir
  @loog = loog
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



34
35
36
# File 'lib/judges/pack.rb', line 34

def dir
  @dir
end

Instance Method Details

#nameObject

Get the name of the pack.



57
58
59
# File 'lib/judges/pack.rb', line 57

def name
  File.basename(@dir)
end

#run(fbase, options) ⇒ Object

Run it with the given Factbase and environment variables.



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/judges/pack.rb', line 42

def run(fbase, options)
  $fb = fbase
  $judge = File.basename(@dir)
  $options = options
  $loog = @loog
  s = File.join(@dir, script)
  raise "Can't load '#{s}'" unless File.exist?(s)
  begin
    load(s, true)
  ensure
    $fb = $judge = $options = $loog = nil
  end
end

#scriptObject

Get the name of the .rb script in the pack.



62
63
64
# File 'lib/judges/pack.rb', line 62

def script
  File.basename(Dir.glob(File.join(@dir, '*.rb')).first)
end

#testsObject

Return all .yml tests files.



67
68
69
# File 'lib/judges/pack.rb', line 67

def tests
  Dir.glob(File.join(@dir, '*.yml'))
end