Sha256: 27d82af412bc734966f95141172950c2750bd4f2d24c7a97b340860f2b6a9bc1
Contents?: true
Size: 1.19 KB
Versions: 11
Compression:
Stored size: 1.19 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) test "-f #{path}" end def no_file(path) test "! -f #{path}" end def md5_of_file(path, md5) test "\"`md5sum #{path} | cut -f1 -d' '`\" = \"#{md5}\"" end def file_contains(path, text) @commands << "grep '#{text}' #{path}" end def user_present(username) has_user username end def matches_local(localfile, remotefile, mode=nil) raise "Couldn't find local file #{localfile}" unless ::File.exists?(localfile) require 'digest/md5' local = Digest::MD5.hexdigest(::File.read(localfile)) @commands << %{[ "X$(md5sum #{remotefile}|cut -d\\ -f 1)" = "X#{local}" ]} end end end end
Version data entries
11 entries across 11 versions & 1 rubygems