Class: Minitest::Reporters::Ws::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/reporters/ws/client.rb

Constant Summary collapse

DEFAULT_CONFIG =
{ 'host' => "localhost", 'port' => "10081" }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
# 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

Instance Attribute Details

#hostObject

Returns the value of attribute host.



7
8
9
# File 'lib/minitest/reporters/ws/client.rb', line 7

def host
  @host
end

#no_serverObject

Returns the value of attribute no_server.



5
6
7
# File 'lib/minitest/reporters/ws/client.rb', line 5

def no_server
  @no_server
end

#portObject

Returns the value of attribute port.



7
8
9
# File 'lib/minitest/reporters/ws/client.rb', line 7

def port
  @port
end

#socketObject

Returns the value of attribute socket.



6
7
8
# File 'lib/minitest/reporters/ws/client.rb', line 6

def socket
  @socket
end

Instance Method Details

#closeObject



29
30
31
32
33
34
35
36
# 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?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/minitest/reporters/ws/client.rb', line 38

def connected?
  !!socket
end

#identifyObject



16
17
18
19
20
21
# 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) ⇒ Object



23
24
25
26
27
# 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