Class: Judges::Update
Overview
Update.
- Author
-
Yegor Bugayenko (yegor256@gmail.com)
- Copyright
-
Copyright © 2024 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
-
#initialize(loog) ⇒ Update
constructor
A new instance of Update.
- #run(opts, args) ⇒ Object
Constructor Details
#initialize(loog) ⇒ Update
Returns a new instance of Update.
35 36 37 |
# File 'lib/judges/commands/update.rb', line 35 def initialize(loog) @loog = loog end |
Instance Method Details
#run(opts, args) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/judges/commands/update.rb', line 39 def run(opts, args) raise 'Exactly two arguments required' unless args.size == 2 dir = args[0] raise "The directory is absent: #{dir.to_rel}" unless File.exist?(dir) impex = Judges::Impex.new(@loog, args[1]) fb = impex.import(strict: false) = Judges::Options.new(opts['option']) @loog.debug("The following options provided:\n\t#{.to_s.gsub("\n", "\n\t")}") packs = Judges::Packs.new(dir, @loog) c = 0 loop do c += 1 diff = cycle(packs, fb, impex, ) break if diff.zero? if !opts['max-cycles'].nil? && c >= opts['max-cycles'] @loog.info('Too many cycles already, as set by --max-cycles, breaking') break end @loog.info("#{diff} modifications at the cycle ##{c}") end @loog.info("Update finished in #{c} cycles") end |