Class: StackProf::Webnav::Presenter
- Inherits:
-
Object
- Object
- StackProf::Webnav::Presenter
- Defined in:
- lib/stackprof-webnav/presenter.rb
Instance Attribute Summary collapse
-
#report ⇒ Object
readonly
Returns the value of attribute report.
Instance Method Summary collapse
- #file_overview(path) ⇒ Object
-
#initialize(report) ⇒ Presenter
constructor
A new instance of Presenter.
- #method_info(name) ⇒ Object
- #overview_frames ⇒ Object
Constructor Details
#initialize(report) ⇒ Presenter
Returns a new instance of Presenter.
9 10 11 |
# File 'lib/stackprof-webnav/presenter.rb', line 9 def initialize report @report = report end |
Instance Attribute Details
#report ⇒ Object (readonly)
Returns the value of attribute report.
8 9 10 |
# File 'lib/stackprof-webnav/presenter.rb', line 8 def report @report end |
Instance Method Details
#file_overview(path) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/stackprof-webnav/presenter.rb', line 13 def file_overview path buffer = StringIO.new report.print_file(path, buffer) data = buffer.string.split("\n").map {|l| l.split('|').first} { :lineinfo => data, :code => BetterErrors::CodeFormatter::HTML.new(path, 0, 9999).output } end |
#method_info(name) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/stackprof-webnav/presenter.rb', line 37 def method_info name name = /#{Regexp.escape name}/ unless Regexp === name frames = report.frames.select do |frame, info| info[:name] =~ name end.map do |frame, info| file, line = info.values_at(:file, :line) { :callers => callers(frame, info), :callees => callees(frame, info), :location => file, :source => BetterErrors::CodeFormatter::HTML.new(file, line).output } end end |
#overview_frames ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/stackprof-webnav/presenter.rb', line 24 def overview_frames report.frames.map do |frame, info| call, total = info.values_at(:samples, :total_samples) { :total => total, :total_pct => percent(total.to_f/report.overall_samples), :samples => call, :samples_pct => percent(call.to_f/report.overall_samples), :method => info[:name] } end end |