Class: Travis::Builder

Inherits:
Object
  • Object
show all
Extended by:
Resque::Plugins::Meta
Includes:
Base
Defined in:
lib/travis/builder.rb,
lib/travis/builder/base.rb,
lib/travis/builder/rails.rb,
lib/travis/builder/pusher.rb,
lib/travis/builder/stdout.rb

Defined Under Namespace

Modules: Base, Pusher, Rails, Stdout

Instance Attribute Summary

Attributes included from Base

#build, #meta_id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

#buildable, #initialize, #on_finish, #on_log, #on_start, #repository_id, #work!

Class Method Details

.connectionsObject



27
28
29
# File 'lib/travis/builder.rb', line 27

def connections
  @@connections ||= []
end

.initObject



17
18
19
20
21
22
23
24
25
# File 'lib/travis/builder.rb', line 17

def init
  require 'resque/heartbeat'

  include Travis::Builder::Stdout
  include Travis::Builder::Rails
  include Travis::Builder::Pusher

  Resque.redis = ENV['REDIS_URL'] || Travis.config['redis']['url']
end

.perform(meta_id, payload) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/travis/builder.rb', line 31

def perform(meta_id, payload)
  EM.run do
    sleep(0.01) until EM.reactor_running?
    EM.defer do
      begin
        new(meta_id, payload).work!
        sleep(0.1) until connections.empty?
        EM.stop
      rescue Exception => e
        $_stdout.puts e.inspect
      end
    end
  end
end

Instance Method Details

#connectionsObject



47
48
49
# File 'lib/travis/builder.rb', line 47

def connections
  self.class.connections
end

#register_connection(connection) ⇒ Object



51
52
53
54
55
# File 'lib/travis/builder.rb', line 51

def register_connection(connection)
  connections << connection
  connection.callback { connections.delete(connection) }
  connection.errback  { connections.delete(connection) }
end