Module: Textus::Manifest::Entry::Validators::FormatMatrix

Defined in:
lib/textus/manifest/entry/validators/format_matrix.rb

Class Method Summary collapse

Class Method Details

.call(entry) ⇒ Object

Raises:



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/textus/manifest/entry/validators/format_matrix.rb', line 6

def self.call(entry)
  begin
    Textus::Entry.for_format(entry.format).validate_path_extension(entry.path, entry.nested)
  rescue UsageError => e
    raise UsageError.new("entry '#{entry.key}': #{e.message}")
  end

  if entry.format == "text" && !entry.schema.nil?
    raise UsageError.new("entry '#{entry.key}': text format must not declare a schema")
  end

  return unless entry.in_generator_zone? && entry.template.nil? && entry.generator.nil? &&
                %w[markdown text].include?(entry.format) && !entry.nested

  raise UsageError.new("entry '#{entry.key}': derived #{entry.format} entries require a template")
end