Sha256: 9f41565abfd641ab5de0434ec86dea5f1841dcab427f6d7ddc4b13585e8ad978

Contents?: true

Size: 675 Bytes

Versions: 1

Compression:

Stored size: 675 Bytes

Contents

require 'net/smtp'

module Travis
  module Notifications
    class Email
      EVENTS = 'build:finished'

      def notify(event, object, *args)
        send_emails(object) if object.send_email_notifications?
      end

      protected

        def send_emails(object)
          email(object).deliver
        rescue Errno::ECONNREFUSED, Net::SMTPError => e
          puts e.message, e.backtrace
        end

        def email(object)
          mailer(object).send(:"#{object.state}_email", object, object.email_recipients)
        end

        def mailer(object)
          Travis::Mailer.const_get(object.class.name.gsub('Travis::Model::', ''))
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
travis-core-0.0.1 lib/travis/notifications/email.rb