Class: CI::Syntax::Tool::Language::YAML
- Defined in:
- lib/ci-syntax-tool/language/yaml.rb
Overview
CI::Syntax::Tool::Language::Base
Base class for syntax checkers. Sketches out the
API you need if you want to add a language.
Instance Method Summary collapse
-
#check_file(file_result) ⇒ Object
Called once for each file being checked.
- #default_globs ⇒ Object
-
#initialize(args) ⇒ YAML
constructor
Args is a hash, contents unspecified as yet.
Methods inherited from Base
#check_ending, #check_starting, #combined_globs, descendant_classes
Constructor Details
#initialize(args) ⇒ YAML
Args is a hash, contents unspecified as yet.
13 14 15 |
# File 'lib/ci-syntax-tool/language/yaml.rb', line 13 def initialize(args) super end |
Instance Method Details
#check_file(file_result) ⇒ Object
Called once for each file being checked.
path [String] - path to filename to check file_result [Result::File] - Results object for the outcome. Returns: Result::File
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ci-syntax-tool/language/yaml.rb', line 25 def check_file(file_result) begin ::YAML.load(File.read(file_result.path)) rescue Psych::SyntaxError => e file_result.add_issue( line_number: e.line, character: e.column, level: :error, raw_message: e.problem, ) end end |
#default_globs ⇒ Object
17 18 19 |
# File 'lib/ci-syntax-tool/language/yaml.rb', line 17 def default_globs ['**/*.yaml', '**/*.yml'] end |