Skip to content

Commit

Permalink
Additional executable verifiers checking for certain version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Ulbrich committed Jul 24, 2009
1 parent 2641360 commit 6acd232
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/sprinkle/verifiers/executable.rb
Expand Up @@ -31,6 +31,23 @@ def has_executable(path)
@commands << "[ -n \"`echo \\`which #{path}\\``\" ]"
end
end

# Same as has_executable but with checking for e certain version number.
# Last option is the parameter to append for getting the version (which
# defaults to "-v").
def has_executable_with_version(path, version, get_version = '-v')
if path.include?('/')
@commands << "[ -x #{path} -a -n \"`#{path} #{get_version} 2> /dev/null | egrep -e \\\"#{version}\\\"`\" ]"
else
@commands << "[ -n \"`echo \\`which #{path}\\``\" -a -n \"`\\`which #{path}\\` #{get_version} 2>&1 | egrep -e \\\"#{version}\\\"`\" ]"
end
end

# Same as has_executable but checking output of a certain command
# with grep.
def has_version_in_grep(cmd, version)
@commands << "[ -n \"`#{cmd} 2> /dev/null | egrep -e \\\"#{version}\\\"`\" ]"
end
end
end
end

0 comments on commit 6acd232

Please sign in to comment.