Class: Git::Parsers::Diff::Patch::PatchFileParser Private

Inherits:
Object
  • Object
show all
Includes:
PatchMetadataParser
Defined in:
lib/git/parsers/diff.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Stateful parser for unified diff patch output

API:

  • private

Instance Method Summary collapse

Constructor Details

#initialize(patch_text, numstat_map = {})

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes parser state for a patch text block

Parameters:

  • unified diff patch text

  • (defaults to: {})

    path to insert/delete stats

API:

  • private



676
677
678
679
680
681
# File 'lib/git/parsers/diff.rb', line 676

def initialize(patch_text, numstat_map = {})
  @patch_text = patch_text
  @numstat_map = numstat_map
  @files = []
  @current_file = nil
end

Instance Method Details

#parseArray<Git::DiffFilePatchInfo>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parses patch text into file patch info objects

Returns:

API:

  • private



687
688
689
690
691
# File 'lib/git/parsers/diff.rb', line 687

def parse
  @patch_text.split("\n").each { |line| process_line(line) }
  finalize_current_file
  @files
end