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

Returns a new instance of 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



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

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

#reject(&block) ⇒ Object



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

def reject(&block)
  Pronto::Git::Patches.new(repo, commit, @patches.reject(&block))
end