Skip to content

Commit

Permalink
Basic Merb support
Browse files Browse the repository at this point in the history
  • Loading branch information
wvanbergen committed Jan 27, 2009
1 parent 9bec38d commit 61e8900
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
20 changes: 17 additions & 3 deletions lib/request_log_analyzer/file_format/merb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions spec/integration/command_line_usage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 61e8900

Please sign in to comment.