Module: Hoe::Email
- Defined in:
- lib/hoe/email.rb
Overview
Email plugin for Hoe.
Instance Attribute Summary collapse
-
#email_to ⇒ Object
readonly
Who to send email to.
Instance Method Summary collapse
-
#define_email_tasks ⇒ Object
Define email tasks.
-
#initialize_email ⇒ Object
Initialize the email plugin.
Instance Attribute Details
#email_to ⇒ Object (readonly)
Who to send email to.
19 20 21 |
# File 'lib/hoe/email.rb', line 19 def email_to @email_to end |
Instance Method Details
#define_email_tasks ⇒ Object
Define email tasks.
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 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/hoe/email.rb', line 33 def define_email_tasks require 'net/smtp' begin require 'smtp_tls' rescue LoadError end # attach to announcements task :announce => :send_email task :post_blog => :send_email # force email to the front desc "Send an announcement email." task :send_email do warn "sending email" = generate_email :full with_config do |conf, _| host = conf["email"]["host"] port = conf["email"]["port"] user = conf["email"]["user"] pass = conf["email"]["pass"] auth = conf["email"]["auth"] tls = conf["email"]["tls"] port = Socket.getservbyname port unless Integer === port tls = port != 25 if tls.nil? start_args = [Socket.gethostname, user, pass, auth].compact raise 'gem install smtp_tls' if tls and not Net::SMTP.method_defined? :starttls smtp = Net::SMTP.new(host, port) smtp.set_debug_output $stderr if $DEBUG smtp.enable_starttls if tls smtp.start(*start_args) do |server| server. , Array(email).first, *email_to end end warn "...done" end end |
#initialize_email ⇒ Object
Initialize the email plugin. Get the email/to from hoe’s config.
24 25 26 27 28 |
# File 'lib/hoe/email.rb', line 24 def initialize_email with_config do |config, _| @email_to = config["email"]["to"] rescue nil end end |