Skip to content

Commit

Permalink
Use Forwardable in Git::Patch
Browse files Browse the repository at this point in the history
  • Loading branch information
mmozuras committed Sep 10, 2014
1 parent 565345e commit befc3e7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
1 change: 1 addition & 0 deletions lib/pronto.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'rugged'
require 'forwardable'

require 'pronto/git/repository'
require 'pronto/git/patches'
Expand Down
2 changes: 0 additions & 2 deletions lib/pronto/git/line.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'forwardable'

module Pronto
module Git
class Line < Struct.new(:line, :patch, :hunk)
Expand Down
16 changes: 6 additions & 10 deletions lib/pronto/git/patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
module Pronto
module Git
class Patch < Struct.new(:patch, :repo)
def delta
patch.delta
end
extend Forwardable

def hunks
patch.hunks
end
def_delegators :patch, :delta, :hunks, :stat

def additions
patch.stat[0]
stat[0]
end

def deletions
patch.stat[1]
stat[1]
end

def blame(lineno)
Expand All @@ -25,7 +21,7 @@ def blame(lineno)

def lines
@lines ||= begin
patch.map do |hunk|
hunks.map do |hunk|
hunk.lines.map { |line| Line.new(line, self, hunk) }
end.flatten.compact
end
Expand All @@ -41,7 +37,7 @@ def deleted_lines

def new_file_full_path
repo_path = Pathname.new(repo.path).parent
repo_path.join(patch.delta.new_file[:path])
repo_path.join(delta.new_file[:path])
end
end
end
Expand Down

0 comments on commit befc3e7

Please sign in to comment.