class Diecut::ReportBuilders::OrphanedField

Public Instance Methods

collect() click to toggle source
# File lib/diecut/report-builders/orphaned-field.rb, line 14
def collect
  context_class = mill.context_class

  required_fields = {}

  context_class.field_names.each do |field_name|
    if context_class.field_metadata(field_name).is?(:required)
      required_fields[field_name.to_s] = []
    end
  end

  each_template do |name, template|
    template.reduced.leaf_fields.each do |field|
      field = field.join(".")
      if required_fields.has_key?(field)
        required_fields[field] << template.path
      end
    end
  end

  each_option do |option, plugin|
    next unless option.has_context_path?
    field = option.context_path.join(".")
    required_fields.delete(field)
  end

  required_fields.each do |name, targets|
    targets.each do |target|
      report.add(name, target)
    end
  end
end
other_advice() click to toggle source
# File lib/diecut/report-builders/orphaned-field.rb, line 52
      def other_advice
        <<-EOA
        These fields might not receive a value during generation, which will
        raise an error at use time.

        It's possible these fields are set in a resolve block in one of the
        plugins - Diecut can't check for that yet.
        EOA
      end
report_fields() click to toggle source
# File lib/diecut/report-builders/orphaned-field.rb, line 10
def report_fields
  ["Output field", "Source file"]
end
report_name() click to toggle source
# File lib/diecut/report-builders/orphaned-field.rb, line 6
def report_name
  "Template fields all have settings"
end
report_status() click to toggle source
# File lib/diecut/report-builders/orphaned-field.rb, line 47
def report_status
  report.empty? ? "OK" : "WARN"
end