Class: HecksPlugins::JSONValidator::MessageParser

Inherits:
Object
  • Object
show all
Defined in:
lib/parsers/message_parser.rb

Overview

Turn the json-schema messages into easy to understand errors for the user

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matcher:, error:) ⇒ MessageParser

Returns a new instance of MessageParser.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/parsers/message_parser.rb', line 7

def initialize(matcher:, error:)
  @matcher = matcher
  @error = error
  @match = error[:message].match(matcher[:regex])
  @fragment = error[:fragment].gsub('#/', '')
  if fragment == ''
    @fragment = nil
  else
    @fragment = fragment.to_sym
  end

end

Instance Attribute Details

#field_nameObject (readonly)

Returns the value of attribute field_name.



5
6
7
# File 'lib/parsers/message_parser.rb', line 5

def field_name
  @field_name
end

#fragmentObject (readonly)

Returns the value of attribute fragment.



5
6
7
# File 'lib/parsers/message_parser.rb', line 5

def fragment
  @fragment
end

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/parsers/message_parser.rb', line 5

def message
  @message
end

Instance Method Details

#callObject



20
21
22
23
# File 'lib/parsers/message_parser.rb', line 20

def call
  parse_match
  self
end