coco 0.4.2 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,19 +1,17 @@
1
1
  = coco
2
2
 
3
- Another COde COverage for ruby 1.9 (from the famous post of Aaron Patterson).
4
- This one suits my needs.
3
+ Another code coverage for ruby 1.9 (from the famous post of Aaron Patterson).
5
4
 
6
5
  == Features
7
- * Use it from rspec with a simple <code>require 'coco'</code>
8
- * Display filenames covered < 90% on console
9
- * Build <em>simple</em> html report <em>only</em> for files covered < 90%
6
+ * Use it from rspec or test/unit with a simple <code>require 'coco'</code>
7
+ * Display filenames covered less than 90% on console
8
+ * <em>Simple</em> html report <em>only</em> for files covered less than 90%
10
9
  * Report sources that have no tests
11
10
  * UTF-8 compliant
12
- * Configuration could be done via a simple yaml file
11
+ * Configurable via a simple yaml file
13
12
  * Colorized console output (*nix only)
14
13
 
15
- <em>Note: I have tested coco only on debian linux. I have not tested it with the test/unit
16
- framework.</em>
14
+ <em>Note: I have tested coco only on debian linux.</em>
17
15
 
18
16
  == Documentation
19
17
 
@@ -32,12 +30,16 @@ ruby >= 1.9.2
32
30
 
33
31
  To contribute:
34
32
 
35
- * reek
36
33
  * rspec
34
+ * reek
35
+ * flay
37
36
 
38
37
  == Installing coco
39
- Download and
38
+ From the sources:
40
39
  rake install
40
+
41
+ From rubygems:
42
+ gem install coco
41
43
 
42
44
  == License
43
45
  GPLv3, see COPYING.
data/Rakefile CHANGED
@@ -3,6 +3,11 @@
3
3
  require 'rake'
4
4
  require 'rspec/core/rake_task'
5
5
 
6
+ def ruby_files_for_shell
7
+ files = Dir.glob 'lib/**/*.rb'
8
+ files.join(' ')
9
+ end
10
+
6
11
  desc 'Test coco'
7
12
  task :default => :spec
8
13
 
@@ -14,11 +19,17 @@ end
14
19
  desc 'Check for code smells'
15
20
  task :reek do
16
21
  puts 'Checking for code smells...'
17
- files = Dir.glob 'lib/**/*.rb'
18
- args = files.join(' ')
22
+ args = ruby_files_for_shell
19
23
  sh "reek --quiet #{args} | ./reek.sed"
20
24
  end
21
25
 
26
+ desc 'Check for duplicate code'
27
+ task :flay do
28
+ puts 'Check for duplicate code...'
29
+ args = ruby_files_for_shell
30
+ exec "flay #{args}"
31
+ end
32
+
22
33
  desc 'Build the gem & install it'
23
34
  task :install do
24
35
  sh "gem build coco.gemspec"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.5
@@ -31,6 +31,12 @@ module Coco
31
31
  files.map {|file| File.expand_path file}
32
32
  end
33
33
 
34
+ # @return [Array<String>] The list of ruby source files from +directory+. Recursive.
35
+ def Helpers.rb_files_from directory
36
+ rb_files = File.join(directory, "**", "*.rb")
37
+ Dir.glob(rb_files)
38
+ end
39
+
34
40
  end
35
41
 
36
42
  end
@@ -29,16 +29,25 @@ module Coco
29
29
  private
30
30
 
31
31
  def look_for_sources
32
- @folders.each do |folder|
33
- rb_files = File.join(folder, "**", "*.rb")
34
- @list += Dir.glob(rb_files)
35
- end
32
+ @folders.each {|folder| @list += Helpers.rb_files_from folder }
36
33
  end
37
34
 
38
35
  def exclude_files_user_dont_want
39
- return if @exclude_files.nil?
36
+ return if @exclude_files.nil?
37
+
40
38
  @exclude_files.each do |filename|
41
- @list.delete File.expand_path(filename)
39
+ full_path = File.expand_path(filename)
40
+ if File.file?(full_path)
41
+ @list.delete full_path
42
+ elsif File.directory?(full_path)
43
+ exclude_all_from_dir full_path
44
+ end
45
+ end
46
+ end
47
+
48
+ def exclude_all_from_dir full_path
49
+ Helpers.rb_files_from(full_path).each do |file|
50
+ @list.delete File.expand_path(file)
42
51
  end
43
52
  end
44
53
 
metadata CHANGED
@@ -4,9 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 4
8
- - 2
9
- version: 0.4.2
7
+ - 5
8
+ version: "0.5"
10
9
  platform: ruby
11
10
  authors:
12
11
  - Xavier Nayrac
@@ -14,20 +13,19 @@ autorequire:
14
13
  bindir: bin
15
14
  cert_chain: []
16
15
 
17
- date: 2011-03-01 00:00:00 +01:00
16
+ date: 2011-03-14 00:00:00 +01:00
18
17
  default_executable:
19
18
  dependencies: []
20
19
 
21
20
  description: |-
22
21
  "Another code coverage tool for ruby 1.9
23
22
  (from the famous post of Aaron Patterson).
24
- This one suits my needs:
25
- * Use it from rspec with a simple <code>require 'coco'</code>
26
- * Display filenames covered < 90% on console
27
- * Build simple html report only for files covered < 90%
23
+ * Simply "require 'coco'" from rspec or unit/test
24
+ * Display filenames covered less than 90% on console
25
+ * Build simple html report only for files covered less than 90%
28
26
  * Report sources that have no tests
29
27
  * UTF-8 compliant
30
- * Configuration could be done via a simple yaml file
28
+ * Configurable with a simple yaml file
31
29
  * Colorized console output (*nix only)
32
30
  email: xavier.nayrac@gmail.com
33
31
  executables: []