Module: Einhorn::Client::Transport
- Defined in:
- lib/einhorn/client.rb
Overview
Keep this in this file so client can be loaded entirely standalone by user code.
Constant Summary collapse
- ParseError =
defined?(Psych::SyntaxError) ? Psych::SyntaxError : ArgumentError
Class Method Summary collapse
- .deserialize_message(line) ⇒ Object
- .receive_message(socket) ⇒ Object
- .send_message(socket, message) ⇒ Object
- .serialize_message(message) ⇒ Object
Class Method Details
.deserialize_message(line) ⇒ Object
28 29 30 31 |
# File 'lib/einhorn/client.rb', line 28 def self.(line) serialized = line.gsub(/%(25|0A)/, "%25" => "%", "%0A" => "\n") SafeYAML.load(serialized) end |
.receive_message(socket) ⇒ Object
17 18 19 20 |
# File 'lib/einhorn/client.rb', line 17 def self.(socket) line = socket.readline (line) end |
.send_message(socket, message) ⇒ Object
12 13 14 15 |
# File 'lib/einhorn/client.rb', line 12 def self.(socket, ) line = () socket.write(line) end |
.serialize_message(message) ⇒ Object
22 23 24 25 26 |
# File 'lib/einhorn/client.rb', line 22 def self.() serialized = YAML.dump() escaped = serialized.gsub(/%|\n/, "%" => "%25", "\n" => "%0A") escaped + "\n" end |