coverband 6.0.3.rc.1 → 6.0.3.rc.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f25f2799e62201b31472588ed6ee3d00697b6ab8eba5beb04c3a76cb7e52d962
4
- data.tar.gz: 599a0d1a4ef26b9b353d4ae341db2287f15b5119b9d9d3ed3d2b0e796c6e1fae
3
+ metadata.gz: 7076b5973080adc6d9fc4ddeadf8baa92d19e04f0d8f2e1ef961ac3075737448
4
+ data.tar.gz: aca8e906625af383fbae32139836e8c93113d89e9b17ca323708aed3b5b46ee7
5
5
  SHA512:
6
- metadata.gz: b58f4486c028a9ed4f2e3444ed164a43b620b4cc213f91e9b7aef93c2ef1c394840aade62466b216f29ade57851314989e0ed3f3bca2a7f692deddd106efe7a3
7
- data.tar.gz: 6569ffaeb15feb24b4eb40d5e0403bcf4fcc6fc381a7fd30e64a9e6a7fee06498e05ffe2832c7a99545c51a8b25a12cf6264daf672ef82485ccf10e03a3895a3
6
+ metadata.gz: 302bf319119b5c1c3911da3591db34170717a53b9d9af32aee1f04b87171115daa6f97502c1e2d2d06180c7ba9c24ca675e5b09c6f19473bffb98838c5765f6f
7
+ data.tar.gz: 0a65eb875a43605f1ef355b6bc268728763e8c6a64e1a5566388fbbd685714e8db6ef48e38849a4d1de5b5b34e984782512b9ffe9a37446b3549f82fa586701a
@@ -51,16 +51,6 @@ module Coverband
51
51
  end
52
52
  end
53
53
 
54
- protected
55
-
56
- def split_coverage(types, coverage_cache, options = {})
57
- if types.is_a?(Array)
58
- coverage_for_types(types, options)
59
- else
60
- super
61
- end
62
- end
63
-
64
54
  private
65
55
 
66
56
  # sleep in between to avoid holding other redis commands..
@@ -189,7 +179,8 @@ module Coverband
189
179
  files_set = if opts[:page]
190
180
  files_set(local_type).each_slice(page_size).to_a[opts[:page] - 1] || {}
191
181
  elsif opts[:filename]
192
- files_set(local_type).select { |filepath| filepath == opts[:filename] } || {}
182
+ # TODO: this probably needs to be an exact match of the parsed cache key section
183
+ files_set(local_type).select{ |cache_key| cache_key.match(short_name(opts[:filename])) } || {}
193
184
  else
194
185
  files_set(local_type)
195
186
  end
@@ -209,7 +200,17 @@ module Coverband
209
200
  end
210
201
  end
211
202
 
203
+ # TODO: fix this before shipping main line release
204
+ # def split_coverage(types, coverage_cache, options = {})
205
+ # if types.is_a?(Array)
206
+ # coverage_for_types(types, options)
207
+ # else
208
+ # super
209
+ # end
210
+ # end
211
+
212
212
  # NOTE: when using paging we need to ensure we have the same set of files per page in runtime and eager
213
+ # TODO: This merge of eager and runtime isn't working fix later...
213
214
  def coverage_for_types(types, opts = {})
214
215
  page_size = opts[:page_size] || 250
215
216
 
@@ -219,10 +220,13 @@ module Coverband
219
220
  runtime_file_set = if opts[:page]
220
221
  files_set(local_type).each_slice(page_size).to_a[opts[:page] - 1] || {}
221
222
  elsif opts[:filename]
222
- files_set(local_type).select { |filepath| filepath == opts[:filename] } || {}
223
+ # TODO: this probably needs to be an exact match of the parsed cache key section
224
+ # match is a hack that will only kind of work
225
+ files_set(local_type).select{ |cache_key| cache_key.match(short_name(opts[:filename])) } || {}
223
226
  else
224
227
  files_set(local_type)
225
228
  end
229
+
226
230
  hash_data[Coverband::RUNTIME_TYPE] = runtime_file_set.each_slice(page_size).flat_map do |key_batch|
227
231
  @redis.pipelined do |pipeline|
228
232
  key_batch.each do |key|
@@ -231,8 +235,12 @@ module Coverband
231
235
  end
232
236
  end
233
237
 
238
+ # TODO: debug the set isn't just paths it has other key details including coverage type so below probalby fails
239
+ # match is a hack that will work a sometimes... fix this but it will prove out if this solves the perf issue
234
240
  matched_file_set = files_set(Coverband::EAGER_TYPE)
235
- .select { |filepath| runtime_file_set.include?(filepath) } || {}
241
+ .select { |eager_key, val| runtime_file_set.any?{ |runtime_key|
242
+ (eager_key.match(/\.\.(.*).rb/) && eager_key.match(/\.\.(.*).rb/)[0]==runtime_key.match(/\.\.(.*).rb/)[0]) }
243
+ } || {}
236
244
  hash_data[Coverband::EAGER_TYPE] = matched_file_set.each_slice(page_size).flat_map do |key_batch|
237
245
  @redis.pipelined do |pipeline|
238
246
  key_batch.each do |key|
@@ -240,9 +248,20 @@ module Coverband
240
248
  end
241
249
  end
242
250
  end
251
+ hash_data[Coverband::RUNTIME_TYPE] = hash_data[Coverband::RUNTIME_TYPE].each_with_object({}) do |data_from_redis, hash|
252
+ add_coverage_for_file(data_from_redis, hash)
253
+ end
254
+ hash_data[Coverband::EAGER_TYPE] = hash_data[Coverband::EAGER_TYPE].each_with_object({}) do |data_from_redis, hash|
255
+ add_coverage_for_file(data_from_redis, hash)
256
+ end
243
257
  hash_data
244
258
  end
245
259
 
260
+ def short_name(filename)
261
+ filename.sub(/^#{Coverband.configuration.root}/, ".")
262
+ .gsub(%r{^\.\/}, "")
263
+ end
264
+
246
265
  def file_count(local_type = nil)
247
266
  files_set(local_type).count { |filename| !Coverband.configuration.ignore.any? { |i| filename.match(i) } }
248
267
  end
@@ -5,13 +5,14 @@
5
5
  module Coverband
6
6
  module Reporters
7
7
  class JSONReport < Base
8
- attr_accessor :filtered_report_files, :options, :page, :as_report, :store, :filename
8
+ attr_accessor :filtered_report_files, :options, :page, :as_report, :store, :filename, :base_path
9
9
 
10
10
  def initialize(store, options = {})
11
11
  self.options = options
12
12
  self.page = options.fetch(:page) { nil }
13
13
  self.filename = options.fetch(:filename) { nil }
14
14
  self.as_report = options.fetch(:as_report) { false }
15
+ self.base_path = options.fetch(:base_path) { "./" }
15
16
  self.store = store
16
17
 
17
18
  coverband_reports = Coverband::Reporters::Base.report(store, options)
@@ -41,8 +42,14 @@ module Coverband
41
42
  if as_report
42
43
  row_data = []
43
44
  data[:files].each_pair do |key, data|
45
+ source_class = data[:never_loaded] ? 'strong red' : 'strong'
46
+ data_loader_url="#{base_path}load_file_details?filename=#{data[:filename]}"
47
+ # class=\"src_link cboxElement\
48
+ link = "<a href=\"##{data[:hash]}\" class=\"cboxElement\" title=\"#{key}\" data-loader-url=\"#{data_loader_url}\" onclick=\"src_link_click(this)\">#{key}</a>"
49
+ # Started GET "/config/coverage/load_file_details?filename=/home/danmayer/projects/coverband_rails_example/app/jobs/application_job.rb" for ::1 at 2024-03-05 16:02:33 -0700
50
+ # class="<%= coverage_css_class(source_file.covered_percent) %> strong"
44
51
  row_data << [
45
- key,
52
+ link,
46
53
  data[:covered_percent].to_s,
47
54
  data[:runtime_percentage].to_s,
48
55
  data[:lines_of_code].to_s,
@@ -79,6 +86,8 @@ module Coverband
79
86
  source_files.each_with_object({}) do |source_file, hash|
80
87
  runtime_coverage = result.file_with_type(source_file, Coverband::RUNTIME_TYPE)&.covered_lines_count || 0
81
88
  hash[source_file.short_name] = {
89
+ filename: source_file.filename,
90
+ hash: Digest::SHA1.hexdigest(source_file.filename),
82
91
  never_loaded: source_file.never_loaded,
83
92
  runtime_percentage: result.runtime_relevant_coverage(source_file),
84
93
  lines_of_code: source_file.lines.count,
@@ -125,7 +125,8 @@ module Coverband
125
125
 
126
126
  def report_json
127
127
  report_options = {
128
- as_report: true
128
+ as_report: true,
129
+ base_path: base_path
129
130
  }
130
131
  report_options[:page] = (request.params["page"] || 1).to_i if request.params["page"]
131
132
  Coverband::Reporters::JSONReport.new(
@@ -5,5 +5,5 @@
5
5
  # use format "4.2.1.rc.1" ~> 4.2.1.rc to prerelease versions like v4.2.1.rc.2 and v4.2.1.rc.3
6
6
  ###
7
7
  module Coverband
8
- VERSION = "6.0.3.rc.1"
8
+ VERSION = "6.0.3.rc.3"
9
9
  end
@@ -35,6 +35,8 @@ $(document).ready(function() {
35
35
 
36
36
  // TODO: add support for searching...
37
37
  // hmm should I just use manual paging? or load more...
38
+ // best docs on our version of datatables 1.7 https://datatables.net/beta/1.7/examples/server_side/server_side.html
39
+ // TODO: fix bug where we hardcoded /coverage we need to pull it from the path it is mounted on
38
40
  if ($(".file_list.unsorted").length == 1) {
39
41
  var current_rows = 0;
40
42
  var total_rows = 0;
@@ -43,11 +45,10 @@ $(document).ready(function() {
43
45
  // write a function to get a page of data and add it to the table
44
46
  function get_page(page) {
45
47
  $.ajax({
46
- url: `/coverage/report_json?page=${page}`,
48
+ url: `${$(".file_list").data("coverageurl")}/report_json?page=${page}`,
47
49
  type: 'GET',
48
50
  dataType: 'json',
49
51
  success: function(data) {
50
- console.log(data);
51
52
  total_rows = data["iTotalRecords"];
52
53
  // NOTE: we request 250 at a time, but we seem to have some files that we have as a list but 0 coverage,
53
54
  // so we don't get back 250 per page... to ensure we we need to account for filtered out and empty files
@@ -70,35 +71,36 @@ $(document).ready(function() {
70
71
 
71
72
  // Syntax highlight all files up front - deactivated
72
73
  // $('.source_table pre code').each(function(i, e) {hljs.highlightBlock(e, ' ')});
74
+ src_link_click = (trigger_element) => {
75
+ // Get the source file element that corresponds to the clicked element
76
+ var source_table = $(".shared_source_table");
77
+ var loader_url = $(trigger_element).attr("data-loader-url");
78
+ $(trigger_element).colorbox(jQuery.extend(colorbox_options, { href: loader_url}));
79
+
80
+ // If not highlighted yet, do it!
81
+ if (!source_table.hasClass("highlighted")) {
82
+ source_table.find("pre code").each(function(i, e) {
83
+ hljs.highlightBlock(e, " ");
84
+ });
85
+ source_table.addClass("highlighted");
86
+ }
87
+ };
88
+ window.src_link_click = src_link_click;
73
89
 
74
90
  // Syntax highlight source files on first toggle of the file view popup
75
- $("a.src_link").click(function() {
76
- // Get the source file element that corresponds to the clicked element
77
- var source_table = $($(this).attr("href"));
78
- var loader_url = $(source_table).attr("data-loader-url");
79
-
80
- $(source_table).load(loader_url);
81
-
82
- // If not highlighted yet, do it!
83
- if (!source_table.hasClass("highlighted")) {
84
- source_table.find("pre code").each(function(i, e) {
85
- hljs.highlightBlock(e, " ");
86
- });
87
- source_table.addClass("highlighted");
88
- }
89
- });
91
+ $("a.src_link").click(src_link_click(this));
90
92
 
91
93
  var prev_anchor;
92
94
  var curr_anchor;
93
-
94
- // Set-up of popup for source file views
95
- $("a.src_link").colorbox({
95
+ var colorbox_options = {
96
+ open: true,
96
97
  transition: "none",
97
- inline: true,
98
+ // inline: true,
98
99
  opacity: 1,
99
100
  width: "95%",
100
101
  height: "95%",
101
102
  onLoad: function() {
103
+ // TODO: move source highlighting here
102
104
  prev_anchor = curr_anchor ? curr_anchor : jQuery.url.attr("anchor");
103
105
  curr_anchor = this.href.split("#")[1];
104
106
  window.location.hash = curr_anchor;
@@ -114,7 +116,16 @@ $(document).ready(function() {
114
116
  }
115
117
  window.location.hash = curr_anchor;
116
118
  }
117
- });
119
+ }
120
+
121
+ src_link_colorbox = (trigger_element) => {
122
+ $(trigger_element).colorbox(colorbox_options);
123
+ };
124
+ window.src_link_colorbox = src_link_colorbox;
125
+
126
+ // Set-up of popup for source file views
127
+ // TODO: drop the static source view even for not paged coverband, then delete all this
128
+ $("a.src_link").colorbox(colorbox_options);
118
129
 
119
130
  window.onpopstate = function(event) {
120
131
  if (location.hash.substring(0, 2) == "#_") {
@@ -122,7 +133,9 @@ $(document).ready(function() {
122
133
  curr_anchor = jQuery.url.attr("anchor");
123
134
  } else {
124
135
  if ($("#colorbox").is(":hidden")) {
125
- $('a.src_link[href="' + location.hash + '"]').colorbox({ open: true });
136
+ console.log("pop");
137
+ // $('a.src_link[href="' + location.hash + '"]').colorbox({ open: true });
138
+ $('.shared_source_table').colorbox({ open: true });
126
139
  }
127
140
  }
128
141
  };
@@ -206,7 +219,8 @@ $(document).ready(function() {
206
219
  var anchor = jQuery.url.attr("anchor");
207
220
  // source file hash
208
221
  if (anchor.length == 40) {
209
- $("a.src_link[href=#" + anchor + "]").click();
222
+ console.log("I need to fix deep links to source, the click call wont work anymore");
223
+ // $("a.src_link[href=#" + anchor + "]").click();
210
224
  } else {
211
225
  if ($(".group_tabs a." + anchor.replace("_", "")).length > 0) {
212
226
  $(".group_tabs a." + anchor.replace("_", "")).click();
data/views/file_list.erb CHANGED
@@ -22,7 +22,7 @@
22
22
  <span class="red"><b><%= source_files.missed_lines %></b> lines missed </span>
23
23
  <% end %>
24
24
  </div>
25
- <table class="file_list <%= page ? "unsorted" : "sorted" %>">
25
+ <table class="file_list <%= page ? "unsorted" : "sorted" %>" data-coverageurl="<%= base_path %>">
26
26
  <thead>
27
27
  <tr>
28
28
  <th title="The source file name">File</th>
data/views/layout.erb CHANGED
@@ -26,9 +26,13 @@
26
26
  </div>
27
27
 
28
28
  <div class="source_files">
29
- <% result.source_files.each do |source_file| %>
30
- <%= formatted_source_file_loader(result, source_file) %>
31
- <% end %>
29
+ <div class="shared_source_table">
30
+ <div class='loader'>
31
+ loading source data...
32
+ <br/>
33
+ <img src="<%= assets_path('loading.gif') %>" alt="loading"/>
34
+ </div>
35
+ </div>
32
36
  </div>
33
37
  </div>
34
38
  </body>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coverband
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.3.rc.1
4
+ version: 6.0.3.rc.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Mayer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-02-28 00:00:00.000000000 Z
12
+ date: 2024-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: benchmark-ips