Module: Sprinkle::Verifiers::Directory

Defined in:
lib/sprinkle/verifiers/directory.rb

Overview

Directory Verifier

Defines a verify which can be used to test the existence of a directory.

Instance Method Summary collapse

Instance Method Details

#has_directory(dir) ⇒ Object

Tests that the directory dir exists.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/sprinkle/verifiers/directory.rb', line 11

def has_directory(dir)
  dir = dir.to_s
  if RUBY_PLATFORM =~ /win32/
    dir += "\\" unless dir[-1,1] == "\\"
    command = "if exist \"#{dir}\" (exit 0) else (exit 1)"
    command << ' > NUL 2>&1' unless logger.debug?
  else
    command = "test -d #{dir}"
  end
  @commands << command
end