coverband 0.0.5 → 0.0.7
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.
- data/README.md +12 -0
- data/lib/coverband.rb +2 -0
- data/lib/coverband/middleware.rb +2 -1
- data/lib/coverband/reporter.rb +12 -9
- data/lib/coverband/version.rb +1 -1
- metadata +3 -3
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
data/lib/coverband/middleware.rb
CHANGED
@@ -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
|
-
|
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!
|
data/lib/coverband/reporter.rb
CHANGED
@@ -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|
|
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
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
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
|
-
|
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
|
data/lib/coverband/version.rb
CHANGED
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.
|
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:
|
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:
|
120
|
+
hash: 1958954660094686763
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
123
|
rubygems_version: 1.8.25
|