module PullRequestsHelper # 获取diff内容行号 def diff_line_num content content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.nil? ? "" : content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.join("").to_i end # 处理内容 def diff_content content content.gsub!(/.*@@ -\d+,\d+ \+\d+,\d+ @@\n/m,'') end def get_user_name user_id User.find(user_id).try(:login) end end