Permalink
Browse files

Merge pull request #68 from wapcaplet/faster-filtering

Faster filtering
  • Loading branch information...
2 parents 087092c + 19cbd05 commit 60969b0656c79c49b2894ed864a32ebefed61371 @abedra abedra committed Jan 19, 2012
Showing with 25 additions and 21 deletions.
  1. +7 −7 lib/rcov/formatters/html_erb_template.rb
  2. +18 −14 lib/rcov/templates/index.html.erb
@@ -19,10 +19,10 @@ def render
end
def coverage_threshold_classes(percentage)
- return 110 if percentage == 100
- return (1..10).find_all{|i| i * 10 > percentage}.map{|i| i.to_i * 10} * " "
+ return '_110' if percentage == 100
+ return (1..10).find_all{|i| i * 10 > percentage}.map{|i| "_#{i*10}"} * " "
end
-
+
def code_coverage_html(code_coverage_percentage, is_total=false)
%{<div class="percent_graph_legend"><tt class='#{ is_total ? 'coverage_total' : ''}'>#{ "%3.2f" % code_coverage_percentage }%</tt></div>
<div class="percent_graph">
@@ -34,11 +34,11 @@ def code_coverage_html(code_coverage_percentage, is_total=false)
def file_filter_classes(file_path)
file_path.split('/')[0..-2] * " "
end
-
+
def relative_filename(path)
@path_relativizer[path]
end
-
+
def line_css(line_number)
case fileinfo.coverage[line_number]
when true
@@ -55,8 +55,8 @@ def method_missing(key, *args)
end
def get_binding
- binding
+ binding
end
end
end
-end
+end
@@ -31,12 +31,12 @@
<label>Code Coverage Threshold:</label>
<select id="coverage_filter" class="filter">
<option value="all_coverage">Show All</option>
- <% (1..10).each do |i| %><option value="<%= i * 10 %>">&lt; <%= i * 10 %>% Coverage</option><% end %>
- <option value="110">= 100% Coverage</option>
+ <% (1..10).each do |i| %><option value="_<%= i * 10 %>">&lt; <%= i * 10 %>% Coverage</option><% end %>
+ <option value="_110">= 100% Coverage</option>
</select>
</fieldset>
</div>
-
+
<div class="report_table_wrapper">
<table class='report' id='report_table'>
<thead>
@@ -70,22 +70,26 @@
</tbody>
</table>
</div>
-
+
<p>Generated on <%= generated_on %> with <a href="<%= rcov::UPSTREAM_URL %>">rcov <%= rcov::VERSION %></a></p>
<script type="text/javascript">
- $(document).ready(function(){$("#report_table").tablesorter({widgets: ['zebra'], textExtraction: 'complex'});});
+ $(document).ready(function(){
+ $("#report_table").tablesorter({widgets: ['zebra'], textExtraction: 'complex'});
+ }
+ );
$('.filter').change(function(){
- ff = $('#file_filter').val();
- cf = $('#coverage_filter').val();
- $('table#report_table tbody tr').each(function(i){
- if ((this.className.split(" ").indexOf(ff) > -1) && (this.className.split(" ").indexOf(cf) > -1)) {
- this.style.display = "";
- } else {
- this.style.display = "none";
- };
+ ff = '.' + $('#file_filter').val();
+ cf = '.' + $('#coverage_filter').val();
+ rows = 'table#report_table tbody tr';
+ // Hide all rows that don't match the filters
+ $(rows).not(cf).map(function() { $(this).hide(); });
+ $(rows).not(ff).map(function() { $(this).hide(); });
+ // Show and restripe all rows that match both filters
+ $(rows).filter(cf).filter(ff).each(function() {
+ $(this).show();
restripe();
- })
+ });
})
</script>

0 comments on commit 60969b0

Please sign in to comment.