coverband 4.2.0.alpha → 4.2.0.beta

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
- SHA1:
3
- metadata.gz: 40372eb3dc52edf4440af29a183eea4354a1695b
4
- data.tar.gz: 47215556426f24df1aa12a26dadfb97418f59ce9
2
+ SHA256:
3
+ metadata.gz: b9aa38073bdae160d98f4b0114909db9e0f3967535df5ed10d92be7ef7f85d58
4
+ data.tar.gz: f0f4ba2d756e783569f75f2444d613eaf17b46eed1b8ff41103dcf1b95454aa0
5
5
  SHA512:
6
- metadata.gz: da9ddb6c8ad13165d7fca9332e23d10a69fe96d6eb4aa2589f206375f4f87943a878d16858408118a32cb0cb37c33e647b3da581f78792fb0fe84ee3fe36b83b
7
- data.tar.gz: 29f91f8e81dd7f00c3b3fa3718b5d8734cad42c7feb4dbd83b930b3cf7e0e649e3ecb34de4efef5c43c15bf37b4d25c6622bc6118755b413ecce1914ac88aed6
6
+ metadata.gz: 6d65b43454b8a119b4fbd52577aef646235facde4e6e887a8e6c41ffbed81fd1e3b13282f4a8dd7ab72a47582dec61706ada1b115b869145bb086b435f6f2dbb
7
+ data.tar.gz: 0b91d57c2f558d8dcfec0452db8c0e8fa7273b19bee982a5ac7fbd1f3da89cac09c154a86bcd21fe89e3c1828328ccf9e3dfd1a68fe9cddafb69a795ee848772
data/changes.md CHANGED
@@ -69,6 +69,8 @@ Feature Ideas:
69
69
  - todos
70
70
  - support multiple gem paths (various version managers setup multiple gem paths)
71
71
  - speed up page load by allowing multiple pages
72
+ - web settings and debug views
73
+ - todo improve these views
72
74
 
73
75
  ### Coverband 4.1.0.alpha
74
76
 
@@ -8,7 +8,7 @@ module Coverband
8
8
  :redis_namespace, :redis_ttl,
9
9
  :safe_reload_files, :background_reporting_enabled,
10
10
  :background_reporting_sleep_seconds, :test_env,
11
- :web_enable_clear, :gem_details
11
+ :web_enable_clear, :gem_details, :web_debug
12
12
 
13
13
  attr_writer :logger, :s3_region, :s3_bucket, :s3_access_key_id, :s3_secret_access_key
14
14
  attr_reader :track_gems
@@ -20,7 +20,7 @@ module Coverband
20
20
  def reset
21
21
  @root = Dir.pwd
22
22
  @root_paths = []
23
- @ignore = %w(vendor .erb$ .slim$)
23
+ @ignore = %w[vendor .erb$ .slim$]
24
24
  @additional_files = []
25
25
  @reporting_frequency = 0.0
26
26
  @verbose = false
@@ -34,6 +34,7 @@ module Coverband
34
34
  @track_gems = false
35
35
  @gem_details = false
36
36
  @groups = {}
37
+ @web_debug = false
37
38
 
38
39
  # TODO: should we push these to adapter configs
39
40
  @s3_region = nil
@@ -83,6 +84,9 @@ module Coverband
83
84
  def track_gems=(value)
84
85
  @track_gems = value
85
86
  return unless @track_gems
87
+ # by default we ignore vendor where many deployments put gems
88
+ # we will remove this default if track_gems is set
89
+ @ignore.delete('vendor')
86
90
  add_group('App', root)
87
91
  # TODO: rework support for multiple gem paths
88
92
  # currently this supports GEM_HOME (which should be first path)
@@ -115,6 +119,14 @@ module Coverband
115
119
  Gem::PathSupport.new(ENV).path.select { |path| File.exist?(path) }
116
120
  end
117
121
 
122
+ SKIPPED_SETTINGS = %w[@s3_secret_access_key @store]
123
+ def to_h
124
+ instance_variables
125
+ .each_with_object('gem_paths': gem_paths) do |var, hash|
126
+ hash[var.to_s.delete('@')] = instance_variable_get(var) unless SKIPPED_SETTINGS.include?(var.to_s)
127
+ end
128
+ end
129
+
118
130
  private
119
131
 
120
132
  def redis_url
@@ -35,6 +35,10 @@ module Coverband
35
35
  case request.path_info
36
36
  when /.*\.(css|js|gif|png)/
37
37
  @static.call(env)
38
+ when %r{\/settings}
39
+ [200, { 'Content-Type' => 'text/json' }, [settings]]
40
+ when %r{\/debug_data}
41
+ [200, { 'Content-Type' => 'text/json' }, [debug_data]]
38
42
  when %r{\/$}
39
43
  [200, { 'Content-Type' => 'text/html' }, [index]]
40
44
  else
@@ -53,6 +57,14 @@ module Coverband
53
57
  open_report: false)
54
58
  end
55
59
 
60
+ def settings
61
+ Coverband.configuration.to_h.to_json
62
+ end
63
+
64
+ def debug_data
65
+ Coverband.configuration.store.coverage.to_json
66
+ end
67
+
56
68
  def collect_coverage
57
69
  Coverband::Collectors::Coverage.instance.report_coverage(true)
58
70
  notice = 'coverband coverage collected'
@@ -8,7 +8,8 @@ module Coverband
8
8
  class FileGroups
9
9
  def initialize(files)
10
10
  @grouped = {}
11
- filter_to_groups(files)
11
+ @files = files
12
+ filter_to_groups
12
13
  end
13
14
 
14
15
  def grouped_results
@@ -17,29 +18,36 @@ module Coverband
17
18
 
18
19
  private
19
20
 
20
- def filter_to_groups(files)
21
+ def filter_to_groups
21
22
  grouped_files = []
22
- grouped_gems = {}
23
- gem_lists = []
24
23
  Coverband.configuration.groups.each do |name, filter|
25
24
  if name == 'Gems'
26
- grouped_gems = files.select { |source_file| source_file.filename =~ /#{filter}/ }.group_by(&:gem_name)
27
- gem_lists = grouped_gems.values.map { |gem_files| Coverband::Utils::FileList.new(gem_files) }
28
- grouped_files.concat(gem_lists.flatten)
29
- @grouped[name] = Coverband::Utils::GemList.new(gem_lists) if gem_lists.flatten.any?
25
+ gem_lists = gem_files(name, filter)
26
+ grouped_files.concat(gem_lists.flatten) if gem_lists.flatten.any?
30
27
  else
31
- @grouped[name] = Coverband::Utils::FileList.new(files.select do |source_file|
32
- source_file.filename =~ /#{filter}/
33
- end)
28
+ app_files(name, filter)
34
29
  grouped_files += @grouped[name]
35
30
  end
36
31
  end
37
- if !Coverband.configuration.groups.empty? && !(other_files = files.reject do |source_file|
32
+ if !Coverband.configuration.groups.empty? && !(other_files = @files.reject do |source_file|
38
33
  grouped_files.include?(source_file)
39
34
  end).empty?
40
35
  @grouped['Ungrouped'] = Coverband::Utils::FileList.new(other_files)
41
36
  end
42
37
  end
38
+
39
+ def gem_files(name, filter)
40
+ grouped_gems = @files.select { |source_file| source_file.filename =~ /#{filter}/ }.group_by(&:gem_name)
41
+ gem_lists = grouped_gems.values.map { |gem_files| Coverband::Utils::FileList.new(gem_files) }
42
+ @grouped[name] = Coverband::Utils::GemList.new(gem_lists) if gem_lists.flatten.any?
43
+ gem_lists
44
+ end
45
+
46
+ def app_files(name, filter)
47
+ @grouped[name] = Coverband::Utils::FileList.new(@files.select do |source_file|
48
+ source_file.filename =~ /#{filter}/ && source_file.filename !~ /#{Coverband.configuration.gem_paths.first}/
49
+ end)
50
+ end
43
51
  end
44
52
  end
45
53
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Coverband
4
- VERSION = '4.2.0.alpha'
4
+ VERSION = '4.2.0.beta'
5
5
  end
data/test/test_helper.rb CHANGED
@@ -95,6 +95,10 @@ def source_fixture(filename)
95
95
  File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', filename))
96
96
  end
97
97
 
98
+ def test_root
99
+ File.expand_path(File.join(File.dirname(__FILE__)))
100
+ end
101
+
98
102
  # Taken from http://stackoverflow.com/questions/4459330/how-do-i-temporarily-redirect-stderr-in-ruby
99
103
  def capture_stderr
100
104
  # The output stream must be an IO-like object. In this case we capture it in
@@ -2,10 +2,6 @@
2
2
 
3
3
  require File.expand_path('../../test_helper', File.dirname(__FILE__))
4
4
 
5
- ####
6
- # Thanks for all the help SimpleCov https://github.com/colszowka/simplecov-html
7
- # initial version of test pulled into Coverband from Simplecov 12/19/2018
8
- ####
9
5
  describe Coverband::Utils::FileGroups do
10
6
  FAKE_GEM_PATH = 'fake/gem/path'
11
7
  subject do
@@ -16,7 +12,7 @@ describe Coverband::Utils::FileGroups do
16
12
  Coverband::Utils::SourceFile.new(source_fixture('app/controllers/sample_controller.rb'), controller_lines),
17
13
  Coverband::Utils::SourceFile.new("#{FAKE_GEM_PATH}/gem_name.rb", controller_lines)
18
14
  ]
19
- Coverband.configuration.expects(:gem_paths).returns([FAKE_GEM_PATH])
15
+ Coverband.configuration.expects(:gem_paths).at_least_once.returns([FAKE_GEM_PATH])
20
16
  Coverband.configuration.track_gems = true
21
17
  Coverband::Utils::FileGroups.new(files)
22
18
  end
@@ -29,3 +25,31 @@ describe Coverband::Utils::FileGroups do
29
25
  assert_equal "#{FAKE_GEM_PATH}/gem_name.rb", subject.grouped_results['Gems'].first.first.short_name
30
26
  end
31
27
  end
28
+
29
+ describe Coverband::Utils::FileGroups, :vendored_gems do
30
+ FAKE_VENDOR_GEM_PATH = "#{test_root}/app/vendor/bundle/ruby/2.5.0/gems"
31
+ subject do
32
+ controller_lines = [nil, 2, 2, 0, nil, nil, 0, nil, nil, nil]
33
+ files = [
34
+ Coverband::Utils::SourceFile.new(source_fixture('sample.rb'), [nil, 1, 1, 1, nil, nil, 1, 1, nil, nil]),
35
+ Coverband::Utils::SourceFile.new(source_fixture('app/models/user.rb'), [nil, 1, 1, 1, nil, nil, 1, 0, nil, nil]),
36
+ Coverband::Utils::SourceFile.new(source_fixture('app/controllers/sample_controller.rb'), controller_lines),
37
+ Coverband::Utils::SourceFile.new("#{FAKE_VENDOR_GEM_PATH}/gem_name.rb", controller_lines)
38
+ ]
39
+ Coverband.configuration.expects(:gem_paths).at_least_once.returns([FAKE_VENDOR_GEM_PATH])
40
+ Coverband.configuration.track_gems = true
41
+ Coverband::Utils::FileGroups.new(files)
42
+ end
43
+
44
+ it 'has app files' do
45
+ assert_equal 'test/fixtures/sample.rb', subject.grouped_results['App'].first.short_name
46
+ end
47
+
48
+ it "doesn't include vendor gems in app files app files" do
49
+ assert_nil subject.grouped_results['App'].select { |files| files.short_name.match(/gem_name/) }.first
50
+ end
51
+
52
+ it 'does has gem files' do
53
+ assert_equal 'gem_name.rb', subject.grouped_results['Gems'].first.first.short_name
54
+ end
55
+ end
data/views/layout.erb CHANGED
@@ -16,11 +16,15 @@
16
16
  <div id="wrapper" style="display:none;">
17
17
  <div id="header">
18
18
  <a href='<%= base_path %>'>Coverband Admin</a> &nbsp;
19
+ <a href='<%= base_path %>settings'>Settings</a> &nbsp;
19
20
  <%= button("#{base_path}collect_coverage", 'force coverage collection') %> &nbsp;
20
21
  <%= button("#{base_path}reload_files", 'reload Coverband files') %> &nbsp;
21
22
  <% if Coverband.configuration.web_enable_clear %>
22
23
  <%= button("#{base_path}clear", 'clear coverage report', delete: true) %>
23
24
  <% end %>
25
+ <% if Coverband.configuration.web_debug %>
26
+ <a href='<%= base_path %>debug_data'>Debug Data</a> &nbsp;
27
+ <% end %>
24
28
  </div>
25
29
  <% if notice.to_s.length > 0 %>
26
30
  <div class="notice"><%= notice %></div>
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: 4.2.0.alpha
4
+ version: 4.2.0.beta
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: 2019-02-03 00:00:00.000000000 Z
12
+ date: 2019-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk-s3
@@ -369,8 +369,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
369
369
  - !ruby/object:Gem::Version
370
370
  version: 1.3.1
371
371
  requirements: []
372
- rubyforge_project:
373
- rubygems_version: 2.5.1
372
+ rubygems_version: 3.0.2
374
373
  signing_key:
375
374
  specification_version: 4
376
375
  summary: Rack middleware to help measure production code usage (LOC runtime usage)