Class: Pronto::Git::Patches

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/pronto/git/patches.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo, commit, patches) ⇒ Patches


8
9
10
11
12
# File 'lib/pronto/git/patches.rb', line 8

def initialize(repo, commit, patches)
  @repo = repo
  @commit = commit
  @patches = patches.map { |patch| Git::Patch.new(patch, repo) }
end

Instance Attribute Details

#commitObject (readonly)

Returns the value of attribute commit


6
7
8
# File 'lib/pronto/git/patches.rb', line 6

def commit
  @commit
end

#repoObject (readonly)

Returns the value of attribute repo


6
7
8
# File 'lib/pronto/git/patches.rb', line 6

def repo
  @repo
end

Instance Method Details

#each(&block) ⇒ Object


14
15
16
# File 'lib/pronto/git/patches.rb', line 14

def each(&block)
  @patches.each(&block)
end

#find_line(path, line) ⇒ Object


18
19
20
21
22
# File 'lib/pronto/git/patches.rb', line 18

def find_line(path, line)
  patch = find { |p| p.new_file_full_path == path }
  lines = patch ? patch.lines : []
  lines.find { |l| l.new_lineno == line }
end