lib/riddle.rb in riddle-1.3.3 vs lib/riddle.rb in riddle-1.4.0
- old
+ new
@@ -1,15 +1,26 @@
+require 'thread'
require 'socket'
require 'timeout'
module Riddle #:nodoc:
@@mutex = Mutex.new
@@escape_pattern = /[\(\)\|\-!@~"&\/]/
+ @@use_encoding = defined?(::Encoding) &&
+ ::Encoding.respond_to?(:default_external)
class ConnectionError < StandardError #:nodoc:
#
end
+
+ def self.encode(data, encoding = defined?(::Encoding) && ::Encoding.default_external)
+ if @@use_encoding
+ data.force_encoding(encoding)
+ else
+ data
+ end
+ end
def self.mutex
@@mutex
end
@@ -49,9 +60,10 @@
# or
require 'riddle/1.10'
}
end
+
end
require 'riddle/auto_version'
require 'riddle/client'
require 'riddle/configuration'