Permalink
Browse files

Merge pull request #43 from benmoss/case_insensitive_readme

Allow README file to be lowercase
  • Loading branch information...
2 parents 4735ab1 + 15430f0 commit c25bc8c2656ccc7203efca9e3cab7d079ae39e2d @xaviershay xaviershay committed Oct 21, 2012
Showing with 12 additions and 7 deletions.
  1. +9 −7 lib/cane/doc_check.rb
  2. +3 −0 spec/doc_check_spec.rb
View
16 lib/cane/doc_check.rb
@@ -54,13 +54,15 @@ def find_violations(file_name)
def missing_file_violations
result = []
- unless opts[:no_readme]
- unless ['', '.txt', '.md'].any? {|x| Cane::File.exists?("README#{x}") }
- result << {
- description: 'Missing documentation',
- label: 'No README found'
- }
- end
+ return result if opts[:no_readme]
+
+ filenames = ['README', 'readme']
+ extensions = ['', '.txt', '.md']
+ combinations = filenames.product(extensions)
+
+ if combinations.none? {|n, x| Cane::File.exists?(n + x) }
+ result << { description: 'Missing documentation',
+ label: 'No README found' }
end
result
end
View
3 spec/doc_check_spec.rb
@@ -60,6 +60,9 @@ class Doc; end
file.should_receive(:exists?).with("README").and_return(false)
file.should_receive(:exists?).with("README.md").and_return(false)
file.should_receive(:exists?).with("README.txt").and_return(false)
+ file.should_receive(:exists?).with("readme").and_return(false)
+ file.should_receive(:exists?).with("readme.md").and_return(false)
+ file.should_receive(:exists?).with("readme.txt").and_return(false)
violations = check("").violations
violations.length.should == 1

0 comments on commit c25bc8c

Please sign in to comment.