class Minitest::Reporters::Ws::Client
Constants
- DEFAULT_CONFIG
Attributes
host[RW]
no_server[RW]
port[RW]
socket[RW]
Public Class Methods
new(opts = {})
click to toggle source
# File lib/minitest/reporters/ws/client.rb, line 9 def initialize(opts = {}) init_config(opts.delete(:yml), opts.delete(:config), opts.delete(:env)) init_socket rescue => ex puts ex.message end
Public Instance Methods
close()
click to toggle source
# File lib/minitest/reporters/ws/client.rb, line 29 def close # hmmm, i want to leave the connection open data = { receiver: "server", method: "disconnect", arguments: ["rspec"] } @socket.send(data.to_json) if connected? @socket.close if connected? #rescue => ex # puts ex.message end
connected?()
click to toggle source
# File lib/minitest/reporters/ws/client.rb, line 38 def connected? !!socket end
identify()
click to toggle source
# File lib/minitest/reporters/ws/client.rb, line 16 def identify data = { receiver: "server", method: "identify", arguments: ["rspec"] } @socket.send(data.to_json) if connected? #rescue => ex # puts ex.message end
send_msg(data)
click to toggle source
# File lib/minitest/reporters/ws/client.rb, line 23 def send_msg(data) @socket.send(data.to_json) if connected? #rescue => ex # puts ex.message end
Private Instance Methods
init_config(file, conf, env = 'test')
click to toggle source
# File lib/minitest/reporters/ws/client.rb, line 54 def init_config(file, conf, env = 'test') config = conf config = read_conf(file, env) if file config ||= DEFAULT_CONFIG @host = config['host'] @port = config['port'].to_i end
init_socket()
click to toggle source
# File lib/minitest/reporters/ws/client.rb, line 44 def init_socket @timestamp = Time.now.to_i @socket = begin WebSocket.new("ws://localhost:10081") #rescue => ex # puts ex.message # nil end end
read_conf(filename, env)
click to toggle source
# File lib/minitest/reporters/ws/client.rb, line 63 def read_conf(filename, env) YAML::load(File.open(filename))[env] end