coverband 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -20,6 +20,18 @@ Or install it yourself as:
20
20
 
21
21
  TODO: Write usage instructions here
22
22
 
23
+ ## TODO
24
+
25
+ * improve the configuration flow (only one time redis setup etc)
26
+ * fix performance by logging to files that purge later
27
+
28
+ ## Completed
29
+
30
+ * fix issue if a file can't be found for reporting
31
+ * add support for file matching ignore for example we need to ignore '/app/vendor/'
32
+ * fix issue on heroku where it logs non app files
33
+ * Allow more configs to be passed in like percentage
34
+
23
35
  ## Contributing
24
36
 
25
37
  1. Fork it
data/lib/coverband.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'redis'
2
+
1
3
  require "coverband/version"
2
4
  require "coverband/reporter"
3
5
  require "coverband/middleware"
@@ -9,6 +9,7 @@ module Coverband
9
9
  @function_set = false
10
10
  @files = {}
11
11
 
12
+ @ignore_patterns = settings[:ignore] || []
12
13
  @sample_percentage = settings[:percentage] || 100.0
13
14
  @reporter = settings[:reporter]
14
15
  end
@@ -48,7 +49,7 @@ module Coverband
48
49
  end
49
50
 
50
51
  def add_file(file, line)
51
- unless !file.match(@project_directory)
52
+ if file.match(@project_directory) && !@ignore_patterns.any?{|pattern| file.match(/#{pattern}/) }
52
53
  if @files.include?(file)
53
54
  @files[file] << line
54
55
  @files[file].uniq!
@@ -28,7 +28,7 @@ module Coverband
28
28
 
29
29
  def self.report_rcov(redis, existing_coverage)
30
30
  rcov_style_report = {}
31
- redis.smembers('coverband').each{|key| rcov_style_report.merge!(line_hash(redis, key)) }
31
+ redis.smembers('coverband').each{|key| line_data = line_hash(redis, key); rcov_style_report.merge!(line_data) if line_data }
32
32
  rcov_style_report = merge_existing_coverage(rcov_style_report, existing_coverage)
33
33
  puts "report:"
34
34
  puts rcov_style_report.inspect
@@ -65,16 +65,19 @@ module Coverband
65
65
  # {"/Users/danmayer/projects/hearno/script/tester.rb"=>[1, nil, 1, 1, nil, nil, nil]}
66
66
  def self.line_hash(redis, key)
67
67
  filename = key.gsub('.','/').gsub('/rb','.rb').gsub('/erb','.erb')
68
-
69
- lines_hit = redis.smembers("coverband#{key}")
70
- count = File.foreach(filename).inject(0) {|c, line| c+1}
71
- if filename.match(/\.erb/)
72
- line_array = Array.new(count, nil)
68
+ if File.exists?(filename)
69
+ lines_hit = redis.smembers("coverband#{key}")
70
+ count = File.foreach(filename).inject(0) {|c, line| c+1}
71
+ if filename.match(/\.erb/)
72
+ line_array = Array.new(count, nil)
73
+ else
74
+ line_array = Array.new(count, 0)
75
+ end
76
+ line_array.each_with_index{|line,index| line_array[index]=1 if lines_hit.include?((index+1).to_s) }
77
+ {filename => line_array}
73
78
  else
74
- line_array = Array.new(count, 0)
79
+ puts "file #{filename} not found in project"
75
80
  end
76
- line_array.each_with_index{|line,index| line_array[index]=1 if lines_hit.include?((index+1).to_s) }
77
- {filename => line_array}
78
81
  end
79
82
 
80
83
  end
@@ -1,3 +1,3 @@
1
1
  module Coverband
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.7"
3
3
  end
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: 0.0.5
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -108,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  segments:
110
110
  - 0
111
- hash: 1757980899486783468
111
+ hash: 1958954660094686763
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements:
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  segments:
119
119
  - 0
120
- hash: 1757980899486783468
120
+ hash: 1958954660094686763
121
121
  requirements: []
122
122
  rubyforge_project:
123
123
  rubygems_version: 1.8.25