rake-timer 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/rake_timer.rb +4 -3
  2. data/lib/version.rb +1 -1
  3. metadata +3 -3
@@ -2,7 +2,7 @@ require 'socket'
2
2
 
3
3
  # time_tasks :to => [:csv, :statsd], :unit => :milliseconds, :host => 'localhost', :port => 8125
4
4
  def time_tasks(options = {})
5
- Thread.current[:time_options] = options
5
+ Thread.current[:time_options] = options.merge(:enabled => true)
6
6
  end
7
7
 
8
8
  class RakeTimer
@@ -10,6 +10,7 @@ class RakeTimer
10
10
  class << self
11
11
 
12
12
  def time(task_name)
13
+ yield and return unless config[:enabled] || task_name == "metrics:all"
13
14
  start = Time.now
14
15
  result = yield
15
16
  record(task_name, Time.now - start)
@@ -20,10 +21,10 @@ class RakeTimer
20
21
  unit = config[:unit] || :milliseconds
21
22
  if unit == :seconds
22
23
  output_time = time
23
- puts "#{task_name} took #{sprintf("%.3f", output_time)} seconds"
24
+ $stderr.puts "#{task_name} took #{sprintf("%.3f", output_time)} seconds"
24
25
  else
25
26
  output_time = time * 1000
26
- puts "#{task_name} took #{output_time} milliseconds"
27
+ $stderr.puts "#{task_name} took #{output_time} milliseconds"
27
28
  end
28
29
  output_options = config[:to] || {}
29
30
  as_csv(task_name, output_time) if output_options.include? :csv
@@ -1,3 +1,3 @@
1
1
  module RakeTimer
2
- VERSION = "0.0.2".freeze
2
+ VERSION = "0.0.3".freeze
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Peter Moran
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-20 00:00:00 +11:00
17
+ date: 2011-02-22 00:00:00 +11:00
18
18
  default_executable:
19
19
  dependencies: []
20
20