coverband 6.0.3.rc.2 → 6.0.3.rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ed82514a858dae89f9a09ec1e1cfb089a9356a1445c4ce930121bb9d8661fc1
4
- data.tar.gz: 3d51eab417e906fbda76b6b94b7f23e000c0f971b7de2a96c9e3adb6fa26616d
3
+ metadata.gz: 7076b5973080adc6d9fc4ddeadf8baa92d19e04f0d8f2e1ef961ac3075737448
4
+ data.tar.gz: aca8e906625af383fbae32139836e8c93113d89e9b17ca323708aed3b5b46ee7
5
5
  SHA512:
6
- metadata.gz: 1a63814d8eb4133fa82990fc7207ee9dce27b9f3b9f09658f34d1904706ec29d2110d15b11461ebbd4c2f5e5b0b7b1e0d8c6575f8daa7d4a06d2b460f2a0aa44
7
- data.tar.gz: 5fcb0ba39f83744b54d97a68318db91686ea5beb2e15a773802a46446afa9ba5b1f892c22add88c11d26ba33f617ad3a276f95cddad37997e8ea0930970b880f
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.2"
8
+ VERSION = "6.0.3.rc.3"
9
9
  end
@@ -71,35 +71,36 @@ $(document).ready(function() {
71
71
 
72
72
  // Syntax highlight all files up front - deactivated
73
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;
74
89
 
75
90
  // Syntax highlight source files on first toggle of the file view popup
76
- $("a.src_link").click(function() {
77
- // Get the source file element that corresponds to the clicked element
78
- var source_table = $($(this).attr("href"));
79
- var loader_url = $(source_table).attr("data-loader-url");
80
-
81
- $(source_table).load(loader_url);
82
-
83
- // If not highlighted yet, do it!
84
- if (!source_table.hasClass("highlighted")) {
85
- source_table.find("pre code").each(function(i, e) {
86
- hljs.highlightBlock(e, " ");
87
- });
88
- source_table.addClass("highlighted");
89
- }
90
- });
91
+ $("a.src_link").click(src_link_click(this));
91
92
 
92
93
  var prev_anchor;
93
94
  var curr_anchor;
94
-
95
- // Set-up of popup for source file views
96
- $("a.src_link").colorbox({
95
+ var colorbox_options = {
96
+ open: true,
97
97
  transition: "none",
98
- inline: true,
98
+ // inline: true,
99
99
  opacity: 1,
100
100
  width: "95%",
101
101
  height: "95%",
102
102
  onLoad: function() {
103
+ // TODO: move source highlighting here
103
104
  prev_anchor = curr_anchor ? curr_anchor : jQuery.url.attr("anchor");
104
105
  curr_anchor = this.href.split("#")[1];
105
106
  window.location.hash = curr_anchor;
@@ -115,7 +116,16 @@ $(document).ready(function() {
115
116
  }
116
117
  window.location.hash = curr_anchor;
117
118
  }
118
- });
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);
119
129
 
120
130
  window.onpopstate = function(event) {
121
131
  if (location.hash.substring(0, 2) == "#_") {
@@ -123,7 +133,9 @@ $(document).ready(function() {
123
133
  curr_anchor = jQuery.url.attr("anchor");
124
134
  } else {
125
135
  if ($("#colorbox").is(":hidden")) {
126
- $('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 });
127
139
  }
128
140
  }
129
141
  };
@@ -207,7 +219,8 @@ $(document).ready(function() {
207
219
  var anchor = jQuery.url.attr("anchor");
208
220
  // source file hash
209
221
  if (anchor.length == 40) {
210
- $("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();
211
224
  } else {
212
225
  if ($(".group_tabs a." + anchor.replace("_", "")).length > 0) {
213
226
  $(".group_tabs a." + anchor.replace("_", "")).click();
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.2
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-03-05 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