Permalink
Browse files

fix bug#18

  • Loading branch information...
1 parent 63e980b commit 7e302fde13b67d27e3083a4fe88a563d5f7298f1 @lkdjiin committed Aug 8, 2011
Showing with 57 additions and 14 deletions.
  1. +7 −0 NEWS
  2. +4 −4 Rakefile
  3. +4 −0 TODO
  4. +1 −1 VERSION
  5. +18 −0 lib/coco/configuration.rb
  6. +1 −1 lib/coco/writer/html_files_writer.rb
  7. +14 −0 spec/configuration_spec.rb
  8. +4 −4 spec/helper.rb
  9. +4 −4 spec/source_lister_spec.rb
View
7 NEWS
@@ -1,3 +1,10 @@
+v0.5 (2011-03-14)
+
+ * can exclude a whole folder of ruby files from the report
+
+ * works with unit/test framework
+
+
v0.4.2 (2011-03-01)
* Minor bug fixes
View
@@ -13,7 +13,7 @@ task :default => :spec
desc 'Test coco'
RSpec::Core::RakeTask.new(:spec) do |t|
- t.rspec_opts = ['--color']
+ t.rspec_opts = ['--color --format documentation']
end
desc 'Check for code smells'
@@ -33,11 +33,11 @@ end
desc 'Build the gem & install it'
task :install do
sh "gem build coco.gemspec"
- f = FileList['coco*gem'].to_a
- sh "gem install #{f.first} --no-rdoc --no-ri"
+ f = FileList['coco*gem'].to_a
+ sh "gem install #{f.first} --no-rdoc --no-ri"
end
desc 'Generate yard documentation for developpers'
task :doc do
- exec 'yardoc --title "Coco Documentation" - NEWS COPYING VERSION'
+ exec 'yardoc --title "Coco Documentation" - NEWS COPYING VERSION'
end
View
4 TODO
@@ -1 +1,5 @@
+bug#18 exclude a whole folder does not work
+add contributor
+
+say it works with test/unit, rspec, ruby project, rails project
View
@@ -1 +1 @@
-0.5
+0.5.1
View
@@ -28,6 +28,24 @@ def initialize
conf = YAML.load_file '.coco'
self.merge!(conf)
end
+ expand_directories
+ remove_directories
+ end
+
+ private
+
+ def expand_directories
+ self[:excludes].each do |file_or_dir|
+ add_files file_or_dir if File.directory?(file_or_dir)
+ end
+ end
+
+ def add_files dir
+ Helpers.rb_files_from(dir).each {|file| self[:excludes] << file }
+ end
+
+ def remove_directories
+ self[:excludes].delete_if {|file_or_dir| File.directory?(file_or_dir)}
end
end
@@ -23,7 +23,7 @@ def write
def write_each_file
@html_files.each do |filename, html|
- FileWriter.write File.join('coverage', Helpers.rb2html(filename)), html
+ FileWriter.write File.join(@html_dir.coverage_dir, Helpers.rb2html(filename)), html
end
end
View
@@ -40,4 +40,18 @@
config[:excludes].should == ['a', 'b']
end
+ it "must read the excludes whole dirs from .coco file" do
+ create_config({:directories => ['spec/project'],
+ :excludes => ['spec/project/3_rb_files', 'spec/project/4_rb_files']})
+ config = Configuration.new
+ config[:excludes].size.should == 7
+ end
+
+ it "must read the excludes whole dirs and files from .coco file" do
+ create_config({:directories => ['spec/project'],
+ :excludes => ['spec/project/3_rb_files', 'spec/project/six_lines.rb']})
+ config = Configuration.new
+ config[:excludes].size.should == 4
+ end
+
end
View
@@ -13,7 +13,7 @@
COVERAGE_100_90_80 = COVERAGE_80.merge(COVERAGE_90).merge(COVERAGE_100)
def create_config options
- f = File.new('.coco', "w")
- f.write options.to_yaml
- f.close
- end
+ f = File.new('.coco', "w")
+ f.write options.to_yaml
+ f.close
+end
@@ -52,10 +52,10 @@
lister = SourceLister.new(Configuration.new)
list = lister.list
list.size.should == 3
- list.map {|x| File.basename(x)}
- list.include?('html_entities.rb')
- list.include?('six_lines.rb')
- list.include?('ten_lines.rb')
+ list.map! {|x| File.basename(x)}
+ list.include?('html_entities.rb').should == true
+ list.include?('six_lines.rb').should == true
+ list.include?('ten_lines.rb').should == true
end
it "must list the rb sources from a list of folders" do

0 comments on commit 7e302fd

Please sign in to comment.