Class: Gemometer::Notifiers::Smtp
- Inherits:
-
Object
- Object
- Gemometer::Notifiers::Smtp
- Defined in:
- lib/gemometer/notifiers/smtp.rb
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#gems ⇒ Object
readonly
Returns the value of attribute gems.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#scheme ⇒ Object
readonly
Returns the value of attribute scheme.
-
#sender ⇒ Object
readonly
Returns the value of attribute sender.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #body ⇒ Object
- #header ⇒ Object
-
#initialize(opts) ⇒ Smtp
constructor
A new instance of Smtp.
- #message ⇒ Object
- #notify ⇒ Object
Constructor Details
#initialize(opts) ⇒ Smtp
Returns a new instance of Smtp.
8 9 10 11 12 13 14 15 16 17 18 |
# 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 |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
6 7 8 |
# File 'lib/gemometer/notifiers/smtp.rb', line 6 def domain @domain end |
#gems ⇒ Object (readonly)
Returns the value of attribute gems.
6 7 8 |
# File 'lib/gemometer/notifiers/smtp.rb', line 6 def gems @gems end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
6 7 8 |
# File 'lib/gemometer/notifiers/smtp.rb', line 6 def password @password end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
6 7 8 |
# File 'lib/gemometer/notifiers/smtp.rb', line 6 def port @port end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
6 7 8 |
# File 'lib/gemometer/notifiers/smtp.rb', line 6 def scheme @scheme end |
#sender ⇒ Object (readonly)
Returns the value of attribute sender.
6 7 8 |
# File 'lib/gemometer/notifiers/smtp.rb', line 6 def sender @sender end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
6 7 8 |
# File 'lib/gemometer/notifiers/smtp.rb', line 6 def server @server end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
6 7 8 |
# File 'lib/gemometer/notifiers/smtp.rb', line 6 def to @to end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
6 7 8 |
# File 'lib/gemometer/notifiers/smtp.rb', line 6 def username @username end |
Instance Method Details
#body ⇒ Object
45 46 47 48 49 |
# 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 ⇒ Object
31 32 33 34 35 36 37 38 39 |
# 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 ⇒ Object
27 28 29 |
# File 'lib/gemometer/notifiers/smtp.rb', line 27 def header + body end |
#notify ⇒ Object
20 21 22 23 24 25 |
# File 'lib/gemometer/notifiers/smtp.rb', line 20 def notify Net::SMTP.start(server, port, domain, username, password, scheme) do |smtp| smtp.(, sender, to) end end |