Sha256: 0b21ec8b08489e19db14fcc82cb2137707e85a4c463681f0892a0da23f593192
Contents?: true
Size: 1.14 KB
Versions: 7
Compression:
Stored size: 1.14 KB
Contents
module Sprinkle module Verifiers # = File Verifier # # Contains a verifier to check the existance of a file. # # == Example Usage # # verify { has_file '/etc/apache2/apache2.conf' } # # verify { file_contains '/etc/apache2/apache2.conf', 'mod_gzip'} # module File Sprinkle::Verify.register(Sprinkle::Verifiers::File) # Checks to make sure <tt>path</tt> is a file on the remote server. def has_file(path) path = path.to_s if RUBY_PLATFORM =~ /win32/ command = "if exist \"#{path}\" (if not exist \"#{path}\\\" (exit 0) else (exit 1)) else (exit 1)" command << ' > NUL 2>&1' unless logger.debug? else command = "test -f #{path}" end @commands << command end def file_contains(path, text) path, text = path.to_s, text.to_s if RUBY_PLATFORM =~ /win32/ command = "findstr /m /c:\"#{text}\" \"#{path}\"" command << ' > NUL 2>&1' unless logger.debug? else command = "grep '#{text}' #{path}" end @commands << command end end end end
Version data entries
7 entries across 7 versions & 1 rubygems