Sha256: 3885696fdba7f393e30aa7714d8d823d58d03fec3b6f8c7dd898875af1aa5226

Contents?: true

Size: 932 Bytes

Versions: 2

Compression:

Stored size: 932 Bytes

Contents

module Reek
  module Configuration
    #
    # Configuration validator module.
    #
    module ConfigurationValidator
      private

      def smell_type?(key)
        Reek::Smells.const_get key
      rescue NameError
        false
      end

      def error_message_for_missing_directory(pathname)
        "Configuration error: Directory `#{pathname}` does not exist"
      end

      def error_message_for_file_given(pathname)
        "Configuration error: `#{pathname}` is supposed to be a directory but is a file"
      end

      def validate_directory(pathname)
        abort(error_message_for_missing_directory(pathname)) unless pathname.exist?
        abort(error_message_for_file_given(pathname)) if pathname.file?
      end

      def with_valid_directory(path)
        directory = Pathname.new path.to_s.chomp('/')
        validate_directory directory
        yield directory if block_given?
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reek-3.3.1 lib/reek/configuration/configuration_validator.rb
reek-3.3.0 lib/reek/configuration/configuration_validator.rb