module Sprinkle::Verifiers::File

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'}

Public Instance Methods

file_contains(path, text) click to toggle source
# File lib/sprinkle/verifiers/file.rb, line 44
def file_contains(path, text)
  @commands << "grep '#{text}' #{path}"
end
has_directory(dir) click to toggle source

Tests that the directory dir exists.

# File lib/sprinkle/verifiers/file.rb, line 22
def has_directory(dir)
  test "-d #{dir}"
end
has_file(path) click to toggle source

tests that the file path exists

# File lib/sprinkle/verifiers/file.rb, line 17
def has_file(path)
  test "-f #{path}"
end
matches_local(localfile, remotefile, mode=nil) click to toggle source
# File lib/sprinkle/verifiers/file.rb, line 54
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
md5_of_file(path, md5) click to toggle source
# File lib/sprinkle/verifiers/file.rb, line 40
def md5_of_file(path, md5)
  test "\"`#{sudo_cmd}md5sum #{path} | cut -f1 -d' '`\" = \"#{md5}\""
end
no_file(path) click to toggle source
# File lib/sprinkle/verifiers/file.rb, line 36
def no_file(path)
  test "! -f #{path}"
end
user_present(username) click to toggle source

TODO: remove 0.9

# File lib/sprinkle/verifiers/file.rb, line 49
def user_present(username) 
  ActiveSupport::Deprecation.warn("user_present is depreciated.  Use has_user instead.")  
  has_user username
end