Sha256: 562b079f3e1589182ea9808b62c9d6010a59f9b77480c4a42d81deccf09afc66

Contents?: true

Size: 999 Bytes

Versions: 1

Compression:

Stored size: 999 Bytes

Contents

require 'active_support/concern'
require 'simple_states'

class Job
  class Test
    module States
      extend ActiveSupport::Concern

      included do
        include SimpleStates, Job::States, Travis::Notifications

        states :created, :started, :finished # :cloned, :installed, ...

        event :start,  :to => :started
        event :finish, :to => :finished, :after => :add_tags
        event :all, :after => [:notify, :propagate]

        after_create do
          notify(:create)
        end
      end

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

      def finish(data = {})
        [:status, :finished_at].each do |key|
          send(:"#{key}=", data[key]) if data.key?(key)
        end
      end

      def append_log!(chars)
        notify(:log, :build => { :_log => chars })
      end

      protected

        def extract_finishing_attributes(attributes)
          extract!(attributes, :finished_at, :status)
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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