Sha256: b86f38f5ef880f5b4b2ae79354044adce1b712252e64ac3583ff0eaafa2cd013

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

require File.dirname(__FILE__) + '/notifyio_client.rb'
require 'httparty'
require 'md5'

module Integrity
  class Notifier
    class Notifyio < Notifier::Base
      attr_reader :config

      def self.to_haml
        @haml ||= File.read(File.dirname(__FILE__) + "/config.haml")
      end

      def deliver!
        post(config['email'], config['api_key'], short_message, full_message)
      end

      def to_s
        'Notifyio'
      end
      
      private
      
      def post(emails, api_key, title, body)
        emails.split(',').each do |email|
          email_hash = MD5.hexdigest(email.strip!)
          HTTParty.post "http://api.notify.io/v1/notify/#{email_hash}?api_key=#{api_key}", :body => {
                                                                                                      :type => 'regular',
                                                                                                      :title => title,
                                                                                                      :body => body,
                                                                                                      :generator => 'integrity-notifyio notifier' 
                                                                                                    }
          
        end
      end
      
    end

    register Notifyio
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
integrity-notifyio-0.1.5 lib/integrity/notifier/notifyio.rb
integrity-notifyio-0.1.4 lib/integrity/notifier/notifyio.rb