Sha256: e6d6f93b3a81d3b2d3b580cfcc02bd3c69e5d65f8e83351829d424511000b4d5

Contents?: true

Size: 672 Bytes

Versions: 2

Compression:

Stored size: 672 Bytes

Contents

require 'command_mapper/types/input_path'

module CommandMapper
  module Types
    #
    # Represents a path to an existing directory.
    #
    class InputDir < InputPath

      #
      # Validates whether the directory exists.
      #
      # @param [Object] value
      #
      # @return [true, (false, String)]
      #
      def validate(value)
        valid, message = super(value)

        unless valid
          return valid, message
        end

        unless value.empty?
          unless File.directory?(value)
            return [false, "directory does not exist (#{value.inspect})"]
          end
        end

        return true
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
command_mapper-0.1.0 lib/command_mapper/types/input_dir.rb
command_mapper-0.1.0.pre1 lib/command_mapper/types/input_dir.rb