Class: WatchmonkeyCli::Checkers::FileExists
- Inherits:
-
WatchmonkeyCli::Checker
- Object
- WatchmonkeyCli::Checker
- WatchmonkeyCli::Checkers::FileExists
- Defined in:
- lib/watchmonkey_cli/checkers/unix_file_exists.rb
Constant Summary
Constants included from Helper
Instance Attribute Summary
Attributes inherited from WatchmonkeyCli::Checker
Instance Method Summary collapse
Methods inherited from WatchmonkeyCli::Checker
#_tolog, #blank_config, checker_name, checker_name=, #debug, descendants, #error, #info, inherited, #init, #initialize, #local, maxrt, maxrt=, #rsafe, #safe, #spawn_sub, #start, #stop
Methods included from Helper
#human_filesize, #human_number, #human_seconds
Constructor Details
This class inherits a constructor from WatchmonkeyCli::Checker
Instance Method Details
#check!(result, host, file, opts = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/watchmonkey_cli/checkers/unix_file_exists.rb', line 13 def check! result, host, file, opts = {} if host.is_a?(WatchmonkeyCli::LoopbackConnection) result.error! "#{opts[:message]} (ENOENT)" if !File.exist?(file) else result.command = "test -f #{Shellwords.escape(file)} && echo exists" result.result = host.exec(result.command) result.error! "#{opts[:message]} (#{result.result.presence || "ENOENT"})" if result.result != "exists" end end |
#enqueue(host, file, opts = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/watchmonkey_cli/checkers/unix_file_exists.rb', line 6 def enqueue host, file, opts = {} opts = { message: "File #{file} does not exist!" }.merge(opts) host = app.fetch_connection(:loopback, :local) if !host || host == :local host = app.fetch_connection(:ssh, host) if host.is_a?(Symbol) app.enqueue(self, host, file, opts) end |