coverband 4.2.0.alpha → 4.2.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/changes.md +2 -0
- data/lib/coverband/configuration.rb +14 -2
- data/lib/coverband/reporters/web.rb +12 -0
- data/lib/coverband/utils/file_groups.rb +20 -12
- data/lib/coverband/version.rb +1 -1
- data/test/test_helper.rb +4 -0
- data/test/unit/utils/file_groups_test.rb +29 -5
- data/views/layout.erb +4 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b9aa38073bdae160d98f4b0114909db9e0f3967535df5ed10d92be7ef7f85d58
|
4
|
+
data.tar.gz: f0f4ba2d756e783569f75f2444d613eaf17b46eed1b8ff41103dcf1b95454aa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d65b43454b8a119b4fbd52577aef646235facde4e6e887a8e6c41ffbed81fd1e3b13282f4a8dd7ab72a47582dec61706ada1b115b869145bb086b435f6f2dbb
|
7
|
+
data.tar.gz: 0b91d57c2f558d8dcfec0452db8c0e8fa7273b19bee982a5ac7fbd1f3da89cac09c154a86bcd21fe89e3c1828328ccf9e3dfd1a68fe9cddafb69a795ee848772
|
data/changes.md
CHANGED
@@ -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
|
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
|
-
|
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
|
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
|
-
|
27
|
-
gem_lists
|
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
|
-
|
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
|
data/lib/coverband/version.rb
CHANGED
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>
|
19
|
+
<a href='<%= base_path %>settings'>Settings</a>
|
19
20
|
<%= button("#{base_path}collect_coverage", 'force coverage collection') %>
|
20
21
|
<%= button("#{base_path}reload_files", 'reload Coverband files') %>
|
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>
|
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.
|
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-
|
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
|
-
|
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)
|