Permalink
Browse files

Fixed parsing of printer choice

  • Loading branch information...
1 parent a12d587 commit 266573e3d247667602d5b10f184c763cd84ec78b @runeb runeb committed Dec 10, 2008
Showing with 19 additions and 6 deletions.
  1. +19 −6 lib/rack/profiler.rb
View
@@ -1,4 +1,4 @@
-gem 'ruby-prof', '>= 0.7.1'
+gem 'ruby-prof', '>= 0.7.3'
require 'ruby-prof'
require 'set'
@@ -27,11 +27,7 @@ class Profiler
# defaulting to :calltree.
def initialize(app, options = {})
@app = app
-
- @printer = options[:printer] || RubyProf::CallTreePrinter
- unless @printer.is_a?(Class)
- @printer = RubyProf.const_get("#{@printer.to_s.upcase}Printer")
- end
+ @printer = parse_printer(options) || RubyProf::CallTreePrinter
end
def call(env)
@@ -82,5 +78,22 @@ def headers(printer, env, mode)
end
headers
end
+
+ def parse_printer(options)
+ return options[:printer] if options[:printer].is_a?(Class)
+
+ case options[:printer]
+ when :calltree
+ RubyProf::CallTreePrinter
+ when :graphhtml
+ RubyProf::GraphHtmlPrinter
+ when :grap
+ RubyProf::GraphPrinter
+ when :flat
+ RubyProf::FlatPrinter
+ else
+ nil
+ end
+ end
end
end

0 comments on commit 266573e

Please sign in to comment.