Class: GroongaQueryLog::Command::RunRegressionTest::MailNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga-query-log/command/run-regression-test.rb

Instance Method Summary collapse

Constructor Details

#initialize(success, elapsed_time, options) ⇒ MailNotifier

Returns a new instance of MailNotifier.



656
657
658
659
660
661
# File 'lib/groonga-query-log/command/run-regression-test.rb', line 656

def initialize(success, elapsed_time, options)
  @success = success
  @elapsed_time = elapsed_time
  @options = options
  @path = @options[:path] || "results"
end

Instance Method Details

#notifyObject



663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
# File 'lib/groonga-query-log/command/run-regression-test.rb', line 663

def notify
  return unless @options[:mail_to]

  output = StringIO.new
  formetter = FormatRegressionTestLogs.new(output: output)
  formetter.run([@path])
  formatted_log = output.string

  if @success
    subject = @options[:mail_subject_on_success]
  else
    subject = @options[:mail_subject_on_failure]
  end
  content = format_elapsed_time
  content << "Report:\n"
  content << formatted_log
  send_mail(subject, content)
end