Class: Pronto::BigFiles::PatchInspector
- Inherits:
-
Object
- Object
- Pronto::BigFiles::PatchInspector
- Defined in:
- lib/pronto/bigfiles/patch_inspector.rb
Overview
Inspects patches and returns a Pronto::Message class when appropriate
Instance Method Summary collapse
-
#initialize(bigfiles_result, message_creator_class: MessageCreator, bigfiles_config:) ⇒ PatchInspector
constructor
A new instance of PatchInspector.
- #inspect_patch(patch_wrapper) ⇒ Object
- #total_lines ⇒ Object
- #under_limit? ⇒ Boolean
Constructor Details
#initialize(bigfiles_result, message_creator_class: MessageCreator, bigfiles_config:) ⇒ PatchInspector
Returns a new instance of PatchInspector.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pronto/bigfiles/patch_inspector.rb', line 11 def initialize(bigfiles_result, message_creator_class: MessageCreator, bigfiles_config:) @message_creator_class = @bigfiles_result = bigfiles_result @bigfiles_config = bigfiles_config @message_creator = @message_creator_class.new(@bigfiles_config.num_files, total_lines, @bigfiles_config.high_water_mark) end |
Instance Method Details
#inspect_patch(patch_wrapper) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pronto/bigfiles/patch_inspector.rb', line 31 def inspect_patch(patch_wrapper) path = patch_wrapper.path file_with_line = @bigfiles_result.find { |f| f.filename == path } return if file_with_line.nil? return unless patch_wrapper.added_to? return if under_limit? @message_creator.(patch_wrapper, file_with_line.num_lines) end |
#total_lines ⇒ Object
27 28 29 |
# File 'lib/pronto/bigfiles/patch_inspector.rb', line 27 def total_lines @bigfiles_result.map(&:num_lines).reduce(:+) end |
#under_limit? ⇒ Boolean
23 24 25 |
# File 'lib/pronto/bigfiles/patch_inspector.rb', line 23 def under_limit? @bigfiles_config.under_limit?(total_lines) end |