Class: Judges::Pull
Overview
Pull.
- Author
-
Yegor Bugayenko (yegor256@gmail.com)
- Copyright
-
Copyright © 2024 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
-
#initialize(loog) ⇒ Pull
constructor
A new instance of Pull.
- #run(opts, args) ⇒ Object
Constructor Details
#initialize(loog) ⇒ Pull
Returns a new instance of Pull.
34 35 36 |
# File 'lib/judges/commands/pull.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 53 54 55 56 57 |
# File 'lib/judges/commands/pull.rb', line 38 def run(opts, args) raise 'Exactly two arguments required' unless args.size == 2 fb = Factbase.new baza = Judges::Baza.new( opts['host'], opts['port'].to_i, opts['token'], ssl: opts['ssl'], timeout: (opts['timeout'] || 5).to_i, loog: @loog ) name = args[0] elapsed(@loog) do if baza.name_exists?(name) fb.import(baza.pull(wait(baza, baza.recent(name), opts['wait']))) Judges::Impex.new(@loog, args[1]).export(fb) throw :"Pulled #{fb.size} facts by the name '#{name}'" else throw :"There is nothing to pull, the name '#{name}' is absent on the server" end end end |