Sha256: 2e69c3b5208b436d15d934665bd783a70030852d73e9eed7d34f277cecaff2b9

Contents?: true

Size: 1.59 KB

Versions: 222

Compression:

Stored size: 1.59 KB

Contents

require 'travis/client'

module Travis
  module Client
    module States
      STATES  = %w[created queued started passed failed errored canceled ready]

      def ready?
        state == 'ready'
      end

      def pending?
        check_state
        %w[created started queued].include? state
      end

      def started?
        check_state
        state != 'created' and state != 'queued'
      end

      def queued?
        check_state
        state != 'created'
      end

      def finished?
        not pending?
      end

      def passed?
        check_state
        state == 'passed'
      end

      def errored?
        check_state
        state == 'errored'
      end

      def failed?
        check_state
        state == 'failed'
      end

      def canceled?
        check_state
        state == 'canceled'
      end

      def unsuccessful?
        errored? or failed? or canceled?
      end

      def created?
        check_state
        !!state
      end

      def color
        case state
        when 'created', 'queued', 'started'   then 'yellow'
        when 'passed', 'ready'                then 'green'
        when 'errored', 'canceled', 'failed'  then 'red'
        end
      end

      def yellow?
        color == 'yellow'
      end

      def green?
        color == 'green'
      end

      def red?
        color == 'red'
      end

      def running?
        state == 'started'
      end

      alias successful? passed?

      private

        def check_state
          raise Error, "unknown state %p for %p" % [state, self] unless STATES.include? state
        end
    end
  end
end

Version data entries

222 entries across 222 versions & 1 rubygems

Version Path
travis-1.5.6 lib/travis/client/states.rb
travis-1.5.6.travis.337.4 lib/travis/client/states.rb
travis-1.5.6.travis.336.4 lib/travis/client/states.rb
travis-1.5.6.travis.333.4 lib/travis/client/states.rb
travis-1.5.6.travis.332.4 lib/travis/client/states.rb
travis-1.5.6.travis.330.4 lib/travis/client/states.rb
travis-1.5.6.travis.329.4 lib/travis/client/states.rb
travis-1.5.6.travis.326.4 lib/travis/client/states.rb
travis-1.5.6.travis.324.4 lib/travis/client/states.rb
travis-1.5.6.travis.323.4 lib/travis/client/states.rb
travis-1.5.6.travis.320.4 lib/travis/client/states.rb
travis-1.5.6.travis.319.4 lib/travis/client/states.rb
travis-1.5.6.travis.317.4 lib/travis/client/states.rb
travis-1.5.6.travis.315.4 lib/travis/client/states.rb
travis-1.5.6.travis.314.4 lib/travis/client/states.rb
travis-1.5.6.travis.312.4 lib/travis/client/states.rb
travis-1.5.6.travis.307.4 lib/travis/client/states.rb
travis-1.5.6.travis.306.4 lib/travis/client/states.rb
travis-1.5.6.travis.304.4 lib/travis/client/states.rb
travis-1.5.6.travis.303.4 lib/travis/client/states.rb