Class: Diecut::ReportBuilders::OptionCollisions

Inherits:
Diecut::ReportBuilder show all
Defined in:
lib/diecut/report-builders/option-collision.rb

Instance Attribute Summary

Attributes inherited from Diecut::ReportBuilder

#mill

Instance Method Summary collapse

Methods inherited from Diecut::ReportBuilder

all_kinds, #build_report, #each_default, #each_option, #each_plugin, #each_template, #go, #initialize, #other_advice, #other_summary, #pass_advice, #pass_summary, register, #report, #report_status, #review, #strict_sequence?, #unindent

Constructor Details

This class inherits a constructor from Diecut::ReportBuilder

Instance Method Details

#collectObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/diecut/report-builders/option-collision.rb', line 16

def collect
  option_targets = Hash.new{|h,k| h[k]=[]}
  each_option do |option, plugin|
    next unless option.has_context_path?
    option_targets[option.context_path] << [plugin, option]
  end
  option_targets.each_value do |set|
    if set.length > 1
      set.each do |plugin, option|
        report.add(option.context_path.join("."), option.name, plugin.name)
      end
    end
  end
end

#fail_adviceObject



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/diecut/report-builders/option-collision.rb', line 35

def fail_advice
  (<<-EOA)
    This is problem because two options in the user interface both change
    rendered values. If a user supplies both with different values, the
    output isn't predictable (either one might take effect).

    Most likely, this is a simple error: remove options from each group
    that targets the same rendered value until only one remains. It may
    also be that one option has a typo - that there's a rendering target
    that's omitted.
  EOA
end

#fail_summaryObject



31
32
33
# File 'lib/diecut/report-builders/option-collision.rb', line 31

def fail_summary
  "Multiple options assign the same values to be rendered"
end

#report_fieldsObject



12
13
14
# File 'lib/diecut/report-builders/option-collision.rb', line 12

def report_fields
  ["Output target", "Option name", "Source plugin"]
end

#report_nameObject



8
9
10
# File 'lib/diecut/report-builders/option-collision.rb', line 8

def report_name
  "Option collisions"
end