Class: Ruber::SyntaxChecker::YamlSyntaxChecker
- Inherits:
-
Object
- Object
- Ruber::SyntaxChecker::YamlSyntaxChecker
- Defined in:
- plugins/syntax_checker/syntax_checker.rb,
plugins/syntax_checker/syntax_checker.rb
Overview
Class which checks the syntax of a ruby file.
It calls the YAML.load
method on the document’s content within a begin/rescue
block, rescuing any ArgumentError exception. The message of the exception is used
to find information about the error
Instance Method Summary (collapse)
-
- (String) check(str)
Checks the syntax of the given string.
-
- (<SyntaxCheckerPlugin::ErrorDescription>) convert_check_result(str)
Parses the output of #check.
-
- (YamlSyntaxChecker) initialize(doc)
constructor
Creates a new instance.
Constructor Details
- (YamlSyntaxChecker) initialize(doc)
Creates a new instance
563 564 |
# File 'plugins/syntax_checker/syntax_checker.rb', line 563 def initialize doc end |
Instance Method Details
- (String) check(str)
Checks the syntax of the given string.
concerning syntax errors or an empty string if there were no syntax error
573 574 575 576 577 578 579 580 |
# File 'plugins/syntax_checker/syntax_checker.rb', line 573 def check str begin YAML.load str '' rescue ArgumentError => e e. end end |
- (<SyntaxCheckerPlugin::ErrorDescription>) convert_check_result(str)
Parses the output of #check
corresponding to the syntax errors mentioned in str
589 590 591 592 593 594 |
# File 'plugins/syntax_checker/syntax_checker.rb', line 589 def convert_check_result str return [] if str.empty? str.match(/^syntax error on line (\d+), col (\d+): `(.*)'$/) error = SyntaxCheckerPlugin::ErrorDescription.new $1.to_i, 'Syntax error', $3.to_s, $2.to_i [error] end |