module WTF
Public Class Methods
files_path()
click to toggle source
# 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()
click to toggle source
# File lib/wtf-tools.rb, line 11 def options @options ||= {} end
options=(value)
click to toggle source
# File lib/wtf-tools.rb, line 7 def options=(value) @options = value end
output_options()
click to toggle source
# File lib/wtf-tools.rb, line 24 def output_options Hash(options[:output]) end
sql(*args)
click to toggle source
# File lib/wtf-tools.rb, line 41 def sql(*args) WTF::QueryTracker.start_tracking(*args) end
time(*args) { || ... }
click to toggle source
# 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) { || ... }
click to toggle source
TODO: separately track ActiveRecord finders usage in the related methods
# File lib/wtf-tools.rb, line 29 def track(*objects) WTF::MethodTracker.start_tracking(*objects) if block_given? yield track_finish end end
track_finish()
click to toggle source
# File lib/wtf-tools.rb, line 37 def track_finish WTF::MethodTracker.finish end