Class: Diecut::Linter

Inherits:
Object
  • Object
show all
Defined in:
lib/diecut/linter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#millObject (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_defaultObject



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_optionObject



52
53
54
55
56
57
58
# File 'lib/diecut/linter.rb', line 52

def each_option
  each_plugin do |plugin|
    plugin.options.each do |option|
      yield option, plugin
    end
  end
end

#each_pluginObject



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

#reportObject



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