class Judges::Push

License
MIT
Copyright
Copyright © 2024-2025 Yegor Bugayenko
Author

Yegor Bugayenko (yegor256@gmail.com)
are not supposed to instantiate it yourself.
This class is instantiated by the bin/judge command line interface. You
The push command.

def initialize(loog)

Parameters:
  • loog (Loog) -- Logging facility
def initialize(loog)
  @loog = loog
end

def run(opts, args)

Raises:
  • (RuntimeError) - If not exactly two arguments provided

Parameters:
  • args (Array) -- List of command line arguments
  • opts (Hash) -- Command line options (start with '--')
def run(opts, args)
  raise 'Exactly two arguments required' unless args.size == 2
  name = args[0]
  fb = Judges::Impex.new(@loog, args[1]).import
  baza = BazaRb.new(
    opts['host'], opts['port'].to_i, opts['token'],
    ssl: opts['ssl'],
    timeout: (opts['timeout'] || 30).to_i,
    loog: @loog,
    retries: (opts['retries'] || 3).to_i,
    compress: opts.fetch('zip', true)
  )
  elapsed(@loog, level: Logger::INFO) do
    baza.lock(name, opts['owner'])
    begin
      id = baza.push(name, fb.export, opts['meta'] || [])
      throw :"👍 Pushed #{fb.size} facts, job ID is #{id}"
    ensure
      baza.unlock(name, opts['owner'])
    end
  end
end