Class: Diecut::ReportBuilders::OrphanedField
Instance Attribute Summary
#mill
Instance Method Summary
collapse
all_kinds, #build_report, #each_default, #each_option, #each_plugin, #each_template, #fail_advice, #fail_summary, #go, #initialize, #other_summary, #pass_advice, #pass_summary, register, #report, #review, #strict_sequence?, #unindent
Instance Method Details
#collect ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# 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 ⇒ Object
52
53
54
55
56
57
58
59
60
|
# 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 ⇒ Object
10
11
12
|
# File 'lib/diecut/report-builders/orphaned-field.rb', line 10
def report_fields
["Output field", "Source file"]
end
|
#report_name ⇒ Object
6
7
8
|
# File 'lib/diecut/report-builders/orphaned-field.rb', line 6
def report_name
"Template fields all have settings"
end
|
#report_status ⇒ Object
47
48
49
|
# File 'lib/diecut/report-builders/orphaned-field.rb', line 47
def report_status
report.empty? ? "OK" : "WARN"
end
|