Class: PreCommit::Checks::Yaml
- Defined in:
- lib/plugins/pre_commit/checks/yaml.rb
Overview
The Yaml check will read and parse YAML files to ensure they have valid syntax.
Instance Attribute Summary
Attributes inherited from Plugin
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Plugin
Constructor Details
This class inherits a constructor from PreCommit::Checks::Plugin
Class Method Details
.description ⇒ Object
13 14 15 |
# File 'lib/plugins/pre_commit/checks/yaml.rb', line 13 def self.description 'Runs yaml to detect errors.' end |
Instance Method Details
#call(staged_files) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/plugins/pre_commit/checks/yaml.rb', line 17 def call(staged_files) staged_files = staged_files.grep(/\.(yml|yaml)$/) return if staged_files.empty? errors = staged_files.map {|file| load_file(file)}.compact errors.join("\n") + "\n" unless errors.empty? end |