Sha256: f7b0f359a13fa70e7d002d41f46de3a86b7572b4ffce6c4e2e2026de92f225b4

Contents?: true

Size: 1.24 KB

Versions: 28

Compression:

Stored size: 1.24 KB

Contents

# encoding: utf-8

require 'rake/common/classes'
require 'rake/helpers/rake'

module Rake
  module Delphi
    class Sendmail < BasicTask

        def initialize(task, opts)
            super(task)
            cmd = ''
            predefined = { :from => '-f', :"from.full" => '-F', :extra => nil, :to => nil }
            predefined.keys.sort{|a, b| a.to_s <=> b.to_s}.each do |k|
                cmd += "#{predefined[k]} #{opts[k]} " if opts[k]
            end
            cmd = "#{sendmail} -i #{cmd}"
            Logger.trace(Logger::VERBOSE, cmd)
            if @task.application.windows? && Rake.ruby18?
                require 'win32/open3'
            else
                require 'open3'
            end
            Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
                stdin.puts(opts[:text])
                stdin.close
                while s = stdout.gets
                    puts s
                end
                while s = stderr.gets
                    puts s
                end
            end
        end

        def sendmail
            if @task.application.unix?
                "sendmail"
            else
                ENV['SENDMAIL']
            end
        end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
rake-delphi-0.0.13 lib/rake/common/sendmailtask.rb
rake-delphi-0.0.12 lib/rake/common/sendmailtask.rb
rake-delphi-0.0.11 lib/rake/common/sendmailtask.rb
rake-delphi-0.0.9 lib/rake/common/sendmailtask.rb
rake-delphi-0.0.8 lib/rake/common/sendmailtask.rb
rake-delphi-0.0.7 lib/rake/common/sendmailtask.rb
rake-delphi-0.0.6 lib/rake/common/sendmailtask.rb
rake-delphi-0.0.5 lib/rake/common/sendmailtask.rb