lib/stack_tracy.rb in stack_tracy-0.1.8 vs lib/stack_tracy.rb in stack_tracy-0.1.9
- old
+ new
@@ -1,7 +1,7 @@
+require RUBY_VERSION == "1.8.7" ? "fastercsv" : "csv"
require "erb"
-require "csv"
require "tmpdir"
require "securerandom"
require "rich/support/core/string/colorize"
require "launchy"
@@ -12,11 +12,11 @@
module StackTracy
extend self
PRESETS = {
- :core => "Array BasicObject Enumerable Fixnum Float Hash IO Integer Kernel Module Mutex Numeric Object Rational String Symbol Thread Time",
+ :core => "Array #{"BasicObject " unless RUBY_VERSION == "1.8.7"}Enumerable Fixnum Float Hash IO Integer Kernel Module #{"Mutex " unless RUBY_VERSION == "1.8.7"}Numeric Object Rational String Symbol Thread Time",
:active_record => "ActiveRecord::Base",
:data_mapper => "DataMapper::Resource"
}
@options = Struct.new(:dump_dir, :dump_source_location, :limit, :threshold, :messages_only, :slows_only, :only, :exclude).new(Dir::tmpdir, false, 7500, 0.001, false, false)
@@ -72,10 +72,10 @@
path = File.join [path || @options.dump_dir, "stack_events-#{SecureRandom.hex(3)}.csv"].compact
end
File.expand_path(path).tap do |path|
bool = dump_source_location.nil? ? @options[:dump_source_location] : dump_source_location
keys = [:event, (:file if bool), (:line if bool), :singleton, :object, :method, :nsec, :time, :call, :depth, :duration]
- CSV.open(path, "w", :col_sep => ";") do |file|
+ (RUBY_VERSION == "1.8.7" ? FasterCSV : CSV).open(path, "w", :col_sep => ";") do |file|
file << keys
select(only).each do |event|
file << event.values_at(*keys)
end
end
\ No newline at end of file