class Gemometer::Notifiers::Smtp

Attributes

domain[R]
gems[R]
password[R]
port[R]
scheme[R]
sender[R]
server[R]
to[R]
username[R]

Public Class Methods

new(opts) click to toggle source
# File lib/gemometer/notifiers/smtp.rb, line 8
def initialize(opts)
  @gems     = opts[:gems]
  @to       = opts[:to]
  @sender   = ENV['SMTP_SENDER']
  @server   = ENV['SMTP_SERVER']
  @port     = ENV['SMTP_PORT'] || SMTP.default_port
  @domain   = ENV['SMTP_DOMAIN']
  @username = ENV['SMTP_USERNAME']
  @password = ENV['SMTP_PASSWORD']
  @scheme   = ENV['SMTP_AUTH_SCHEME'] || :plain # :plain, :login, or :cram_md5
end

Public Instance Methods

body() click to toggle source
# File lib/gemometer/notifiers/smtp.rb, line 45
def body
  msg = '<p>Outdated gems:</p><ul>'
  gems.each { |g| msg += "<li>#{ruby_gems_link(g.name)} #{g.message_line}</li>" }
  msg += '</ul>'
end
header() click to toggle source
# File lib/gemometer/notifiers/smtp.rb, line 31
      def header
%{
From: Gemometer <#{sender}>
To: #{to.join(",")}
MIME-Version: 1.0
Content-Type: text/html; charset=utf-8
Subject: Some gems are Outdated
}
      end
message() click to toggle source
# File lib/gemometer/notifiers/smtp.rb, line 27
def message
  header + body
end
notify() click to toggle source
# File lib/gemometer/notifiers/smtp.rb, line 20
def notify

  Net::SMTP.start(server, port, domain, username, password, scheme) do |smtp|
    smtp.send_message(message, sender, to)
  end
end

Private Instance Methods