Class: Canvas::ValidBlockSchemasCheck

Inherits:
Check
  • Object
show all
Defined in:
lib/canvas/checks/valid_block_schemas_check.rb

Overview

:documented: This check will validate the schema defined in the front matter within each block template file.

Example of block Liquid with valid front matter:


my_title:

type: string

my_color:

type: color
label: My color
hint: "Select your favourite color"

<p>My block HTML</p>

Instance Attribute Summary

Attributes inherited from Check

#offenses

Instance Method Summary collapse

Methods inherited from Check

#failed?, #initialize

Constructor Details

This class inherits a constructor from Canvas::Check

Instance Method Details

#runObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/canvas/checks/valid_block_schemas_check.rb', line 22

def run
  custom_types = Canvas::FetchCustomTypes.call
  block_files.each do |filename|
    front_matter = extract_front_matter(filename)
    next unless front_matter

    validate_format(filename, front_matter) &&
      validate_schema(filename, front_matter, custom_types)
  end
end