lib/stash/pull_request/diff.rb in face_control-0.5.1 vs lib/stash/pull_request/diff.rb in face_control-0.6.0
- old
+ new
@@ -1,10 +1,10 @@
module Stash
class PullRequest
class Diff
- def initialize(raw_diff)
- @raw_diff = raw_diff
+ def initialize(diff)
+ @diff = diff
end
def added_line?(file, line)
added_lines(file).include?(line)
end
@@ -13,20 +13,20 @@
def added_lines(file)
@added_lines ||= {}
@added_lines[file] ||= begin
file_diff(file)['hunks'].map do |hunk|
- hunk['segments'].select{ |segment| segment['type'] == 'ADDED' }.map do |segment|
+ hunk['segments'].select{|segment| segment['type'] == 'ADDED' }.map do |segment|
segment['lines'].map do |line|
line['destination']
end
end
end.flatten
end
end
def file_diff(file)
- @raw_diff['diffs'].detect{ |diff| diff['destination'] && diff['destination']['toString'] == file } || {'hunks' => []}
+ @diff['diffs'].detect{|diff| diff['destination'] && diff['destination']['toString'] == file } || {'hunks' => []}
end
end
end
end