class Pronto::BigFiles::PatchInspector

Inspects patches and returns a Pronto::Message class when appropriate

Public Class Methods

new(bigfiles_result, message_creator_class: MessageCreator, bigfiles_config:) click to toggle source
# File lib/pronto/bigfiles/patch_inspector.rb, line 11
def initialize(bigfiles_result,
               message_creator_class: MessageCreator,
               bigfiles_config:)
  @message_creator_class = 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

Public Instance Methods

inspect_patch(patch_wrapper) click to toggle source
# 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.create_message(patch_wrapper, file_with_line.num_lines)
end
total_lines() click to toggle source
# File lib/pronto/bigfiles/patch_inspector.rb, line 27
def total_lines
  @bigfiles_result.map(&:num_lines).reduce(:+)
end
under_limit?() click to toggle source
# File lib/pronto/bigfiles/patch_inspector.rb, line 23
def under_limit?
  @bigfiles_config.under_limit?(total_lines)
end