Skip to content

Commit

Permalink
fix issue #356 by having debug data and coverage data one is raw redi…
Browse files Browse the repository at this point in the history
…s data for debugging, the other is enriched like the HTML report including filtering and #nocov comments
  • Loading branch information
danmayer committed Dec 3, 2019
1 parent 8df3fa4 commit 0372349
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/coverband/reporters/html_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def report
end
end

def report_data
report_dynamic_data
end

private

def static?
Expand All @@ -54,6 +58,12 @@ def report_dynamic_html
base_path: base_path,
notice: notice).format_dynamic_html!
end

def report_dynamic_data
Coverband::Utils::HTMLFormatter.new(filtered_report_files,
base_path: base_path,
notice: notice).format_dynamic_data!
end
end
end
end
10 changes: 10 additions & 0 deletions lib/coverband/reporters/web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def call(env)
[200, { 'Content-Type' => 'text/json' }, [view_tracker_data]]
when %r{\/view_tracker}
[200, { 'Content-Type' => 'text/html' }, [view_tracker]]
when %r{\/enriched_debug_data}
[200, { 'Content-Type' => 'text/json' }, [enriched_debug_data]]
when %r{\/debug_data}
[200, { 'Content-Type' => 'text/json' }, [debug_data]]
when %r{\/load_file_details}
Expand Down Expand Up @@ -97,6 +99,14 @@ def debug_data
Coverband.configuration.store.get_coverage_report.to_json
end

def enriched_debug_data
Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
static: false,
base_path: base_path,
notice: '',
open_report: false).report_data
end

def load_file_details
filename = request.params['filename']
Coverband::Reporters::HTMLReport.new(Coverband.configuration.store,
Expand Down
8 changes: 8 additions & 0 deletions lib/coverband/utils/html_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def format_dynamic_html!
format_html(@coverage_result)
end

def format_dynamic_data!
format_data(@coverage_result)
end

def format_settings!
format_settings
end
Expand Down Expand Up @@ -71,6 +75,10 @@ def format_html(result)
template('layout').result(binding)
end

def format_data(result)
template('data').result(binding)
end

# Returns the an erb instance for the template of given name
def template(name)
ERB.new(File.read(File.join(File.dirname(__FILE__), '../../../views/', "#{name}.erb")))
Expand Down
1 change: 1 addition & 0 deletions views/data.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= result.source_files.to_json %>
3 changes: 2 additions & 1 deletion views/nav.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<%= button("#{base_path}clear", 'clear coverage report', delete: true) %>
<% end %>
<% if Coverband.configuration.web_debug %>
<a href='<%= base_path %>debug_data'>Coverage Data</a> &nbsp;
<a href='<%= base_path %>debug_data'>Debug Data</a> &nbsp;
<a href='<%= base_path %>enriched_debug_data'>Coverage Data</a> &nbsp;
<% end %>
</div>
<% if notice.to_s.length > 0 %>
Expand Down

0 comments on commit 0372349

Please sign in to comment.