Class: Pronto::Punchlist::PatchInspector

Inherits:
Object
  • Object
show all
Defined in:
lib/pronto/punchlist/patch_inspector.rb

Overview

Inspects a patch and reports any relevant offenses

Instance Method Summary collapse

Constructor Details

#initialize(punchlist_driver:, offense_matcher_class: OffenseMatcher) ⇒ PatchInspector

Returns a new instance of PatchInspector.



10
11
12
13
14
# File 'lib/pronto/punchlist/patch_inspector.rb', line 10

def initialize(punchlist_driver:,
               offense_matcher_class: OffenseMatcher)
  @punchlist_driver = punchlist_driver
  @offense_matcher_class = offense_matcher_class
end

Instance Method Details

#inspect_patch(patch) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/pronto/punchlist/patch_inspector.rb', line 16

def inspect_patch(patch)
  path = patch.new_file_full_path

  offenses = @punchlist_driver.inspect_filename(path)

  messages = []
  offenses.each do |offense|
    offense_matcher = @offense_matcher_class.new(offense)
    message = offense_matcher.inspect_patch(patch)
    messages << message unless message.nil?
  end
  messages
end