Sha256: fc72e24082332b9a6d96d54e6008de33e6aab47c8c24af545bc21797aa8d1d5d

Contents?: true

Size: 715 Bytes

Versions: 2

Compression:

Stored size: 715 Bytes

Contents

module Codestatus
  class BuildStatus
    UNDEFINED = 'undefined'.freeze

    # Defined in GitHub
    ERROR = 'error'.freeze
    FAILURE = 'failure'.freeze
    PENDING = 'pending'.freeze
    SUCCESS = 'success'.freeze

    # Statuses defined in Bitbucket are mapped into GitHub's status
    #   STOPPED    => ERROR
    #   FAILED     => FAILURE
    #   INPROGRESS => PENDING
    #   SUCCESSFUL => SUCCESS

    STATUSES = [
      ERROR,
      FAILURE,
      PENDING,
      SUCCESS,
    ].freeze

    def initialize(sha:, status:)
      @sha = sha

      if STATUSES.include?(status.to_s)
        @status = status.to_s
      else
        @status = UNDEFINED
      end
    end

    attr_reader :sha, :status
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
codestatus-0.1.3 lib/codestatus/build_status.rb
codestatus-0.1.2 lib/codestatus/build_status.rb