Class: Antwort::CLI::Send
- Inherits:
-
Object
- Object
- Antwort::CLI::Send
- Includes:
- Thor::Shell
- Defined in:
- lib/antwort/cli/send.rb
Instance Attribute Summary collapse
-
#build_id ⇒ Object
readonly
Returns the value of attribute build_id.
-
#html_body ⇒ Object
readonly
Returns the value of attribute html_body.
-
#mail ⇒ Object
readonly
Returns the value of attribute mail.
-
#recipient ⇒ Object
readonly
Returns the value of attribute recipient.
-
#sender ⇒ Object
readonly
Returns the value of attribute sender.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
-
#initialize(build_id, options = {}) ⇒ Send
constructor
A new instance of Send.
-
#send ⇒ Object
rubocop:disable Metrics/MethodLength.
Constructor Details
#initialize(build_id, options = {}) ⇒ Send
Returns a new instance of Send.
21 22 23 24 25 26 27 28 |
# File 'lib/antwort/cli/send.rb', line 21 def initialize(build_id, = {}) @build_id = build_id @html_body = File.open("build/#{build_id}/#{template_name}.html").read @recipient = ([:recipient] || ENV['SEND_TO']).split(',') @sender = [:from] || ENV['SEND_FROM'] @subject = [:subject] || '[Test] ' << extract_title(@html_body) end |
Instance Attribute Details
#build_id ⇒ Object (readonly)
Returns the value of attribute build_id.
8 9 10 |
# File 'lib/antwort/cli/send.rb', line 8 def build_id @build_id end |
#html_body ⇒ Object (readonly)
Returns the value of attribute html_body.
8 9 10 |
# File 'lib/antwort/cli/send.rb', line 8 def html_body @html_body end |
#mail ⇒ Object (readonly)
Returns the value of attribute mail.
8 9 10 |
# File 'lib/antwort/cli/send.rb', line 8 def mail @mail end |
#recipient ⇒ Object (readonly)
Returns the value of attribute recipient.
8 9 10 |
# File 'lib/antwort/cli/send.rb', line 8 def recipient @recipient end |
#sender ⇒ Object (readonly)
Returns the value of attribute sender.
8 9 10 |
# File 'lib/antwort/cli/send.rb', line 8 def sender @sender end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
8 9 10 |
# File 'lib/antwort/cli/send.rb', line 8 def subject @subject end |
Instance Method Details
#send ⇒ Object
rubocop:disable Metrics/MethodLength
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/antwort/cli/send.rb', line 31 def send # because scope changes inside mail DSL mail_from = @sender mail_to = @recipient mail_subject = @subject # setup email @mail = Mail.new do from mail_from to mail_to subject mail_subject text_part do body 'This is plain text' end html_part do content_type 'text/html' body @html_body end end # send email if @mail.deliver! say "Sent Email \"#{template_name}\" at #{Time.now.strftime('%d.%m.%Y %H:%M')}", :green say " to: #{@recipient}" say " subject: #{@subject}" say " html: #{build_id}/#{template_name}.html" else say "Error sending #{build_id}/#{template_name} at #{Time.now.strftime('%d.%m.%Y %H:%M')}", :red end end |