Sha256: f4e86d266cdd20dda07dddb93d06841084a578e6789363300cea024fc4528119

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

require 'etc'
require 'time'

module ChickenSoup
  module Email
    class Presenter
      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
        Etc.getlogin
      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
        @capistrano[: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

6 entries across 6 versions & 1 rubygems

Version Path
chicken_soup-0.5.2 lib/chicken_soup/notifiers/email/presenter.rb
chicken_soup-0.5.0 lib/chicken_soup/notifiers/email/presenter.rb
chicken_soup-0.4.1 lib/chicken_soup/notifiers/email/presenter.rb
chicken_soup-0.4.0 lib/chicken_soup/notifiers/email/presenter.rb
chicken_soup-0.3.0 lib/chicken_soup/notifiers/email/presenter.rb
chicken_soup-0.2.0 lib/chicken_soup/notifiers/email/presenter.rb