Sha256: 35f9475056647ff20c02b78ec407218999fb176fae8a358ed11b024e79cab795

Contents?: true

Size: 1.51 KB

Versions: 237

Compression:

Stored size: 1.51 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
          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
end

Version data entries

237 entries across 237 versions & 3 rubygems

Version Path
avm-0.84.0 lib/avm/launcher/publish/check_result.rb
eac_tools-0.83.0 sub/avm/lib/avm/launcher/publish/check_result.rb
avm-0.83.0 lib/avm/launcher/publish/check_result.rb
eac_tools-0.82.0 sub/avm/lib/avm/launcher/publish/check_result.rb
avm-0.82.0 lib/avm/launcher/publish/check_result.rb
eac_tools-0.81.0 sub/avm/lib/avm/launcher/publish/check_result.rb
eac_tools-0.80.0 sub/avm/lib/avm/launcher/publish/check_result.rb
avm-0.81.0 lib/avm/launcher/publish/check_result.rb
eac_tools-0.79.0 sub/avm/lib/avm/launcher/publish/check_result.rb
avm-0.80.0 lib/avm/launcher/publish/check_result.rb
eac_tools-0.78.0 sub/avm/lib/avm/launcher/publish/check_result.rb
eac_tools-0.77.1 sub/avm/lib/avm/launcher/publish/check_result.rb
eac_tools-0.77.0 sub/avm/lib/avm/launcher/publish/check_result.rb
eac_tools-0.76.1 sub/avm/lib/avm/launcher/publish/check_result.rb
eac_tools-0.76.0 sub/avm/lib/avm/launcher/publish/check_result.rb
eac_tools-0.75.2 sub/avm/lib/avm/launcher/publish/check_result.rb
eac_tools-0.75.1 sub/avm/lib/avm/launcher/publish/check_result.rb
eac_tools-0.75.0 sub/avm/lib/avm/launcher/publish/check_result.rb
eac_tools-0.74.1 sub/avm/lib/avm/launcher/publish/check_result.rb
eac_tools-0.74.0 sub/avm/lib/avm/launcher/publish/check_result.rb