Sha256: 217d3f4d99439bdf5fa33d2d638e95a5f49efc129bf7006395c5236ddae5e74c
Contents?: true
Size: 573 Bytes
Versions: 3
Compression:
Stored size: 573 Bytes
Contents
require 'socket' require 'timeout' class Eye::Client attr_reader :socket_path def initialize(socket_path) @socket_path = socket_path end def command(cmd, *args) attempt_command(Marshal.dump([cmd, *args])) end def attempt_command(pack) Timeout.timeout(Eye::Local.client_timeout) { send_request(pack) } rescue Timeout::Error, EOFError :timeouted end def send_request(pack) UNIXSocket.open(@socket_path) do |socket| socket.write(pack) data = socket.read Marshal.load(data) rescue :corrupted_data end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
eye-0.8.pre2 | lib/eye/client.rb |
eye-0.8.pre | lib/eye/client.rb |
eye-0.7 | lib/eye/client.rb |