lib/autobuild/reporting.rb in autobuild-1.5.0 vs lib/autobuild/reporting.rb in autobuild-1.5.1

- old
+ new

@@ -72,16 +72,12 @@ def self.each_reporter(&iter) @@reporters.each(&iter) end ## Iterate on all log files - def self.each_log - Find.find(Autobuild.logdir) do |path| - if File.file?(path) && path =~ /\.log$/ - yield(path) - end - end + def self.each_log(&block) + Autobuild.logfiles.each(&block) end end ## Base class for reporters class Reporter @@ -158,19 +154,28 @@ name = file[Autobuild.logdir.size..-1] mail.add_file(name, file) end # Send the mails - smtp = Net::SMTP.new(smtp_hostname, smtp_port) - smtp.start { - to_email.each do |email| - mail.header.to = email - smtp.send_mail RMail::Serialize.write('', mail), from_email, email - end - } + if File.directory?(File.dirname(smtp_hostname)) + File.open(smtp_hostname, 'w') do |io| + io.puts "From: #{from_email}" + io.puts "To: #{to_email.join(" ")}" + io.write RMail::Serialize.write('', mail) + end + puts "saved notification email in #{smtp_hostname}" + else + smtp = Net::SMTP.new(smtp_hostname, smtp_port) + smtp.start { + to_email.each do |email| + mail.header.to = email + smtp.send_mail RMail::Serialize.write('', mail), from_email, email + end + } - # Notify the sending - puts "Sent notification mail to #{to_email} with source #{from_email}" + # Notify the sending + puts "sent notification mail to #{to_email} with source #{from_email}" + end end end end module RMail