Methods
B
C
D
E
F
G
H
L
N
P
R
S
Constants
DEFAULT_SENDER = %("CapGun" <cap_gun@example.com>)
DEFAULT_EMAIL_PREFIX = "[DEPLOY]"
Attributes
[RW] capistrano
Class Public methods
new(capistrano)
# File lib/cap_gun/presenter.rb, line 10
    def initialize(capistrano)
      self.capistrano = capistrano
    end
Instance Public methods
body()
# File lib/cap_gun/presenter.rb, line 112
    def body
"\#{summary}\n\#{comment}\nDeployment details\n==================\nRelease: \#{capistrano[:current_release]}\nRelease Time: \#{release_time}\nRelease Revision: \#{capistrano[:current_revision]}\n\nPrevious Release: \#{capistrano[:previous_release]}\nPrevious Release Time: \#{previous_release_time}\nPrevious Release Revision: \#{capistrano[:previous_revision]}\n\nRepository: \#{capistrano[:repository]}\nDeploy path: \#{capistrano[:deploy_to]}\nDomain: \#{capistrano[:domain]}\n\#{git_details}\n"
    end
branch()
# File lib/cap_gun/presenter.rb, line 40
    def branch
      "Branch: #{capistrano[:branch]}" unless capistrano[:branch].nil? || capistrano[:branch].empty?
    end
comment()
# File lib/cap_gun/presenter.rb, line 108
    def comment
      "Comment: #{capistrano[:comment]}.\n" if capistrano[:comment]
    end
convert_from_utc(timestamp)

Use some DateTime magicrey to convert UTC to the current time zone When the whole world is on Rails 2.1 (and therefore new ActiveSupport) we can use the magic timezone support there.

# File lib/cap_gun/presenter.rb, line 81
    def convert_from_utc(timestamp)
      # we know Capistrano release timestamps are UTC, but Ruby doesn't, so make it explicit
      utc_time = timestamp << "UTC" 
      datetime = DateTime.parse(utc_time)
      datetime.new_offset(local_datetime_zone_offset)
    end
current_user()
# File lib/cap_gun/presenter.rb, line 27
    def current_user
      Etc.getlogin
    end
deployed_to()
# File lib/cap_gun/presenter.rb, line 35
    def deployed_to
      return "deployed to #{capistrano[:rails_env]}" if capistrano[:rails_env]
      "deployed"
    end
email_prefix()
# File lib/cap_gun/presenter.rb, line 19
    def email_prefix
      capistrano[:cap_gun_email_envelope][:email_prefix] || DEFAULT_EMAIL_PREFIX
    end
exit_code()
# File lib/cap_gun/presenter.rb, line 64
    def exit_code
      $?
    end
from()
# File lib/cap_gun/presenter.rb, line 23
    def from
      capistrano[:cap_gun_email_envelope][:from] || DEFAULT_SENDER
    end
git_details()
# File lib/cap_gun/presenter.rb, line 44
    def git_details
      return unless capistrano[:scm].to_sym == :git
      "\#{branch}\n\#{git_log}\n"
      rescue
        nil
    end
git_log()
# File lib/cap_gun/presenter.rb, line 55
    def git_log
      "\nCommits since last release\n====================\n#{git_log_messages}"
    end
git_log_messages()
# File lib/cap_gun/presenter.rb, line 59
    def git_log_messages
      messages = `git log #{capistrano[:previous_revision]}..#{capistrano[:current_revision]} --pretty=format:%h:%s`
      exit_code.success? ? messages : "N/A"
    end
humanize_release_time(path)

Gives you a prettier date/time for output from the standard Capistrano timestamped release directory. This assumes Capistrano uses UTC for its date/timestamped directories, and converts to the local machine timezone.

# File lib/cap_gun/presenter.rb, line 71
    def humanize_release_time(path)
      return unless path
      match = path.match(/(\d+)$/)
      return unless match
      local = convert_from_utc(match[1])
      local.strftime("%B #{local.day.ordinalize}, %Y %l:%M %p #{local_timezone}").gsub(/\s+/, ' ').strip
    end
local_datetime_zone_offset()
# File lib/cap_gun/presenter.rb, line 88
    def local_datetime_zone_offset
      @local_datetime_zone_offset ||= DateTime.now.offset
    end
local_timezone()
# File lib/cap_gun/presenter.rb, line 92
    def local_timezone
      @current_timezone ||= Time.now.zone
    end
previous_release_time()
# File lib/cap_gun/presenter.rb, line 100
    def previous_release_time 
      humanize_release_time(capistrano[:previous_release])
    end
recipients()
# File lib/cap_gun/presenter.rb, line 15
    def recipients
      capistrano[:cap_gun_email_envelope][:recipients]
    end
release_time()
# File lib/cap_gun/presenter.rb, line 96
    def release_time
      humanize_release_time(capistrano[:current_release])
    end
subject()
# File lib/cap_gun/presenter.rb, line 104
    def subject
      "#{email_prefix} #{capistrano[:application]} #{deployed_to}"
    end
summary()
# File lib/cap_gun/presenter.rb, line 31
    def summary
      %[#{capistrano[:application]} was #{deployed_to} by #{current_user} at #{release_time}.]
    end