lib/netsoul/client.rb in netsoul-2.3.0 vs lib/netsoul/client.rb in netsoul-2.3.1

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: false + require_relative '../netsoul' require 'socket' module Netsoul class Client @@ -14,21 +16,22 @@ @started = false end def auth_ag send(Message.auth_ag) - fail Netsoul::IdentificationError, 'Identification failed.'.freeze unless get.split(' ')[1] == '002'.freeze + fail Netsoul::IdentificationError, 'Identification failed.'.freeze unless get.split(' '.freeze)[1] == '002'.freeze end private :auth_ag def auth_method if @config.auth_method == :krb5 send(Message.kerberos_auth(@config)) else send(Message.standard_auth(@config)) end - fail Netsoul::AuthenticationError, 'Authentication failed. See your config file or environment variables'.freeze unless get.split(' ')[1] == '002' + fail Netsoul::AuthenticationError, 'Authentication failed. See your config file or environment variables'.freeze \ + unless get.split(' '.freeze)[1] == '002'.freeze end private :auth_method def auth_status send(Message.attach) @@ -56,27 +59,27 @@ close end def send(str) _, sock = IO.select(nil, [@socket], nil, SOCKET_WRITE_TIMEOUT) - fail Netsoul::SocketError, 'Timeout or fail on write socket' if sock.nil? || sock.empty? + fail Netsoul::SocketError, 'Timeout or fail on write socket'.freeze if sock.nil? || sock.empty? s = sock.first if s s.puts str s.flush end log :info, "[send] #{str.chomp}" end def get sock, = IO.select([@socket], nil, nil, SOCKET_READ_TIMEOUT) - fail Netsoul::SocketError, 'Timeout or fail on read socket' if sock.nil? || sock.empty? + fail Netsoul::SocketError, 'Timeout or fail on read socket'.freeze if sock.nil? || sock.empty? res = sock.first.gets if res log :info, "[get ] #{res.chomp}" res else - 'nothing' # Send some string and permit IO.select to thrown exception if something goes wrong. + 'nothing'.freeze # Send some string and permit IO.select to thrown exception if something goes wrong. end end def close @started = false