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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae65d228389db7462d1ddc08e950d5964e8a34f4
4
- data.tar.gz: 8bd404ca135c010026e965953c717ca8539f1dc9
3
+ metadata.gz: 632ca31e52cd04b166b3d0258b8ac3008646ed92
4
+ data.tar.gz: 3066cb339fa87bd8ff82b5821e8ccc08cc68277a
5
5
  SHA512:
6
- metadata.gz: c29477a4e66d9521b42d58db8469bb75e891d834ab59d08ca784acde9396f65de384b6e27d822fa28bc0641a40a88776b1411191baa8fb9d115f6ca442cb3c9b
7
- data.tar.gz: a2195997791f11c2c69433210b106631a62785bf7d9bcc68c05ce31a4bbc06ac2b67716458c3a0b36f610b39cde69c9498289fbcf724357102615426eb06c82f
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.
@@ -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, :stats,
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
- File.read("#{SimpleCov.coverage_dir}/index.html").gsub("./assets/#{Gem::Specification.find_by_name('simplecov-html').version.version}/", '')
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
@@ -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
- if Rake::Task.tasks.any?{ |key| key.to_s.match(/environment$/) }
7
- Coverband.configuration.logger.info "invoking rake environment"
8
- Rake::Task['environment'].invoke
9
- elsif Rake::Task.tasks.any?{ |key| key.to_s.match(/env$/) }
10
- Coverband.configuration.logger.info "invoking rake env"
11
- Rake::Task["env"].invoke
12
- end
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
- baseline_files = [File.expand_path('./config/boot.rb', Dir.pwd),
15
- File.expand_path('./config/application.rb', Dir.pwd),
16
- File.expand_path('./config/environment.rb', Dir.pwd)]
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
- baseline_files.each do |baseline_file|
19
- if File.exists?(baseline_file)
20
- require baseline_file
21
- end
34
+ baseline_files.each do |baseline_file|
35
+ if File.exists?(baseline_file)
36
+ require baseline_file
22
37
  end
23
- if defined? Rails
24
- files = Coverband::Baseline.exclude_files(Dir.glob("#{Rails.root}/app/**/*.rb"))
25
- files.sort.each { |file|
26
- begin
27
- require_dependency file
28
- rescue Exception
29
- #ignore
30
- end }
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
  ###
@@ -1,3 +1,3 @@
1
1
  module Coverband
2
- VERSION = "1.5.2"
2
+ VERSION = "1.5.3"
3
3
  end
@@ -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).with("#{SimpleCov.coverage_dir}/index.html").returns("content ./assets/#{Gem::Specification.find_by_name('simplecov-html').version.version}/")
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.2
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-07-16 00:00:00.000000000 Z
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: '0.11'
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: '0.11'
152
+ version: 0.11.1
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: json
155
155
  requirement: !ruby/object:Gem::Requirement