Sha256: 5a932ade3b0979633883fc864d15871272c91650d6a9f56d2ec6d59933ada0cb

Contents?: true

Size: 1.41 KB

Versions: 79

Compression:

Stored size: 1.41 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 EacLauncher
  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
        class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
          def self.#{status}(message)
            new('#{status}', message)
          end
        RUBY_EVAL
      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

Version data entries

79 entries across 79 versions & 2 rubygems

Version Path
avm-tools-0.99.0 lib/eac_launcher/publish/check_result.rb
avm-tools-0.98.0 lib/eac_launcher/publish/check_result.rb
avm-tools-0.97.0 lib/eac_launcher/publish/check_result.rb
avm-tools-0.96.0 lib/eac_launcher/publish/check_result.rb
avm-tools-0.95.0 lib/eac_launcher/publish/check_result.rb
avm-tools-0.94.3 lib/eac_launcher/publish/check_result.rb
avm-tools-0.94.2 lib/eac_launcher/publish/check_result.rb
avm-tools-0.94.1 lib/eac_launcher/publish/check_result.rb
avm-tools-0.94.0 lib/eac_launcher/publish/check_result.rb
avm-tools-0.93.0 lib/eac_launcher/publish/check_result.rb
avm-tools-0.92.0 lib/eac_launcher/publish/check_result.rb
avm-tools-0.91.0 lib/eac_launcher/publish/check_result.rb
avm-tools-0.90.0 lib/eac_launcher/publish/check_result.rb
avm-tools-0.89.0 lib/eac_launcher/publish/check_result.rb
avm-tools-0.88.0 lib/eac_launcher/publish/check_result.rb
avm-tools-0.87.1 lib/eac_launcher/publish/check_result.rb
avm-tools-0.87.0 lib/eac_launcher/publish/check_result.rb
avm-tools-0.86.0 lib/eac_launcher/publish/check_result.rb
avm-tools-0.85.1 lib/eac_launcher/publish/check_result.rb
avm-tools-0.85.0 lib/eac_launcher/publish/check_result.rb