Module: WTF
- Defined in:
- lib/wtf-tools.rb,
lib/wtf/dumper.rb,
lib/wtf/query_tracker.rb,
lib/wtf/method_tracker.rb
Defined Under Namespace
Modules: MethodTracker, QueryTracker
Classes: Dumper
Class Method Summary
collapse
Class Method Details
.files_path ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/wtf-tools.rb', line 15
def files_path
if options[:files]
dirs = FileUtils.mkdir_p(options[:files])
dirs.first
else
Dir.getwd
end
end
|
.options ⇒ Object
11
12
13
|
# File 'lib/wtf-tools.rb', line 11
def options
@options ||= {}
end
|
.options=(value) ⇒ Object
7
8
9
|
# File 'lib/wtf-tools.rb', line 7
def options=(value)
@options = value
end
|
.output_options ⇒ Object
24
25
26
|
# File 'lib/wtf-tools.rb', line 24
def output_options
Hash(options[:output])
end
|
.time(*args) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/wtf-tools.rb', line 45
def time(*args)
require 'absolute_time'
precision = args.shift if args.first.is_a?(Fixnum)
precision ||= 3
before = AbsoluteTime.now
result = yield
duration = AbsoluteTime.now - before
WTF::Dumper.new(duration.round(precision), *args).call
result
end
|
.track(*objects) ⇒ Object
TODO: separately track ActiveRecord finders usage in the related methods
29
30
31
32
33
34
35
|
# File 'lib/wtf-tools.rb', line 29
def track(*objects)
WTF::MethodTracker.start_tracking(*objects)
if block_given?
yield
track_finish
end
end
|