Sha256: ba78bd8d14057006769e31ea4bfccd48cd3fbe1714e760127ee082c4f143b30f

Contents?: true

Size: 707 Bytes

Versions: 5

Compression:

Stored size: 707 Bytes

Contents

module Shipit
  class StatusGroup
    STATES_PRIORITY = %w(failure error pending success).freeze

    attr_reader :statuses, :significant_status

    def initialize(significant_status, visible_statuses)
      @significant_status = significant_status
      @statuses = visible_statuses
    end

    delegate :pending?, :success?, :error?, :failure?, :unknown?, :state, to: :significant_status

    def description
      "#{success_count} / #{statuses.count} checks OK"
    end

    def target_url
    end

    def to_partial_path
      'statuses/group'
    end

    def group?
      true
    end

    private

    def success_count
      @statuses.count { |s| s.state == 'success'.freeze }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
shipit-engine-0.15.0 app/models/shipit/status_group.rb
shipit-engine-0.14.0 app/models/shipit/status_group.rb
shipit-engine-0.13.0 app/models/shipit/status_group.rb
shipit-engine-0.12.1 app/models/shipit/status_group.rb
shipit-engine-0.12.0 app/models/shipit/status_group.rb