Sha256: c0fa141b153d054485c11b56b82883ec16f8433677783579c10b07a74b4f44a9
Contents?: true
Size: 924 Bytes
Versions: 41
Compression:
Stored size: 924 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
41 entries across 41 versions & 2 rubygems