Skip to content

Commit

Permalink
add generic test verifier and use it instead of hard coding test ever…
Browse files Browse the repository at this point in the history
…ywhere
  • Loading branch information
joshgoebel committed Apr 6, 2013
1 parent 5a81a76 commit bd16eb7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/sprinkle/verifiers/directory.rb
Expand Up @@ -9,7 +9,7 @@ module Directory

# Tests that the directory <tt>dir</tt> exists.
def has_directory(dir)
@commands << "test -d #{dir}"
test "-d #{dir}"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/sprinkle/verifiers/executable.rb
Expand Up @@ -26,7 +26,7 @@ def has_executable(path)
# Be smart: If the path includes a forward slash, we're checking
# an absolute path. Otherwise, we're checking a global executable
if path.include?('/')
@commands << "test -x #{path}"
test "-x #{path}"
else
@commands << "[ -n \"`echo \\`which #{path}\\``\" ]"
end
Expand Down
8 changes: 6 additions & 2 deletions lib/sprinkle/verifiers/file.rb
Expand Up @@ -15,11 +15,15 @@ module File

# Checks to make sure <tt>path</tt> is a file on the remote server.
def has_file(path)
@commands << "test -f #{path}"
test "-f #{path}"
end

def no_file(path)
@commands << "test ! -f #{path}"
test "! -f #{path}"
end

def md5_of_file(path, md5)
test "`md5sum #{path} | cut -f1 -d' '` == \"#{md5}\""
end

def file_contains(path, text)
Expand Down
4 changes: 2 additions & 2 deletions lib/sprinkle/verifiers/symlink.rb
Expand Up @@ -20,9 +20,9 @@ module Symlink
# given, it checks that <tt>symlink</tt> points to <tt>file</tt>
def has_symlink(symlink, file = nil)
if file.nil?
@commands << "test -L #{symlink}"
test "-L #{symlink}"
else
@commands << "test '#{file}' = `readlink #{symlink}`"
test "'#{file}' = `readlink #{symlink}`"
end
end
end
Expand Down

0 comments on commit bd16eb7

Please sign in to comment.