lib/backup_report.rb in keepitsafe-0.1.10 vs lib/backup_report.rb in keepitsafe-0.2.0

- old
+ new

@@ -1,31 +1,33 @@ -require 'mail' + +require 'mail_builder' require "socket" class BackupReport def initialize from = ENV['USER'],to = "root",mail_options = {} + backups = [] + + Keepitsafe.after_backup do |backup,values| + backups << backup + end + + start_time = Time.now capture = STDCapture.capture do yield end + end_time = Time.now # Send email report - mail = Mail.new + mail = MailBuilder.new("#{File.dirname(__FILE__)}/../email/report").build({:backups => backups, :start_time => start_time, :end_time => end_time}) mail.to to mail.from from mail.subject "Backup report" - mail.body %@ - - We are runnig on: #{Socket.gethostname} - Below is the output log. - - ---- - #{capture} - ----@ - mail.delivery_method.settings = mail.delivery_method.settings.merge(mail_options) mail.deliver! + + puts "Sent backup report to: #{to}" end end \ No newline at end of file