Module: Google::Cloud::Debugger::Breakpoint::Validator

Defined in:
lib/google/cloud/debugger/breakpoint/validator.rb

Overview

Validator

A collection of static methods to help validate a given breakpoint.

Constant Summary collapse

FILE_NOT_FOUND_MSG =
"File not found.".freeze
WRONG_FILE_TYPE_MSG =
"File must be a `.rb` file.".freeze
INVALID_LINE_MSG =
"Invalid line.".freeze

Class Method Summary collapse

Class Method Details

.validate(breakpoint) ⇒ Object

Validate a given breakpoint. Set breakpoint to error state if the breakpoint fails validation.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/google/cloud/debugger/breakpoint/validator.rb', line 32

def self.validate breakpoint
  error_msg = nil
  if !verify_file_path breakpoint.full_path
    error_msg = FILE_NOT_FOUND_MSG
  elsif !verify_file_type breakpoint.full_path
    error_msg = WRONG_FILE_TYPE_MSG
  elsif !verify_line breakpoint.full_path, breakpoint.line
    error_msg = INVALID_LINE_MSG
  end

  if error_msg
    cause = Breakpoint::StatusMessage::BREAKPOINT_SOURCE_LOCATION
    breakpoint.set_error_state error_msg, refers_to: cause
    false
  else
    true
  end
end