Class: Travis::Surveillance::Surveyor

Inherits:
Object
  • Object
show all
Defined in:
lib/travis/surveillance/surveyor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, pusher_token = "23ed642e81512118260e") ⇒ Surveyor

Returns a new instance of Surveyor.



13
14
15
16
# File 'lib/travis/surveillance/surveyor.rb', line 13

def initialize(project, pusher_token = "23ed642e81512118260e")
  @project = project
  @socket   = PusherClient::Socket.new(pusher_token)
end

Instance Attribute Details

#projectObject

Returns the value of attribute project.



11
12
13
# File 'lib/travis/surveillance/surveyor.rb', line 11

def project
  @project
end

#socketObject

Returns the value of attribute socket.



11
12
13
# File 'lib/travis/surveillance/surveyor.rb', line 11

def socket
  @socket
end

Instance Method Details

#survey(&block) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/travis/surveillance/surveyor.rb', line 18

def survey(&block)
  @socket.subscribe('common')

  @socket['common'].bind('build:started') do |payload|
    payload_to_new_build(payload)
    yield if block_given?
  end
  @socket['common'].bind('build:finished') do |payload|
    payload_to_finished_build(payload)
    yield if block_given?
  end
  @socket['common'].bind('job:started') do |payload|
    payload_to_job_started(payload)
    yield if block_given?
  end
  @socket['common'].bind('job:finished') do |payload|
    payload_to_job_finished(payload)
    yield if block_given?
  end

  @socket.connect unless Travis::Surveillance.mocking?
end