Sha256: 851c7526dd899801f1c895c276b92bc1381860cacb02323b4cce57d57d297ee5

Contents?: true

Size: 1.9 KB

Versions: 1

Compression:

Stored size: 1.9 KB

Contents

require 'reap/hosts/host'
require 'reap/emailer'

module Reap
module Hosts

  # = Mailinglist
  #
  # Gerneic Mailing list "host". Mailinglist hosts
  # support the @announce@ task.

  class Mailinglist < Host

    register('mailinglist')

    # Email message. Options are:
    #
    #   message     Message to send.
    #   mailto      Email address to whom to mail.
    #   from        Email address from whom.
    #   subject     Subject line (default is "ANN: project version").
    #   server      Email server
    #   port        Emails server port (default is usually correct).
    #   account     Email account name (defaults to from).
    #   domain      User domain (not sure why SMTP requires this?)
    #   login       Login type (plain, login)
    #   secure      Use TLS/SSL true or false?

    def announce(options)
      options = announce_options(options)

      subject = options[:subject]
      mailto  = options[:mailto] || options[:to]
      to      = [mailto].flatten.join(", ")

      if dryrun?
        puts "email '#{subject}' to #{to}"
      else
        emailer = Emailer.new(options)
        emailer.email
      end
    end

    # Confirm announcement

    def announce_confirm?(options)
      options = announce_options(options)

      if mailto = options[:mailto] || options[:to]
        return true if force?
        to  = [mailto].flatten.join(", ")
        ans = ask("Announce to #{to}?", "yN")
        case ans.downcase
        when 'y', 'yes'
          true
        else
          false
        end
      end
    end

    #

    def announce_options(options)
      options  = options.rekey
      environ  = Emailer.environment_options
      defaults = project.defaults['email'].rekey

      result = {}
      result.update(defaults)
      result.update(environ)
      result.update(options)

      result[:subject] = (result[:subject] % [metadata.unixname, metadata.version])

      result
    end

  end

end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reap-9.4.0 lib/reap/hosts/mailinglist.rb