我正在使用紅寶石遊戲服務器,在測試過程中,我無法單獨測試組件。我沒有從我的啓動器,只有服務器獲得輸出,所以我評論了服務器的初始化 - 但eclipse仍然顯示服務器的輸出!Ruby require_relative執行腳本?
然後我去了命令行,假設eclipse正在查看錯誤的文件(git之前已經搞混了,但正如您所看到的,堆棧跟蹤顯示Server.rb
正在從第5行開始全部執行: require_relative 'Server'
:
這是該文件的文本內容:
class Launcher
puts "File saved at #{File.mtime($0)}"
require_relative 'Server'
require_relative 'Game'
#STDOUT.sync = true
puts "Launcher started"
#server = Server.new
print "server made"
game = Game.new
#serverThread = Thread.new{server.start()}
gameThread = Thread.new{game.start()}
while (running)
print "Stop? "
input = gets.chomp
if (input.equals?("yes"))
running = false
end
end
server.stop
game.stop
gameThread.join
serverThread.join
end
和終端輸出:
C:\Users\gossfunkel\git\citadelserver\RubyCitadelServer>ruby Launcher.rb
File saved at 2013-06-22 18:16:44 +0100
Server starting up at 2013-06-22 18:16:47 +0100...
C:/Users/gossfunkel/git/citadelserver/RubyCitadelServer/Server.rb:20:in `recvfro
m': Interrupt
from C:/Users/gossfunkel/git/citadelserver/RubyCitadelServer/Server.rb:2
0:in `run'
from C:/Users/gossfunkel/git/citadelserver/RubyCitadelServer/Server.rb:1
5:in `start'
from C:/Users/gossfunkel/git/citadelserver/RubyCitadelServer/Server.rb:3
0:in `<class:Server>'
from C:/Users/gossfunkel/git/citadelserver/RubyCitadelServer/Server.rb:1
:in `<top (required)>'
from Launcher.rb:5:in `require_relative'
from Launcher.rb:5:in `<class:Launcher>'
from Launcher.rb:1:in `<main>'
如何在不發生這種情況的情況下需要文件?
請發佈文字,而不是截圖。圖像不可讀取,無法放大,也不能複製粘貼。 – Borodin
對不起,假設圖像會更大。我似乎無法從cmd複製粘貼,但我已經把啓動器代碼。 – gossfunkel
啊,你在Windows上。爲了將來的參考,從'cmd'窗口複製,右鍵單擊它的任何地方;從上下文菜單中選擇「標記」;用你的鼠標指針拖動一個矩形;按下鍵盤上的'return'。現在它在剪貼板上。您可能需要將其粘貼到編輯器中並整理它。 – Borodin