class PrSummary::FileDiff
Attributes
diff[R]
filename[R]
Public Class Methods
new(filename:, diff:)
click to toggle source
# File lib/pr_summary/file_diff.rb, line 7 def initialize(filename:, diff:) @filename = filename @diff = diff end
Public Instance Methods
changes_display()
click to toggle source
# File lib/pr_summary/file_diff.rb, line 20 def changes_display str = "" str << "#{insertions}(+)" if insertions str << "#{deletions}(-)" if deletions str end
deletions()
click to toggle source
# File lib/pr_summary/file_diff.rb, line 16 def deletions file_changes[__method__] end
insertions()
click to toggle source
# File lib/pr_summary/file_diff.rb, line 12 def insertions file_changes[__method__] end
md5_file()
click to toggle source
# File lib/pr_summary/file_diff.rb, line 35 def md5_file Digest::MD5.new.update(filename).to_s end
truncated_name()
click to toggle source
# File lib/pr_summary/file_diff.rb, line 27 def truncated_name if filename.length > MAX_FILE_NAME_LENGTH "..." + filename[(filename.length-(MAX_FILE_NAME_LENGTH-3))..-1] else filename end end
Private Instance Methods
file_changes()
click to toggle source
# File lib/pr_summary/file_diff.rb, line 41 def file_changes @file_changes ||= begin text = PrSummary::Git::Diff.new(diff: diff).shortstat(filename) { insertions: find_number_before(text, "insertion"), deletions: find_number_before(text, "deletion") } end end
find_number_before(text, word)
click to toggle source
# File lib/pr_summary/file_diff.rb, line 51 def find_number_before(text, word) text.scan(/(\d+) #{word}/)[0][0].to_i rescue nil end