Module: Sprinkle::Verifiers::File
- Defined in:
- lib/sprinkle/verifiers/file.rb
Overview
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'}
Instance Method Summary collapse
- #file_contains(path, text) ⇒ Object
-
#has_file(path) ⇒ Object
Checks to make sure
path
is a file on the remote server. - #matches_local(localfile, remotefile, mode = nil) ⇒ Object
- #user_present(username) ⇒ Object
Instance Method Details
#file_contains(path, text) ⇒ Object
21 22 23 |
# File 'lib/sprinkle/verifiers/file.rb', line 21 def file_contains(path, text) @commands << "grep '#{text}' #{path}" end |
#has_file(path) ⇒ Object
Checks to make sure path
is a file on the remote server.
17 18 19 |
# File 'lib/sprinkle/verifiers/file.rb', line 17 def has_file(path) @commands << "test -f #{path}" end |
#matches_local(localfile, remotefile, mode = nil) ⇒ Object
27 28 29 30 31 |
# File 'lib/sprinkle/verifiers/file.rb', line 27 def matches_local(localfile, remotefile, mode=nil) raise "Couldn't find local file #{localfile}" unless ::File.exists?(localfile) local = `md5 #{localfile}`.split.last @commands << %{[ "X$(md5sum #{remotefile}|cut -d\\ -f 1)" = "X#{local}" ]} end |
#user_present(username) ⇒ Object
24 25 26 |
# File 'lib/sprinkle/verifiers/file.rb', line 24 def user_present(username) @commands << %Q{grep -q -e \'^#{username}:x\' /etc/passwd && test -d ~#{username}} end |