Sha256: 6d2c42509f261aef4cf58b4c2096681cc845ffef65586271602b3ae92673f95a

Contents?: true

Size: 823 Bytes

Versions: 1

Compression:

Stored size: 823 Bytes

Contents

require 'active_support/concern'
require 'simple_states'

class Build
  module States
    extend ActiveSupport::Concern

    included do
      include SimpleStates, Denormalize, Notifications, Travis::Notifications

      states :created, :started, :finished

      event :start,  :to => :started
      event :finish, :to => :finished, :if => :matrix_finished?
      event :all, :after => [:denormalize, :notify]
    end

    def start(data = {})
      self.started_at = data[:started_at]
    end

    def finish(data = {})
      self.status = matrix_status
      self.finished_at = data[:finished_at]
    end

    def pending?
      !finished?
    end

    def passed?
      status == 0
    end

    def failed?
      !passed?
    end

    def color
      pending? ? 'yellow' : passed? ? 'green' : 'red'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
travis-core-0.0.1 lib/travis/model/build/states.rb