Module: Baptize::Plugins::Verifications
- Defined in:
- lib/baptize/plugins/verifications.rb
Instance Method Summary collapse
- #fail_verification(message = "Verification failed") ⇒ Object
- #file_contains(path, text, options = {}) ⇒ Object
- #has_directory(path) ⇒ Object
- #has_executable(path) ⇒ Object
- #has_file(path) ⇒ Object
- #has_user(name) ⇒ Object
Instance Method Details
#fail_verification(message = "Verification failed") ⇒ Object
5 6 7 |
# File 'lib/baptize/plugins/verifications.rb', line 5 def fail_verification( = "Verification failed") raise VerificationFailure.new() end |
#file_contains(path, text, options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/baptize/plugins/verifications.rb', line 17 def file_contains(path, text, = {}) = {:mode => :text}.merge() if [:mode] == :text command = Array(text.strip.split("\n")).flatten.map {|line| "grep --fixed-strings #{line.shellescape} #{path.shellescape}" }.join(" && ") elsif [:mode] == :perl command = "grep --perl-regexp #{text.shellescape} #{path.shellescape}" else command = "grep --basic-regexp #{text.shellescape} #{path.shellescape}" end remote_assert command end |
#has_directory(path) ⇒ Object
13 14 15 |
# File 'lib/baptize/plugins/verifications.rb', line 13 def has_directory(path) remote_assert("test -d #{path.shellescape}") or fail_verification("Remote directory #{path} does not exist") end |
#has_executable(path) ⇒ Object
29 30 31 |
# File 'lib/baptize/plugins/verifications.rb', line 29 def has_executable(path) remote_assert("which #{path.shellescape}") or fail_verification("No executable #{path} found") end |
#has_file(path) ⇒ Object
9 10 11 |
# File 'lib/baptize/plugins/verifications.rb', line 9 def has_file(path) remote_assert("test -e #{path.shellescape}") or fail_verification("Remote file #{path} does not exist") end |
#has_user(name) ⇒ Object
33 34 35 |
# File 'lib/baptize/plugins/verifications.rb', line 33 def has_user(name) remote_assert("id -u #{name.to_s.shellescape}") or fail_verification("No user #{name}") end |