Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim committed Oct 10, 2013
1 parent e2bfce9 commit fbe94a0
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions lib/capistrano/notifier/mail.rb
Expand Up @@ -87,33 +87,31 @@ def from
cap.notifier_mail_options[:from]
end

def github_commit_prefix
"#{github_prefix}/commit"
def git_commit_prefix
"#{git_prefix}/commit"
end

def github_compare_prefix
"#{github_prefix}/compare"
def git_compare_prefix
"#{git_prefix}/compare"
end

def github_prefix
prefix = gitlab
prefix ||= "https://github.com/#{github}"
prefix
def git_prefix
giturl ? giturl : "https://github.com/#{github}"
end

def github
cap.notifier_mail_options[:github]
end

def gitlab
cap.notifier_mail_options[:gitlab]
def giturl
cap.notifier_mail_options[:giturl]
end

def html
body.gsub(
/([0-9a-f]{7})\.\.([0-9a-f]{7})/, "<a href=\"#{github_compare_prefix}/\\1...\\2\">\\1..\\2</a>"
/([0-9a-f]{7})\.\.([0-9a-f]{7})/, "<a href=\"#{git_compare_prefix}/\\1...\\2\">\\1..\\2</a>"
).gsub(
/^([0-9a-f]{7})/, "<a href=\"#{github_commit_prefix}/\\0\">\\0</a>"
/^([0-9a-f]{7})/, "<a href=\"#{git_commit_prefix}/\\0\">\\0</a>"
)
end

Expand All @@ -130,7 +128,7 @@ def subject
end

def text
body.gsub(/([0-9a-f]{7})\.\.([0-9a-f]{7})/, "#{github_compare_prefix}/\\1...\\2")
body.gsub(/([0-9a-f]{7})\.\.([0-9a-f]{7})/, "#{git_compare_prefix}/\\1...\\2")
end

def to
Expand Down

0 comments on commit fbe94a0

Please sign in to comment.