Skip to content

Commit

Permalink
add Views
Browse files Browse the repository at this point in the history
  • Loading branch information
chiefpansancolt committed Oct 10, 2020
1 parent 59217a0 commit 3b50253
Show file tree
Hide file tree
Showing 5 changed files with 433 additions and 0 deletions.
88 changes: 88 additions & 0 deletions views/dialog.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<div class="fixed z-10 inset-0 overflow-y-auto hidden" data-toggle-name="<%= id(file) %>">
<div class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 transition-opacity">
<div class="absolute inset-0 bg-gray-500 opacity-75"></div>
</div>

<span class="hidden sm:inline-block sm:align-middle sm:h-screen"></span>&#8203;

<div class="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle" role="dialog" aria-modal="true" aria-labelledby="modal-headline">
<div class="hidden sm:block absolute top-0 right-0 pt-4 pr-4">
<button type="button" class="text-gray-400 hover:text-gray-500 focus:outline-none focus:text-gray-500 transition ease-in-out duration-150" aria-label="Close" data-action="click->toggle#toggle touch->toggle#toggle" data-toggle-target="<%= id(file) %>">
<svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
<div class="bg-white">
<div class="sm:flex sm:items-start">
<div class="mt-3 w-full">
<h3 class=" pt-4 pl-6 text-lg leading-6 font-medium text-gray-900" id="modal-headline">
<%= shortened_filename file %>
(<span class="<%= coverage_class(file.covered_percent) %>">
<%= file.covered_percent.round(2).to_s %>%
</span>)
<% if branchable_result? %>
| Branches
(<span class="<%= coverage_class(file.covered_percent) %>">
<%= file.branches_coverage_percent.round(2).to_s %>%
</span>)
<% end %>
</h3>
<div class="mt-4 dialog-body">
<pre class="bg-gray-800 text-white whitespace-normal w-full text-xs">
<ol class="list-decimal ml-12 p-0">
<% file.lines.each do |line| %>
<li class="bg-white border-l-4 border-gray-700 py-2 pl-2 pr-4 <%= line.status %>" data-hits="<%= line.coverage ? line.coverage : '' %>"
data-linenumber="<%= line.number %>">
<% if line.covered? %>
<span class="inline-flex items-center ml-1 px-2.5 py-0.5 rounded-full text-xs font-medium leading-4 bg-gray-800 text-white float-right"><%= line.coverage %></span>
<% end %>
<% if line.skipped? %>
<span class="inline-flex items-center ml-1 px-2.5 py-0.5 rounded-full text-xs font-medium leading-4 bg-gray-800 text-white float-right">skipped</span>
<% end %>

<% if branchable_result? %>
<% file.branches_for_line(line.number).each do |branch_type, hit_count| %>
<span class="inline-flex items-center ml-1 px-2.5 py-0.5 rounded-full text-xs font-medium leading-4 bg-gray-800 text-white float-right" title="<%= branch_type%> branch hit <%= hit_count %> times">
<%= branch_type %>: <%= hit_count %>
</span>
<% end %>
<% end %>
<code class="text-cool-gray-900 whitespace-pre whitespace-pre-wrap"><%= CGI.escapeHTML(line.src.chomp) %></code>
</li>
<% end %>
</ol>
</pre>
</div>
</div>
</div>
</div>
<div class="bg-gray-50 px-4 py-3 text-xs">
<b><%= file.lines_of_code %></b>
Relevant Lines |
<span class="text-green-500"><b>
<%= format_number(file.covered_lines.count) %>
</b></span>
Lines Covered |
<span class="text-red-500"><b>
<%= format_number(file.missed_lines.count) %>
</b></span>
Lines Missed
<% if branchable_result? %>
|
<b><%= file.total_branches.count %></b>
Total Branches |
<span class="text-green-500"><b>
<%= format_number(file.covered_branches.count) %>
</b></span>
Branches Covered |
<span class="text-red-500"><b>
<%= format_number(file.missed_branches.count) %>
</b></span>
Branches Missed
<% end %>
</div>
</div>
</div>
</div>
133 changes: 133 additions & 0 deletions views/group_page.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<div class="tab-groups pt-2 pb-6 md:py-6 <%= hide_show(title_id) %>" name="<%= title_id %>">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<h1 class="text-2xl font-semibold text-gray-900">
<%= title %>
</h1>
</div>

<div class="max-w-7xl mx-auto px-6 pt-4 grid grid-cols-2 gap-5 lg:grid-cols-6 md:grid-cols-3">
<%= generate_stat_card('# of Files', format_number(files.length), 'text-gray-900') %>
<%= generate_stat_card('Relevent Lines', format_number(files.lines_of_code), 'text-gray-900') %>
<%= generate_stat_card('Lines Covered', format_number(files.covered_lines), 'text-green-500') %>
<%= generate_stat_card('Lines Missed', format_number(files.missed_lines), 'text-red-500') %>
<%= generate_stat_card('Covered', files.covered_percent.round(2).to_s + '%', coverage_class(files.covered_percent)) %>
<%= generate_stat_card('Hits/Line', files.covered_strength.round(2), strength_class(files.covered_strength)) %>
<% if branchable_result? %>
<%= generate_stat_card('Total Branches', format_number(files.total_branches), 'text-gray-900') %>
<%= generate_stat_card('Branches Covered', format_number(files.covered_branches), 'text-green-500') %>
<%= generate_stat_card('Branches Missed', format_number(files.missed_branches), 'text-red-500') %>
<%= generate_stat_card('Branches', files.branch_covered_percent.round(2).to_s + '%', coverage_class(files.branch_covered_percent)) %>
<% end %>
</div>

<div class="max-w-7xl mx-auto px-6 pt-4">
<div class="bg-white overflow-hidden shadow rounded-lg">
<div class="flex flex-col">
<div class="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
<div class="py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8">
<div class="overflow-hidden rounded-lg">
<table class="min-w-full divide-y divide-gray-200" id="<%= title_id %>-table">
<thead>
<tr>
<th class="px-2 py-3 bg-gray-50 text-left text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider clickable">
<%= generate_table_column_head('File Name') %>
</th>
<th class="px-2 py-3 bg-gray-50 text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider clickable">
<%= generate_table_column_head('% Covered') %>
</th>
<th class="px-2 py-3 bg-gray-50 text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider clickable">
<%= generate_table_column_head('Lines') %>
</th>
<th class="px-2 py-3 bg-gray-50 text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider clickable">
<%= generate_table_column_head('Relevant Files') %>
</th>
<th class="px-2 py-3 bg-gray-50 text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider clickable">
<%= generate_table_column_head('Lines Covered') %>
</th>
<th class="px-2 py-3 bg-gray-50 text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider clickable">
<%= generate_table_column_head('Lines Missed') %>
</th>
<th class="px-2 py-3 bg-gray-50 text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider clickable">
<%= generate_table_column_head('Avg Hits/Line') %>
</th>
<% if branchable_result? %>
<th class="px-2 py-3 bg-gray-50 text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider clickable">
<%= generate_table_column_head('Branch % Covered') %>
</th>
<th class="px-2 py-3 bg-gray-50 text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider clickable">
<%= generate_table_column_head('Branches') %>
</th>
<th class="px-2 py-3 bg-gray-50 text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider clickable">
<%= generate_table_column_head('Covered Branches') %>
</th>
<th class="px-2 py-3 bg-gray-50 text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider clickable">
<%= generate_table_column_head('Missed Branches') %>
</th>
<% end %>
</tr>
</thead>
<tbody>
<tr class="bg-white <%= files.length == 0 ? '' : 'hidden' %>" id="<%= title_id %>-hiderow">
<th class="px-6 py-4 text-center" colspan="<%= branchable_result? ? '11' : '7' %>">
No Results Found Please Search Again!
</th>
</tr>
<% files.each.with_index do |source_file, index| %>
<tr class="row clickable <%= index.odd? ? 'bg-gray-50' : 'bg-white' %>" data-action="click->toggle#toggle touch->toggle#toggle" data-toggle-target="<%= id(source_file) %>">
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 font-medium text-gray-900"
title="<%= shortened_filename(source_file) %>" data-sort-val="<%= shortened_filename(source_file) %>">
<%= shortened_filename(source_file) %>
</td>
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 <%= coverage_class(source_file.covered_percent) %>"
data-sort-val="<%= source_file.covered_percent.round(2).to_s %>">
<%= sprintf("%.2f", source_file.covered_percent.round(2)) %>%
</td>
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500"
data-sort-val="<%= source_file.lines.count %>">
<%= format_number(source_file.lines.count) %>
</td>
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500"
data-sort-val="<%= source_file.covered_lines.count + source_file.missed_lines.count %>">
<%= format_number(source_file.covered_lines.count + source_file.missed_lines.count) %>
</td>
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500"
data-sort-val="<%= source_file.covered_lines.count %>">
<%= format_number(source_file.covered_lines.count) %>
</td>
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500"
data-sort-val="<%= source_file.missed_lines.count %>">
<%= format_number(source_file.missed_lines.count) %>
</td>
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500"
data-sort-val="<%= source_file.covered_strength %>">
<%= format_number(source_file.covered_strength.round(2)) %>
</td>
<% if branchable_result? %>
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 <%= coverage_class(source_file.branches_coverage_percent) %>"
data-sort-val="<%= source_file.branches_coverage_percent.round(2).to_s %>">
<%= sprintf("%.2f", source_file.branches_coverage_percent.round(2)) %>%
</td>
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500"
data-sort-val="<%= source_file.total_branches.count %>">
<%= format_number(source_file.total_branches.count) %>
</td>
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500"
data-sort-val="<%= source_file.covered_branches.count %>">
<%= format_number(source_file.covered_branches.count) %>
</td>
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500"
data-sort-val="<%= source_file.missed_branches.count %>">
<%= format_number(source_file.missed_branches.count) %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Loading

0 comments on commit 3b50253

Please sign in to comment.