Sha256: dc058a783a980606d5c57af85c5fee19c0ea5fb81128758932b77d7e17d04a26

Contents?: true

Size: 1.45 KB

Versions: 34

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

require 'active_support/concern' # Missing on "eac/listable"
require 'active_support/hash_with_indifferent_access'
require 'eac_ruby_utils/listable'

module Avm
  module Launcher
    module Publish
      class CheckResult
        include ::EacRubyUtils::Listable

        lists.add_string :status, :updated, :pending, :blocked, :outdated

        lists.status.values.each do |status| # rubocop:disable Style/HashEachMethods
          singleton_class.define_method status do |message|
            new(status, message)
          end
        end

        class << self
          def pending_status?(status)
            [STATUS_PENDING].include?(status)
          end

          def updated_color
            'green'
          end

          def pending_color
            'yellow'
          end

          def blocked_color
            'red'
          end

          def outdated_color
            'light_blue'
          end
        end

        attr_reader :status, :message

        def initialize(status, message)
          raise "Status \"#{status}\" not in #{self.class.lists.status.values}" unless
          self.class.lists.status.values.include?(status)

          @status = status
          @message = message
        end

        def to_s
          message.light_white.send("on_#{background_color}")
        end

        private

        def background_color
          self.class.send("#{status}_color")
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
avm-0.94.1 lib/avm/launcher/publish/check_result.rb
eac_tools-0.98.0 sub/avm/lib/avm/launcher/publish/check_result.rb
avm-0.94.0 lib/avm/launcher/publish/check_result.rb
eac_tools-0.94.0 sub/avm/lib/avm/launcher/publish/check_result.rb
avm-0.93.0 lib/avm/launcher/publish/check_result.rb
eac_tools-0.92.0 sub/avm/lib/avm/launcher/publish/check_result.rb
avm-0.92.0 lib/avm/launcher/publish/check_result.rb
eac_tools-0.91.0 sub/avm/lib/avm/launcher/publish/check_result.rb
avm-0.90.1 lib/avm/launcher/publish/check_result.rb
eac_tools-0.87.1 sub/avm/lib/avm/launcher/publish/check_result.rb
avm-0.90.0 lib/avm/launcher/publish/check_result.rb
eac_tools-0.87.0 sub/avm/lib/avm/launcher/publish/check_result.rb
avm-0.89.0 lib/avm/launcher/publish/check_result.rb
eac_tools-0.86.12 sub/avm/lib/avm/launcher/publish/check_result.rb
avm-0.88.0 lib/avm/launcher/publish/check_result.rb
eac_tools-0.86.11 sub/avm/lib/avm/launcher/publish/check_result.rb
avm-0.87.0 lib/avm/launcher/publish/check_result.rb
eac_tools-0.86.8 sub/avm/lib/avm/launcher/publish/check_result.rb
avm-0.86.2 lib/avm/launcher/publish/check_result.rb
eac_tools-0.86.7 sub/avm/lib/avm/launcher/publish/check_result.rb