coverband 1.5.2 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/coverband.gemspec +1 -1
- data/lib/coverband/configuration.rb +4 -3
- data/lib/coverband/s3_report_writer.rb +5 -1
- data/lib/coverband/tasks.rb +40 -33
- data/lib/coverband/version.rb +1 -1
- data/test/unit/s3_report_writer_test.rb +7 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 632ca31e52cd04b166b3d0258b8ac3008646ed92
|
4
|
+
data.tar.gz: 3066cb339fa87bd8ff82b5821e8ccc08cc68277a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32c0d9bb405aca81afbcb291989f248e1435a82fc7463e1384a719aea4ef386f9173c90792808261aaf3d1474b666934ed3dba652af5013311576643693d135f
|
7
|
+
data.tar.gz: 0719826a809f4f73486c922cba025b0303f4645ed7686f0dc1d7f24886329b2da5a1420ee5d82e68b5941c543957c4445198838e0cb3c7fa161d3abbf5822974
|
data/README.md
CHANGED
@@ -23,7 +23,7 @@ The performance impact on Ruby 2.1+ is fairly small and no longer requires a C-e
|
|
23
23
|
## How I use Coverband
|
24
24
|
|
25
25
|
* install coverband.
|
26
|
-
* take baseline: `rake coverband:baseline`
|
26
|
+
* take baseline: `rake coverband:baseline` (__note: never run baseline on production__)
|
27
27
|
* validate baseline with `rake coverband:coverage`
|
28
28
|
* test setup in development (hit endpoints and generate new report)
|
29
29
|
* deploy to staging and verify functionality
|
@@ -65,7 +65,7 @@ That gives you the gem, but to get up and running then follow:
|
|
65
65
|
* Coverband config setup
|
66
66
|
* Require Coverband
|
67
67
|
* Insert middleware in stack
|
68
|
-
* run `bundle exec rake coverband:baseline` ([what is baseline?](https://github.com/danmayer/coverband#coverband-baseline))
|
68
|
+
* run `bundle exec rake coverband:baseline` ([what is baseline?](https://github.com/danmayer/coverband#coverband-baseline)) (__note: never run baseline on production__)
|
69
69
|
* run `bundle exec rake coverband:coverage` this will show app initialization coverage
|
70
70
|
* run app and hit a controller (hit at least +1 time over your `config.startup_delay` setting default is 0)
|
71
71
|
* run `bundle exec rake coverband:coverage` and you should see coverage increasing for the endpoints you hit.
|
data/coverband.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency 'sinatra'
|
28
28
|
spec.add_development_dependency 'classifier-reborn'
|
29
29
|
spec.add_development_dependency 'aws-sdk', '~> 2'
|
30
|
-
spec.add_runtime_dependency "simplecov", '~> 0.11'
|
30
|
+
spec.add_runtime_dependency "simplecov", '~> 0.11.1'
|
31
31
|
spec.add_runtime_dependency "json"
|
32
32
|
# TODO make redis optional dependancy as we add additional adapters
|
33
33
|
spec.add_runtime_dependency "redis"
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Coverband
|
2
2
|
class Configuration
|
3
|
-
|
3
|
+
|
4
4
|
attr_accessor :redis, :root_paths, :root,
|
5
|
-
:ignore, :percentage, :verbose, :reporter,
|
6
|
-
:logger, :startup_delay, :trace_point_events,
|
5
|
+
:ignore, :additional_files, :percentage, :verbose, :reporter,
|
6
|
+
:stats, :logger, :startup_delay, :trace_point_events,
|
7
7
|
:include_gems, :memory_caching, :s3_bucket, :coverage_file, :store,
|
8
8
|
:disable_on_failure_for
|
9
9
|
|
@@ -17,6 +17,7 @@ module Coverband
|
|
17
17
|
@stats = nil
|
18
18
|
@root_paths = []
|
19
19
|
@ignore = []
|
20
|
+
@additional_files = []
|
20
21
|
@include_gems = false
|
21
22
|
@percentage = 0.0
|
22
23
|
@verbose = false
|
@@ -17,7 +17,11 @@ class S3ReportWriter
|
|
17
17
|
private
|
18
18
|
|
19
19
|
def coverage_content
|
20
|
-
|
20
|
+
begin
|
21
|
+
File.read("#{SimpleCov.coverage_dir}/index.html").gsub("./assets/#{Gem::Specification.find_by_name('simplecov-html').version.version}/", '')
|
22
|
+
rescue
|
23
|
+
File.read("#{SimpleCov.coverage_dir}/index.html").to_s.gsub("./assets/0.10.1/", '')
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
def object
|
data/lib/coverband/tasks.rb
CHANGED
@@ -1,44 +1,51 @@
|
|
1
1
|
namespace :coverband do
|
2
2
|
|
3
|
+
def safely_import_files(files_to_cover)
|
4
|
+
if files_to_cover.any?
|
5
|
+
files = Coverband::Baseline.exclude_files(files_to_cover)
|
6
|
+
files.each do |file|
|
7
|
+
begin
|
8
|
+
require_dependency file
|
9
|
+
rescue Exception => err
|
10
|
+
if Coverband.configuration.verbose
|
11
|
+
Coverband.configuration.logger.info "error adding file to baseline: #{file}"
|
12
|
+
Coverband.configuration.logger.info "error: #{err}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
3
19
|
desc "record coverband coverage baseline"
|
4
20
|
task :baseline do
|
5
|
-
Coverband::Baseline.record
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
21
|
+
Coverband::Baseline.record do
|
22
|
+
if Rake::Task.tasks.any?{ |key| key.to_s.match(/environment$/) }
|
23
|
+
Coverband.configuration.logger.info "invoking rake environment"
|
24
|
+
Rake::Task['environment'].invoke
|
25
|
+
elsif Rake::Task.tasks.any?{ |key| key.to_s.match(/env$/) }
|
26
|
+
Coverband.configuration.logger.info "invoking rake env"
|
27
|
+
Rake::Task["env"].invoke
|
28
|
+
end
|
13
29
|
|
14
|
-
|
15
|
-
|
16
|
-
|
30
|
+
baseline_files = [File.expand_path('./config/boot.rb', Dir.pwd),
|
31
|
+
File.expand_path('./config/application.rb', Dir.pwd),
|
32
|
+
File.expand_path('./config/environment.rb', Dir.pwd)]
|
17
33
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
34
|
+
baseline_files.each do |baseline_file|
|
35
|
+
if File.exists?(baseline_file)
|
36
|
+
require baseline_file
|
22
37
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
if File.exists?("#{Rails.root}/lib")
|
32
|
-
files = Coverband::Baseline.exclude_files(Dir.glob("#{Rails.root}/lib/**/*.rb"))
|
33
|
-
files.sort.each { |file|
|
34
|
-
begin
|
35
|
-
require_dependency file
|
36
|
-
rescue Exception
|
37
|
-
#ignoring file
|
38
|
-
end}
|
39
|
-
end
|
38
|
+
end
|
39
|
+
|
40
|
+
safely_import_files(Coverband.configuration.additional_files.flatten)
|
41
|
+
|
42
|
+
if defined? Rails
|
43
|
+
safely_import_files(Dir.glob("#{Rails.root}/app/**/*.rb"))
|
44
|
+
if File.exists?("#{Rails.root}/lib")
|
45
|
+
safely_import_files(Dir.glob("#{Rails.root}/lib/**/*.rb"))
|
40
46
|
end
|
41
|
-
|
47
|
+
end
|
48
|
+
end
|
42
49
|
end
|
43
50
|
|
44
51
|
###
|
data/lib/coverband/version.rb
CHANGED
@@ -5,13 +5,19 @@ module Coverband
|
|
5
5
|
|
6
6
|
class S3ReportWriterTest < Test::Unit::TestCase
|
7
7
|
|
8
|
+
def html_version
|
9
|
+
"#{Gem::Specification.find_by_name('simplecov-html').version.version}"
|
10
|
+
rescue
|
11
|
+
"0.10.1"
|
12
|
+
end
|
13
|
+
|
8
14
|
test 'it writes the coverage report to s3' do
|
9
15
|
s3 = mock('s3_resource')
|
10
16
|
bucket = mock('bucket')
|
11
17
|
object = mock('object')
|
12
18
|
s3.expects(:bucket).with('coverage-bucket').returns(bucket)
|
13
19
|
bucket.expects(:object).with('coverband/index.html').returns(object)
|
14
|
-
File.expects(:read).
|
20
|
+
File.expects(:read).at_least(0).returns("content ./assets/#{html_version}/")
|
15
21
|
object.expects(:put).with(body: 'content ')
|
16
22
|
Aws::S3::Resource.expects(:new).returns(s3)
|
17
23
|
S3ReportWriter.new('coverage-bucket').persist!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coverband
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Mayer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
145
|
+
version: 0.11.1
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
152
|
+
version: 0.11.1
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: json
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|