Class: Makit::Yaml

Inherits:
Object
  • Object
show all
Defined in:
lib/makit/yaml.rb

Overview

YAML file validation utilities

This class provides methods for validating YAML file syntax and structure, helping to catch configuration errors early.

Class Method Summary collapse

Class Method Details

.validate_yaml(file_path) ⇒ nil

Validate YAML file syntax and structure

Attempts to parse a YAML file to verify it has valid syntax. Prints a success message if valid, raises an error if invalid.

Parameters:

  • file_path (String)

    Path to the YAML file to validate

Returns:

  • (nil)

    Prints success message if validation passes

Raises:

  • (RuntimeError)

    If YAML syntax is invalid



22
23
24
25
26
27
# File 'lib/makit/yaml.rb', line 22

def self.validate_yaml(file_path)
  YAML.load_file(file_path)
  puts "#{file_path} is a valid YAML file."
rescue Psych::SyntaxError => e
  raise "YAML validation failed for #{file_path}: #{e}"
end