Module: Dopi::CommandParser::ExitCode
- Included in:
- Dopi::Command::Custom, Dopi::Command::Mco::Rpc, Dopi::Command::Ssh::Custom, Dopi::Command::Ssh::FileContains, Dopi::Command::Ssh::FileDeploy, Dopi::Command::Ssh::FileExists, Dopi::Command::Ssh::FileReplace, Dopi::Command::Ssh::WaitForLogin, Dopi::Command::Winrm::Cmd, Dopi::Command::Winrm::FileContains, Dopi::Command::Winrm::FileExists, Dopi::Command::Winrm::WaitForLogin
- Defined in:
- lib/dopi/command_parser/exit_code.rb
Instance Method Summary collapse
-
#check_exit_code(cmd_exit_code) ⇒ Object
Returns true if the exit code is one we expected, otherwise false.
- #expect_exit_codes ⇒ Object
- #validate_exit_code ⇒ Object
Instance Method Details
#check_exit_code(cmd_exit_code) ⇒ Object
Returns true if the exit code is one we expected, otherwise false
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/dopi/command_parser/exit_code.rb', line 23 def check_exit_code(cmd_exit_code) log(:debug, "Checking exit code '#{cmd_exit_code}'") exit_code_ok = case expect_exit_codes when 'all', 'ALL', 'All', :all then true when Array then expect_exit_codes.include?(cmd_exit_code) when Fixnum then expect_exit_codes == cmd_exit_code else false end unless exit_code_ok log(:error, "Wrong exit code in command #{name}") if expect_exit_codes.kind_of?(Array) log(:error, "Exit code was #{cmd_exit_code.to_s} should be one of #{expect_exit_codes.join(', ')}") elsif expect_exit_codes.kind_of?(Fixnum) log(:error, "Exit code was #{cmd_exit_code.to_s} should be #{expect_exit_codes.to_s}") else log(:error, "Exit code was #{cmd_exit_code.to_s} #{expect_exit_codes}") end end exit_code_ok end |
#expect_exit_codes ⇒ Object
17 18 19 20 |
# File 'lib/dopi/command_parser/exit_code.rb', line 17 def expect_exit_codes @expect_exit_codes ||= expect_exit_codes_valid? ? hash[:expect_exit_codes] : create_exit_codes end |
#validate_exit_code ⇒ Object
13 14 15 |
# File 'lib/dopi/command_parser/exit_code.rb', line 13 def validate_exit_code log_validation_method('expect_exit_codes_valid?', CommandParsingError) end |