Sha256: 4c23b9a21d9f96cff445c0d2acb6c2b5b19ee4a45ac1b464b1c9e0b9e20d852e

Contents?: true

Size: 906 Bytes

Versions: 3

Compression:

Stored size: 906 Bytes

Contents

module StatusCat
  module Checkers
    class Base
      extend ActiveSupport::DescendantsTracker

      FORMAT = "%s | %s | %s\n".freeze

      attr_reader :value, :status

      def self.class_to_name(klass)
        klass.to_s.split('::').last.underscore.to_sym
      end

      def name
        Base.class_to_name(self.class)
        # self.class.to_s.split('::').last.underscore.to_sym
      end

      def to_s(format = FORMAT)
        format(format, name, value, status || I18n.t(:ok, scope: :status_cat))
      end

      protected

      # rubocop:disable Lint/RescueException
      def fail_on_exception
        begin
          return yield
        rescue Exception => e
          return e
        end
        return nil
      end

      def gem_missing?(gem, present)
        return false if present

        @status = "#{gem} gem is not installed"
        return true
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
status_cat-5.0.2 lib/status_cat/checkers/base.rb
status_cat-5.0.1 lib/status_cat/checkers/base.rb
status_cat-5.0.0 lib/status_cat/checkers/base.rb