class Dopi::Command::Winrm::FileExists
Public Instance Methods
command_string()
click to toggle source
# File lib/dopi/command/winrm/file_exists.rb, line 28 def command_string "if(-not(Test-Path '#{file}')) { exit 1 }" end
file()
click to toggle source
# File lib/dopi/command/winrm/file_exists.rb, line 32 def file @file ||= file_valid? ? hash[:file] : nil end
file_valid?()
click to toggle source
# File lib/dopi/command/winrm/file_exists.rb, line 37 def file_valid? hash[:file] or raise CommandParsingError, "Plugin #{name}: The key 'file' needs to be specified" begin hash[:file][/[a-zA-Z]+:\\/] or hash[:file][/\\\\\w+/] or raise CommandParsingError, "Plugin #{name}: The path for 'file' has to be absolute" rescue ArgumentError => e raise CommandParsingError, "Plugin #{name}: The value in 'file' is not a valid file path: #{e.message}" end end
run()
click to toggle source
# File lib/dopi/command/winrm/file_exists.rb, line 19 def run cmd_stdout, cmd_stderr, cmd_exit_code = winrm_powershell_command(command_string) check_exit_code(cmd_exit_code) end
run_noop()
click to toggle source
# File lib/dopi/command/winrm/file_exists.rb, line 24 def run_noop log(:info, "(NOOP) Executing '#{command_string}' for command #{name}") end
validate()
click to toggle source
# File lib/dopi/command/winrm/file_exists.rb, line 13 def validate validate_winrm validate_exit_code log_validation_method(:file_valid?, CommandParsingError) end