em-simple_telnet 0.0.15 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/em-simple_telnet.rb +13 -14
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aac1cbb2de2d9e9285a27c2e36f9c255e00f6c13
4
- data.tar.gz: 2491898f33c8cf1933ca7389296fb50d6d977b5c
3
+ metadata.gz: a3a87aad1b79cbd0d9d345286f057f9645b762ed
4
+ data.tar.gz: 1afc5e5953809b6ba526672a07ad778b600419dd
5
5
  SHA512:
6
- metadata.gz: fa352be4b89435b9c8f2ae773c80dab83a1f6ffba98175c147d9adbaf0eac5497f67418806f5b26bf155c84b702e08effabf763891664974ea95fafe2bae3cf9
7
- data.tar.gz: 73b705b35ad35d862000dd2218c4c968ab1200997cce3698cc11c1b4a505d5d79570a0ae5de777846e72ec3e6ccf98dab9a63aa2d6274dcd69c0ae23d1c6f780
6
+ metadata.gz: 43f09ceba50d39a511a8a800b9a143bc16b42b504a4f327ad4a5aa744e5d91587df422dad994f579f60111be7db8ba7d4146f99affe6f25d1f95be5d28556e1a
7
+ data.tar.gz: 45480727c86fc53583f24f96112b6f7d3cf02c79552ba5abdf9f8528c317d29c7f59a150dc287db4925d8d85e5b83a2d93efdfa68b73cc45724c5046bcc21dd9
@@ -521,7 +521,7 @@ class Protocols::SimpleTelnet < Connection
521
521
  # #log_output. Then calls #process_payload.
522
522
  #
523
523
  def receive_data data
524
- @recently_received_data << data if logger.debug?
524
+ @recently_received_data << data if log_recently_received_data?
525
525
  if @telnet_options[:telnet_mode]
526
526
  c = @input_rest + data
527
527
  se_pos = c.rindex(/#{IAC}#{SE}/no) || 0
@@ -673,7 +673,8 @@ class Protocols::SimpleTelnet < Connection
673
673
  #
674
674
  def waitfor prompt=nil, opts={}
675
675
  if closed?
676
- abort "Can't wait for anything when connection is already closed!"
676
+ raise Errno::ENOTCONN,
677
+ "Can't wait for anything when connection is already closed!"
677
678
  end
678
679
  options_were = @telnet_options
679
680
  timeout_was = self.timeout if opts.key?(:timeout)
@@ -756,9 +757,8 @@ class Protocols::SimpleTelnet < Connection
756
757
  raise Errno::ENOTCONN,
757
758
  "Can't send data: Connection is already closed." if closed?
758
759
  @last_sent_data = Time.now
759
- log_recently_received_data if logger.debug?
760
+ log_recently_received_data
760
761
  logger.debug "#{node}: Sending #{s.inspect}"
761
- log_output(s)
762
762
  super
763
763
  end
764
764
 
@@ -933,7 +933,7 @@ class Protocols::SimpleTelnet < Connection
933
933
  def unbind(reason)
934
934
  prev_conn_state = @connection_state
935
935
  self.connection_state = :closed
936
- logger.debug "#{node}: Unbinding because of: " + reason.inspect
936
+ logger.debug "#{node}: Unbind reason: " + reason.inspect
937
937
  @@_telnet_connection_count -= 1
938
938
  close_logs
939
939
 
@@ -999,23 +999,22 @@ class Protocols::SimpleTelnet < Connection
999
999
 
1000
1000
  private
1001
1001
 
1002
- # Prints recently received data (@recently_received), if there's any, and
1003
- # empties that buffer afterwards.
1002
+ # Prints recently received data (@recently_received_data) if
1003
+ # {#log_recently_received_data?} says so and there is recently received data
1004
+ # in the buffer. Clears the buffer afterwards.
1004
1005
  #
1005
1006
  # The goal is to log data in a more readable way, by periodically log what
1006
1007
  # has recently been received, as opposed to each single character in case of
1007
1008
  # a slowly answering telnet server.
1008
1009
  def log_recently_received_data
1009
- return if @recently_received_data.empty?
1010
+ return if @recently_received_data.empty? || !log_recently_received_data?
1010
1011
  logger.debug "#{node}: Received: #{@recently_received_data.inspect}"
1011
- @recently_received_data = ""
1012
+ @recently_received_data.clear
1012
1013
  end
1013
1014
 
1014
- # Returns +true+ if recently received data should be logged.
1015
- # @see #log_recently_received_data
1016
- # @return [Boolean]
1017
- def should_log_recently_received_data?
1018
- true & logger.debug?
1015
+ # @return [Boolean] if recently received data should be logged or not
1016
+ def log_recently_received_data?
1017
+ logger.debug?
1019
1018
  end
1020
1019
 
1021
1020
  # Sets the @connection_state to _new_state_. Raises if current (old) state is
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-simple_telnet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrik Wenger