Class: Diecut::Linter
- Inherits:
-
Object
- Object
- Diecut::Linter
- Defined in:
- lib/diecut/linter.rb
Instance Attribute Summary collapse
-
#mill ⇒ Object
readonly
Returns the value of attribute mill.
Instance Method Summary collapse
- #each_default ⇒ Object
- #each_option ⇒ Object
- #each_plugin ⇒ Object
-
#initialize(mill) ⇒ Linter
constructor
A new instance of Linter.
- #report ⇒ Object
-
#unindent(text) ⇒ Object
Needed: Overridden option defaults (without plugin dep) Option with default, context with default (w/o PD).
Constructor Details
#initialize(mill) ⇒ Linter
Returns a new instance of Linter.
11 12 13 |
# File 'lib/diecut/linter.rb', line 11 def initialize(mill) @mill = mill end |
Instance Attribute Details
#mill ⇒ Object (readonly)
Returns the value of attribute mill.
14 15 16 |
# File 'lib/diecut/linter.rb', line 14 def mill @mill end |
Instance Method Details
#each_default ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/diecut/linter.rb', line 44 def each_default each_plugin do |plugin| plugin.context_defaults.each do |default| yield default, plugin end end end |
#each_option ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/diecut/linter.rb', line 52 def each_option each_plugin do |plugin| plugin..each do |option| yield option, plugin end end end |
#each_plugin ⇒ Object
38 39 40 41 42 |
# File 'lib/diecut/linter.rb', line 38 def each_plugin mill.mediator.activated_plugins.each do |plugin| yield plugin end end |
#report ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/diecut/linter.rb', line 16 def report @ui = mill.user_interface reports = ReportBuilder.all_kinds.map do |kind| kind.new(mill).go end if Diecut.issue_handler.respond_to?(:reports) reports += Diecut.issue_handler.reports end formatter = ReportFormatter.new( reports) formatter.to_s end |
#unindent(text) ⇒ Object
Needed: Overridden option defaults (without plugin dep) Option with default, context with default (w/o PD)
33 34 35 36 |
# File 'lib/diecut/linter.rb', line 33 def unindent(text) indent = text.scan(/(^[ \t]*)\S/).map{|cap| cap.first}.max_by(&:length) text.gsub(%r{^#{indent}},'') end |