0
@@ -17,6 +17,7 @@ module ComparisonsHelper
0
lines.each_with_index do |line, offset|
0
classes = ["line_#{offset + 1}"]
0
+ classes << "first-line" if offset == 0
0
if options[:errors] && line =~ /^-:(\d+):/
0
classes << "code_error code_error_line_#{$1}"
0
@@ -29,28 +30,35 @@ module ComparisonsHelper
0
+ def show_output(text
, html_options={})
0
- content_tag(:td, 'No output', :class =>
:blank)
0
+ content_tag(:td, 'No output', :class =>
"#{html_options[:class]} blank")
0
- content_tag(:td, format_output(text)
)
0
+ content_tag(:td, format_output(text)
, html_options={})
0
- def benchmark_info_for(comparison)
0
- if (errors = comparison.results.select { |r| !r.success? }).any?
0
- return content_tag(:span, "Error in #{errors.map(&:version).to_sentence}", :class => 'bad-result')
0
- results = comparison.results.sort_by(&:real_time)
0
+ def benchmark_info_for(*results)
0
+ options = results.last.is_a?(Hash) ? results.pop : {}
0
+ results = results.sort_by(&:real_time)
0
longest = results.last.real_time
0
+ has_errors = results.any? { |r| !r.success? }
0
- percent = r.real_time / longest * 100
0
- content_tag(:li, "#{r.version} <span class='time'>#{'%.8f' % r.real_time}s</span>",
0
- :class => (r.id == results.first.id ? 'winner' : 'loser'),
0
- :style => "width:#{percent}%;")
0
+ if !options[:only] || options[:only].id == r.id
0
+ content_tag(:span, "Error#{options[:only] ? '' : ' in ' + r.version}", :class => 'bad-result')
0
+ percent = r.real_time / longest * 100
0
+ content_tag(:li, "#{r.version unless options[:only]} <span class='time'>#{'%.8f' % r.real_time}s</span>",
0
+ :class => (r.id == results.first.id ? 'winner' : 'loser'),
0
+ :style => "width:#{percent}%;")
0
+ :class => "bars bars-#{has_errors ? 'with-errors' : 'without-errors'}")