Class: Yamlint::Linter
- Inherits:
-
Object
- Object
- Yamlint::Linter
- Defined in:
- lib/yamlint/linter.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config = nil) ⇒ Linter
constructor
A new instance of Linter.
- #lint(content, filepath: nil) ⇒ Object
- #lint_file(filepath) ⇒ Object
Constructor Details
#initialize(config = nil) ⇒ Linter
Returns a new instance of Linter.
10 11 12 |
# File 'lib/yamlint/linter.rb', line 10 def initialize(config = nil) @config = config || Config.load_default end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/yamlint/linter.rb', line 8 def config @config end |
Instance Method Details
#lint(content, filepath: nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/yamlint/linter.rb', line 14 def lint(content, filepath: nil) context = build_context(content, filepath) syntax_problems = check_syntax(content, filepath) return syntax_problems unless syntax_problems.empty? parse_content(context) rules = build_rules rules.each do |rule| problems = rule.check(context) context.problems.concat(Array(problems)) end filter_disabled_problems(context) end |
#lint_file(filepath) ⇒ Object
31 32 33 34 |
# File 'lib/yamlint/linter.rb', line 31 def lint_file(filepath) content = File.read(filepath) lint(content, filepath:) end |