ruby-nsca/test/dummy_server.rb

17 lines
371 B
Ruby
Raw Normal View History

require 'pathname'
$: << Pathname.new( __FILE__).dirname.join( '..', 'lib').to_s
module NSCA
def self.dummy_server *args
Dir[ Pathname.new( __FILE__).dirname.join( '..', 'lib', '**').to_s].each_entry do |l|
load l if /\.rb$/ =~ l
end
serv = NSCA::Server.new *args
sock = serv.accept
sock.fetch
ensure
sock.close if sock
serv.close if serv
end
end