Sha256: fc76bf6790d74a22424e7eb4382ad33194177d8a38007b02468e272dc8fdb58d

Contents?: true

Size: 1.19 KB

Versions: 8

Compression:

Stored size: 1.19 KB

Contents

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
        @capistrano[:local_user]
      end

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

      def previous_deploy_date_in_long_format
        format_timestamp(@capistrano[:previous_release_name], 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

8 entries across 8 versions & 1 rubygems

Version Path
chicken_soup-0.9.0 lib/chicken_soup/notifiers/email/presenter.rb
chicken_soup-0.8.6 lib/chicken_soup/notifiers/email/presenter.rb
chicken_soup-0.8.5 lib/chicken_soup/notifiers/email/presenter.rb
chicken_soup-0.8.4 lib/chicken_soup/notifiers/email/presenter.rb
chicken_soup-0.8.3 lib/chicken_soup/notifiers/email/presenter.rb
chicken_soup-0.8.2 lib/chicken_soup/notifiers/email/presenter.rb
chicken_soup-0.8.1 lib/chicken_soup/notifiers/email/presenter.rb
chicken_soup-0.8.0 lib/chicken_soup/notifiers/email/presenter.rb