Use Tox::Client#run to event loop
This commit is contained in:
parent
b0aae52682
commit
7c07f1ff83
2 changed files with 13 additions and 9 deletions
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'bundler/setup'
|
||||
|
||||
lib = File.expand_path('../lib', __dir__).freeze
|
||||
$LOAD_PATH.unshift lib unless $LOAD_PATH.include? lib
|
||||
|
||||
|
|
20
lib/main.rb
20
lib/main.rb
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'tox'
|
||||
|
||||
require 'thread'
|
||||
|
||||
require 'faker'
|
||||
|
@ -24,19 +26,19 @@ private
|
|||
|
||||
def call
|
||||
before_loop
|
||||
loop do
|
||||
before_iteration
|
||||
sleep
|
||||
after_iteration
|
||||
end
|
||||
before_iteration
|
||||
@tox_client.run
|
||||
after_loop
|
||||
end
|
||||
|
||||
def sleep
|
||||
super 0.01
|
||||
end
|
||||
|
||||
def before_loop
|
||||
@tox_client = Tox::Client.new
|
||||
|
||||
@tox_client.on_iteration do
|
||||
after_iteration
|
||||
before_iteration
|
||||
end
|
||||
|
||||
@screen = Screen.new
|
||||
Style.default = Style.new
|
||||
end
|
||||
|
|
Reference in a new issue