Sha256: c4682116ea1e96e646f77dd6eada3b2e83da0827fca605bf283c36dca4125764

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

# Author::    Nicolas Pouillard  <ertai@lrde.epita.fr>.
# Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
# License::   GNU General Public License (GPL).
# Revision::  $Id: header 98 2004-09-29 12:07:43Z ertai $

require 'vcs'
require 'sendmail'

class Vcs

  MAIL = Sendmail::MAIL_FILE
  MAILER = Sendmail.new
  DEFAULT_OPTIONS = %w[ --ask --sign --mime ]

  #
  # Mail.
  #
  def mail ( *args )
    error_handling :mail_failed
    unless MAIL.exist?
      print_body(MAIL, MAILER.parse_mail_options(*(DEFAULT_OPTIONS + args)))
    end
    MAILER.sendmail
    MAIL.delete
    StringIO.new('Mail: Sent.')
  end

  def mail_failed
    if defined? MAIL and MAIL.exist?
      LOG.info "#{MAIL}: Contains the generated mail " +
               "(generated from #{@@message})"
    end
  end

  def mail_conf_checker
    %w[ EMAIL FULLNAME SMTPSERVER ].each do |var|
      if ENV[var].nil? or ENV[var].empty?
        LOG.error "environment variable `#{var}' not set"
      end
    end
    unless `gpg --version` =~ /^gpg \(GnuPG\)/
      LOG.error 'command not found: gpg'
    end
    unless File.exist?("#{ENV['HOME']}/.gnupg/secring.gpg")
      LOG.error 'no private key: in your ~/.gnupg'
    end
  end

  add_conf_checker :mail_conf_checker

end # class Vcs

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vcs-0.2.148 src/mail.rb