Class: Borg::Requestor

Inherits:
EM::Connection
  • Object
show all
Includes:
EM::P::ObjectProtocol
Defined in:
lib/borg/borg_requestor.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.make_requestObject



4
5
6
# File 'lib/borg/borg_requestor.rb', line 4

def self.make_request
  EM.connect(Borg::Config.ip,Borg::Config.port,Requestor)
end

Instance Method Details

#connection_completedObject



8
9
10
11
# File 'lib/borg/borg_requestor.rb', line 8

def connection_completed
  @server_running = true
  send_object(BuildRequester.new())
end

#receive_object(ruby_object) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/borg/borg_requestor.rb', line 13

def receive_object(ruby_object)
  case ruby_object
  when BuildOutput
    print ruby_object.data
  when BuildStatus
    stop_build(ruby_object)
  end
end

#stop_build(ruby_object) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/borg/borg_requestor.rb', line 31

def stop_build(ruby_object)
  puts
  if(ruby_object.exit_status == 0)
    puts "Successfully ran all tests"
    EM.stop()
  else
    abort("Error running tests")
  end
end

#unbindObject



22
23
24
25
26
27
28
29
# File 'lib/borg/borg_requestor.rb', line 22

def unbind
  unless @server_running
    puts "Error running server"
    EM.stop()
  else
    EM.stop()
  end
end