Class: Judges::Push

Inherits:
Object show all
Defined in:
lib/judges/commands/push.rb

Overview

Push.

Author

Yegor Bugayenko (yegor256@gmail.com)

Copyright

Copyright © 2024 Yegor Bugayenko

License

MIT

Instance Method Summary collapse

Constructor Details

#initialize(loog) ⇒ Push

Returns a new instance of Push.



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

def initialize(loog)
  @loog = loog
end

Instance Method Details

#run(opts, args) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/judges/commands/push.rb', line 38

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 = Judges::Baza.new(
    opts['host'], opts['port'].to_i, opts['token'],
    ssl: opts['ssl'],
    timeout: (opts['timeout'] || 5).to_i,
    loog: @loog
  )
  elapsed(@loog) do
    id = baza.push(name, fb.export)
    throw :"Pushed #{fb.size} facts, job ID is #{id}"
  end
end