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
22
23
24
# 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

  has_template = !entry.template.nil?
  is_external  = entry.derived? && entry.external?
  is_intake    = entry.intake?
  return unless entry.in_generator_zone? && !has_template && !is_external && !is_intake &&
                %w[markdown text].include?(entry.format) && !entry.nested?

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