Sha256: 48242fffb6f4e01d411b13ff83ce9c3dc355b935adeb0c75dee86767e82b7747
Contents?: true
Size: 1.93 KB
Versions: 1
Compression:
Stored size: 1.93 KB
Contents
require 'pusher' module Travis module Notifications class Pusher autoload :Payload, 'travis/notifications/pusher/payload' EVENTS = [/build:(started|finished)/, /job:.*:(created|started|log|finished)/] def notify(event, object, *args) push(event, object, *args) end protected def push(event, object, *args) data = args.last.is_a?(Hash) ? args.pop : {} data = payload_for(event, object, data) event = client_event_for(event) channel(event, object).trigger(event, data) end def config @config ||= Travis.config.pusher end def pusher @pusher ||= ::Pusher.tap do |pusher| pusher.app_id = config.app_id pusher.key = config.key pusher.secret = config.secret end end def channel(event, object) pusher[queue_for(event, object)] end def client_event_for(event) # gotta remap a bunch of events here. should get better with sproutcore case event when /job:.*:created/ 'build:queued' when 'job:configure:started', # TODO doesn't seem to be sent by the worker, so we notify on finished, too 'job:configure:finished' 'build:removed' when 'job:test:started' 'build:removed' when 'job:test:finished' 'build:finished' when 'job:test:log' 'build:log' else event end end def queue_for(event, object) case event when 'build:queued', 'build:removed' 'jobs' when 'build:log' "build-#{object.id}" else 'builds' end end def payload_for(event, object, extra = {}) Payload.new(client_event_for(event), object, extra).to_hash end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
travis-core-0.0.1 | lib/travis/notifications/pusher.rb |