lib/travis/cli/monitor.rb in travis-1.5.9.travis.361.4 vs lib/travis/cli/monitor.rb in travis-1.5.9.travis.362.4

- old
+ new

@@ -70,23 +70,30 @@ def monitor?(entity) return true if all? entity.pull_request? ? pull? : push? end + def display(entity, time) + say [ + color(formatter.time(time), entity.color), + color(entity.inspect_info, [entity.color, :bold]), + color(entity.state, entity.color) + ].join(" ") + notification.notify(entity.repository.slug, "#{entity.class.name[/[^:]+$/]} ##{entity.number} #{entity.state}") + end + + def handle_event(event) + entity = event.job || event.build + time = entity.finished_at || entity.started_at + display(entity, time) if monitor? entity + rescue Travis::Client::Error => error + raise error if explode? + end + def run listen(*repos) do |listener| listener.on_connect { say description, "Monitoring #{"builds for " if builds?}%s:" } - listener.on(*events) do |event| - entity = event.job || event.build - time = entity.finished_at || entity.started_at - next unless monitor? entity - say [ - color(formatter.time(time), entity.color), - color(entity.inspect_info, [entity.color, :bold]), - color(entity.state, entity.color) - ].join(" ") - notification.notify(entity.repository.slug, "#{entity.class.name[/[^:]+$/]} ##{entity.number} #{entity.state}") - end + listener.on(*events) { |e| handle_event(e) } end end end end end