diff --git a/lib/request_log_analyzer/file_format/merb.rb b/lib/request_log_analyzer/file_format/merb.rb index dbbdbfcf..0bd254e5 100644 --- a/lib/request_log_analyzer/file_format/merb.rb +++ b/lib/request_log_analyzer/file_format/merb.rb @@ -14,8 +14,8 @@ class Merb < Base # ~ Params: {"_method"=>"delete", "authenticity_token"=>"[FILTERED]", "action"=>"d} line_definition :params do |line| line.teaser = /Params/ - line.regexp = /Params\:\ \{(.+)\}/ - line.captures << { :name => :raw_hash, :type => :string} + line.regexp = /Params\:\ (\{.+\})/ + line.captures << { :name => :action, :type => :params} end # ~ {:dispatch_time=>0.006117, :after_filters_time=>6.1e-05, :before_filters_time=>0.000712, :action_time=>0.005833} @@ -31,7 +31,21 @@ class Merb < Base report do |analyze| - # FIX ME + analyze.timespan :line_type => :started + analyze.hourly_spread :line_type => :started + + analyze.duration :dispatch_time, :category => :action, :title => 'Request dispatch duration' + # analyze.duration :action_time, :category => :action, :title => 'Request action duration' + # analyze.duration :after_filters_time, :category => :action, :title => 'Request after_filter duration' + # analyze.duration :before_filters_time, :category => :action, :title => 'Request before_filter duration' + end + + + class Request < RequestLogAnalyzer::Request + def convert_params(value, definition) + hash = eval(value) rescue {} + "#{hash['controller']}##{hash['action']}" + end end end diff --git a/spec/integration/command_line_usage_spec.rb b/spec/integration/command_line_usage_spec.rb index ed4a098b..826fa5f4 100644 --- a/spec/integration/command_line_usage_spec.rb +++ b/spec/integration/command_line_usage_spec.rb @@ -63,4 +63,9 @@ output.all? { |line| /^[\x00-\x7F]*$/ =~ line }.should be_true end + it "should parse a Merb file if --format merb is set" do + output = run("#{log_fixture(:merb)} --format merb") + output.detect { |line| /Parsed requests\:\s*11/ =~ line }.should_not be_nil + end + end \ No newline at end of file