Sha256: e978d116757ac50abcfe24add7fcd81bf5587462e854a40bd0cd44cb61a07508
Contents?: true
Size: 1.41 KB
Versions: 8
Compression:
Stored size: 1.41 KB
Contents
module Sprinkle module Verifiers # = Executable Verifier # # Contains a verifier to check the existance of an executable # script on your server. # # == Example Usage # # First, absolute path to an executable: # # verify { has_executable '/usr/special/secret/bin/scipt' } # # Second, a global executable which would be available anywhere on the # command line: # # verify { has_executable 'grep' } module Executable Sprinkle::Verify.register(Sprinkle::Verifiers::Executable) # Checks if <tt>path</tt> is an executable script. This verifier is "smart" because # if the path contains a forward slash '/' then it assumes you're checking an # absolute path to an executable. If no '/' is in the path, it assumes you're # checking for a global executable that would be available anywhere on the command line. def has_executable(path) if RUBY_PLATFORM =~ /win32/ raise NotImplementedError, "Win32 platform does not support checking for executables" else # 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}" else @commands << "[ -n \"`echo \\`which #{path}\\``\" ]" end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems