Sha256: 8e167374f766c3c5c0286237b495fb7f4be95267e40cd3a25f4070278fcbd26c
Contents?: true
Size: 1.71 KB
Versions: 7
Compression:
Stored size: 1.71 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) # tests that the file <tt>path</tt> exists def has_file(path) test "-f #{path}" end # Tests that the directory <tt>dir</tt> exists. def has_directory(dir) test "-d #{dir}" end # Checks that <tt>symlink</tt> is a symbolic link. If <tt>file</tt> is # given, it checks that <tt>symlink</tt> points to <tt>file</tt> def has_symlink(symlink, file = nil) if file.nil? test "-L #{symlink}" else test "'#{file}' = `readlink #{symlink}`" end end def no_file(path) test "! -f #{path}" end def md5_of_file(path, md5) test "\"`#{sudo_cmd}md5sum #{path} | cut -f1 -d' '`\" = \"#{md5}\"" end def file_contains(path, text) @commands << "grep '#{text}' #{path}" end # TODO: remove 0.9 def user_present(username) ActiveSupport::Deprecation.warn("user_present is depreciated. Use has_user instead.") 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)) md5_of_file remotefile, local end end end end
Version data entries
7 entries across 7 versions & 1 rubygems