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

#patch ⇒ Object

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

#repo ⇒ Object

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_lines ⇒ Object



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

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

#additions ⇒ Object



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_lines ⇒ Object



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

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

#deletions ⇒ Object



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

def deletions
  stat[1]
end

#lines ⇒ Object



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_path ⇒ Object



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

def new_file_full_path
  repo.path.join(new_file_path)
end

#new_file_path ⇒ Object



40
41
42
# File 'lib/pronto/git/patch.rb', line 40

def new_file_path
  delta.new_file[:path]
end