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

Instance Method Summary collapse

Constructor Details

#initialize(patch_text, numstat_map = {}) ⇒ PatchFileParser

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.

Returns a new instance of PatchFileParser.



510
511
512
513
514
515
# File 'lib/git/parsers/diff.rb', line 510

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

Instance Method Details

#parse

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.



517
518
519
520
521
# File 'lib/git/parsers/diff.rb', line 517

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