Sha256: 27410766d554f63431ea23dcd84b886c98c5492935d5e30e20f707beaf156a6c
Contents?: true
Size: 884 Bytes
Versions: 11
Compression:
Stored size: 884 Bytes
Contents
module Bozo::Hooks class Timing def initialize @timings = {} end def print_timings puts '' @timings.each do |stage, times| puts format_timing(stage, times).bright.color(stage == :build ? :cyan : :black) end end def format_timing(stage, args) time_taken = (args[:post] - args[:pre]).round(1) "#{stage.to_s.capitalize.ljust(14)} #{time_taken.to_s.rjust(5)}s" end def record(stage, point) @timings[stage] ||= {} @timings[stage][point] = Time.now end def method_missing(method, *args) if method.to_s =~ /^(pre|post)_(.+)/ record $2.to_sym, $1.to_sym print_timings if $1 == 'post' and $2 == 'build' else super end end def respond_to?(method) method.to_s =~ /^(pre|post)_(.+)/ or super end end end
Version data entries
11 entries across 11 versions & 1 rubygems