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.
36 37 38 |
# File 'lib/judges/commands/update.rb', line 36 def initialize(loog) @loog = loog end |
Instance Method Details
#run(opts, args) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/judges/commands/update.rb', line 40 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) fb = Factbase::Looged.new(fb, @loog) = Judges::Options.new(opts['option']) @loog.debug("The following options provided:\n\t#{.to_s.gsub("\n", "\n\t")}") packs = Judges::Packs.new(dir, opts['lib'], @loog) c = 0 start = Time.now loop do c += 1 diff = cycle(opts, packs, fb, ) impex.export(fb) 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( "By #{diff} facts the factbase " \ "#{diff.positive? ? 'increased' : 'decreased'} " \ "its size at the cycle ##{c}" ) end @loog.info("Update finished: #{c} cycles in #{format('%.02f', Time.now - start)}s") end |