lib/sprinkle/verifiers/executable.rb in trevorturk-sprinkle-0.2.2 vs lib/sprinkle/verifiers/executable.rb in trevorturk-sprinkle-0.2.6
- old
+ new
@@ -29,8 +29,25 @@
@commands << "test -x #{path}"
else
@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
\ No newline at end of file