Class: Pronto::Punchlist

Inherits:
Runner
  • Object
show all
Defined in:
lib/pronto/punchlist.rb,
lib/pronto/punchlist/driver.rb,
lib/pronto/punchlist/file_classifier.rb,
lib/pronto/punchlist/message_creator.rb,
lib/pronto/punchlist/offense_matcher.rb,
lib/pronto/punchlist/patch_inspector.rb,
lib/pronto/punchlist/patch_validator.rb

Overview

Performs incremental quality reporting for the punchlist gem

Defined Under Namespace

Classes: Error, FileClassifier, MessageCreator, OffenseMatcher, PatchInspector, PatchValidator, PunchlistDriver

Instance Method Summary collapse

Constructor Details

#initialize(patches, commit = nil, regexp_string: ::Punchlist::Config .default_punchlist_line_regexp_string, punchlist_regexp: Regexp.new(regexp_string), punchlist_driver: PunchlistDriver.new(punchlist_regexp), patch_inspector: PatchInspector.new(punchlist_driver: punchlist_driver), patch_validator: PatchValidator.new) ⇒ Punchlist

Returns a new instance of Punchlist.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/pronto/punchlist.rb', line 12

def initialize(patches, commit = nil,
               regexp_string: ::Punchlist::Config
                 .default_punchlist_line_regexp_string,
               punchlist_regexp: Regexp.new(regexp_string),
               punchlist_driver: PunchlistDriver.new(punchlist_regexp),
               patch_inspector: PatchInspector.new(punchlist_driver:
                                                     punchlist_driver),
               patch_validator: PatchValidator.new)
  super(patches, commit)
  @patch_inspector = patch_inspector
  @patch_validator = patch_validator
end

Instance Method Details

#inspect_patch(patch) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/pronto/punchlist.rb', line 34

def inspect_patch(patch)
  if valid_patch?(patch)
    @patch_inspector.inspect_patch(patch)
  else
    []
  end
end

#runObject



26
27
28
# File 'lib/pronto/punchlist.rb', line 26

def run
  @patches.flat_map { |patch| inspect_patch(patch) }
end

#valid_patch?(patch) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/pronto/punchlist.rb', line 30

def valid_patch?(patch)
  @patch_validator.valid_patch?(patch)
end