Class: Autoproj::Reporter

Inherits:
Autobuild::Reporter
  • Object
show all
Defined in:
lib/autoproj/reporter.rb

Overview

Subclass of Autobuild::Reporter, used to display a message when the build finishes/fails.

Instance Method Summary collapse

Instance Method Details

#elapsed_timeObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/autoproj/reporter.rb', line 69

def elapsed_time
    return unless @timer_start

    secs = Time.now - @timer_start
    return if secs < 1

    [[60, "sec"], [60, "min"], [24, "hour"], [1000, "day"]].map do |count, name|
        if secs > 0
            secs, n = secs.divmod(count)
            next if (val = n.to_i) == 0

            "#{val} #{val > 1 ? "#{name}s" : name}"
        end
    end.compact.reverse.join(" ")
end

#error(error) ⇒ Object



54
55
56
57
58
59
60
61
62
63
# File 'lib/autoproj/reporter.rb', line 54

def error(error)
    error_lines = error.to_s.split("\n")
    Autoproj.not_silent do
        Autoproj.message("Command failed", :bold, :red, STDERR)
        Autoproj.message(error_lines.shift.to_s, :bold, :red, STDERR)
        error_lines.each do |line|
            Autoproj.message line, STDERR
        end
    end
end

#reset_timerObject



65
66
67
# File 'lib/autoproj/reporter.rb', line 65

def reset_timer
    @timer_start = Time.now
end

#successObject



85
86
87
88
89
90
91
92
# File 'lib/autoproj/reporter.rb', line 85

def success
    elapsed_string = elapsed_time ? " (took #{elapsed_time})" : ""
    Autoproj.message("Command finished successfully at "\
                     "#{Time.now}#{elapsed_string}", :bold, :green)
    if Autobuild.post_success_message
        Autoproj.message Autobuild.post_success_message
    end
end