Class: Pronto::Git::Patch

Inherits:
Struct
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/pronto/git/patch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#patchObject

Returns the value of attribute patch

Returns:

  • (Object)

    the current value of patch



3
4
5
# File 'lib/pronto/git/patch.rb', line 3

def patch
  @patch
end

#repoObject

Returns the value of attribute repo

Returns:

  • (Object)

    the current value of repo



3
4
5
# File 'lib/pronto/git/patch.rb', line 3

def repo
  @repo
end

Instance Method Details

#added_linesObject



28
29
30
# File 'lib/pronto/git/patch.rb', line 28

def added_lines
  lines.select(&:addition?)
end

#additionsObject



8
9
10
# File 'lib/pronto/git/patch.rb', line 8

def additions
  stat[0]
end

#blame(lineno) ⇒ Object



16
17
18
# File 'lib/pronto/git/patch.rb', line 16

def blame(lineno)
  repo.blame(new_file_path, lineno)
end

#deleted_linesObject



32
33
34
# File 'lib/pronto/git/patch.rb', line 32

def deleted_lines
  lines.select(&:deletion?)
end

#deletionsObject



12
13
14
# File 'lib/pronto/git/patch.rb', line 12

def deletions
  stat[1]
end

#linesObject



20
21
22
23
24
25
26
# File 'lib/pronto/git/patch.rb', line 20

def lines
  @lines ||= begin
    hunks.flat_map do |hunk|
      hunk.lines.map { |line| Line.new(line, self, hunk) }
    end
  end
end

#new_file_full_pathObject



36
37
38
# File 'lib/pronto/git/patch.rb', line 36

def new_file_full_path
  repo.path.join(new_file_path)
end