Class: Spurious::Server::App

Inherits:
EventMachine::Connection
  • Object
show all
Defined in:
lib/spurious/server/app.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ App

Returns a new instance of App.



12
13
14
# File 'lib/spurious/server/app.rb', line 12

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



10
11
12
# File 'lib/spurious/server/app.rb', line 10

def options
  @options
end

Instance Method Details

#error(message, close = false) ⇒ Object



25
26
27
# File 'lib/spurious/server/app.rb', line 25

def error(message, close = false)
  send_data "#{JSON.generate({:message_type => 'error', :type => 'error', :response => message, :close => close, :colour => :red})}\n"
end

#receive_data(data) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/spurious/server/app.rb', line 16

def receive_data data
    payload = parse_payload data
    state(payload[:type]).execute!
rescue Excon::Errors::Timeout, Excon::Errors::SocketError => e
    error('Connection to the docker daemon has failed, please check that docker is running on the host or VM', true)
rescue StandardError => e
  error(e.message, true)
end