Sha256: 4cc5f597bc13837079bdc952ee35ab3660e08c58ac5a62bf1d38c70f587166f5

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

require 'time'

module ChickenSoup
  module Email
    class Presenter
      include ChickenSoup

      LongDateFormat = "%A, %B %e, %Y at %l:%M%p %Z"

      def initialize(capistrano)
        @capistrano = capistrano
      end

      def application
        @capistrano[:application].titleize
      end

      def environment
        @capistrano[:rails_env].titleize
      end

      def deployed_by
        @capistrano[:local_user]
      end

      def deploy_date_in_long_format
        format_timestamp(@capistrano[:current_release], LongDateFormat)
      end

      def previous_deploy_date_in_long_format
        format_timestamp(@capistrano[:previous_release], LongDateFormat)
      end

      def notifiers
        @capistrano[:notifiers].join(", ")
      end

      def changes_since_last_deployment
        vc_log
      end

      private
      def format_timestamp(capistrano_timestamp, format)
        timestamp = convert_capistrano_timestamp(capistrano_timestamp)
        timestamp.strftime(format)
      end

      def convert_capistrano_timestamp(capistrano_timestamp)
        begin
          Date.strptime(capistrano_timestamp, "%Y%m%d%H%M%S")
        rescue
          Date.today
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chicken_soup-0.6.1 lib/chicken_soup/notifiers/email/presenter.rb
chicken_soup-0.6.0 lib/chicken_soup/notifiers/email/presenter.rb