Sha256: 3836edfe52a1931765cf10dd82c84ba903e49815ef65ed77d2a374f583bba950

Contents?: true

Size: 959 Bytes

Versions: 42

Compression:

Stored size: 959 Bytes

Contents

require_relative './task_exception'

module Builderator
  module Util
    ##
    # Exception raised if a safety limit is exceeded
    ##
    class LimitException < TaskException
      DEFAULT_LIMIT = 4

      attr_reader :resource_name
      attr_reader :resources

      def initialize(resource_name, task, resources)
        super(:limit, task, :yellow)

        @resource_name = resource_name
        @resources = resources
      end

      def count
        @resources.size
      end

      def limit
        Config.cleaner.limits[resource_name]
      end

      def message
        msg = "Safety limit exceeded for task `#{task}`: Count #{count} is "
        msg << "greater than the limit of #{limit} set in `cleaner.limits.#{resource_name}`. "
        msg << 'Please re-run this task with the --force flag if you are sure this is '\
        'the correct set of resources to delete.' unless Config.cleaner.force

        msg
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
builderator-2.1.1 lib/builderator/util/limit_exception.rb
builderator-2.1.0 lib/builderator/util/limit_exception.rb
builderator-2.0.4 lib/builderator/util/limit_exception.rb
builderator-2.0.3 lib/builderator/util/limit_exception.rb
builderator-2.0.2 lib/builderator/util/limit_exception.rb
builderator-2.0.1 lib/builderator/util/limit_exception.rb
builderator-2.0.0 lib/builderator/util/limit_exception.rb
builderator-1.3.2 lib/builderator/util/limit_exception.rb
builderator-1.3.1 lib/builderator/util/limit_exception.rb
builderator-1.3.0 lib/builderator/util/limit_exception.rb
builderator-1.2.3.pre.beta.1 lib/builderator/util/limit_exception.rb
builderator-1.2.2 lib/builderator/util/limit_exception.rb
builderator-1.2.1 lib/builderator/util/limit_exception.rb
builderator-1.2.0 lib/builderator/util/limit_exception.rb
builderator-1.1.12 lib/builderator/util/limit_exception.rb
builderator-1.1.11 lib/builderator/util/limit_exception.rb
builderator-1.1.10 lib/builderator/util/limit_exception.rb
builderator-1.1.9 lib/builderator/util/limit_exception.rb
builderator-1.1.8 lib/builderator/util/limit_exception.rb
builderator-1.1.7 lib/builderator/util/limit_exception.rb