Class: Minitest::Reporters::Ws::Client
- Inherits:
-
Object
- Object
- Minitest::Reporters::Ws::Client
- Defined in:
- lib/minitest/reporters/ws/client.rb
Constant Summary collapse
- DEFAULT_CONFIG =
{ 'host' => "localhost", 'port' => "10081" }
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#no_server ⇒ Object
Returns the value of attribute no_server.
-
#port ⇒ Object
Returns the value of attribute port.
-
#socket ⇒ Object
Returns the value of attribute socket.
Instance Method Summary collapse
- #close ⇒ Object
- #connected? ⇒ Boolean
- #identify ⇒ Object
-
#initialize(opts = {}) ⇒ Client
constructor
A new instance of Client.
- #send_msg(data) ⇒ Object
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. end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
7 8 9 |
# File 'lib/minitest/reporters/ws/client.rb', line 7 def host @host end |
#no_server ⇒ Object
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 |
#port ⇒ Object
Returns the value of attribute port.
7 8 9 |
# File 'lib/minitest/reporters/ws/client.rb', line 7 def port @port end |
#socket ⇒ Object
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
#close ⇒ Object
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
38 39 40 |
# File 'lib/minitest/reporters/ws/client.rb', line 38 def connected? !!socket end |
#identify ⇒ Object
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 |