Sha256: 0cbe45fc71317c73011fb6a050fcbf4331940de91083f8a0bcbed2393c3c2db5

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

module Capistrano
  module Blaze
    class Message

      def self.start(context)
        new(context).start
      end

      def self.failure(context, exception)
        new(context, exception).failure
      end

      def self.success(context)
        new(context).success
      end

      def self.test(context)
        new(context).test
      end

      attr_reader :context, :exception

      def initialize(context, exception = nil)
        @context, @exception = context, exception
      end

      def start
        speak "#{user} is deploying #{what}, via `#{command}`"
      end

      def failure
        speak ":warning: #{user} failed to deploy #{what}, via `#{command}`: #{exception_message}"
      end

      def success
        speak "#{user} succesfully deployed #{what}, via `#{command}`"
      end

      def test
        speak ":heart: #{context.application}!"
      end

      private

      def exception_message
        "#{exception.to_s} (#{exception.class.inspect})"
      end

      def speak(message)
        Blaze.speak(message)
      end

      def what
        stage + context.application
      end

      def stage
        if context.respond_to?(:stage)
          "to the #{context.stage} stage of "
        else
          ""
        end
      end

      def user
        `whoami`.strip
      end

      def command
        [ 'cap', *ARGV ] * ' '
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capistrano-blaze-0.2.0 lib/capistrano/blaze/message.rb