lib/roku_builder/monitor.rb in roku_builder-3.3.2 vs lib/roku_builder/monitor.rb in roku_builder-3.3.3

- old
+ new

@@ -33,18 +33,11 @@ connection = Net::Telnet.new(telnet_config) Thread.current[:connection] = connection all_text = "" while true connection.waitfor(waitfor_config) do |txt| - all_text += txt - while line = all_text.slice!(/^.*\n/) do - puts line - end - if all_text == "BrightScript Debugger> " - print all_text - all_text = "" - end + all_text = manage_text(all_text: all_text, txt: txt) end end } running = true while running @@ -55,8 +48,26 @@ running = false else thread[:connection].puts(command) end end + end + + private + + # Handel text from telnet + # @param all_text [String] remaining partial line text + # @param txt [String] current string from telnet + # @return [String] remaining partial line text + def manage_text(all_text:, txt:) + all_text += txt + while line = all_text.slice!(/^.*\n/) do + puts line + end + if all_text == "BrightScript Debugger> " + print all_text + all_text = "" + end + all_text end end end