Permalink
Browse files

Merge pull request #49 from marten/master

Add support for a glob pattern in the style-exclude parameter
  • Loading branch information...
2 parents c03edbb + 310642a commit 628cc1e9591d4190089e5303aa9d278ce8c9d964 @xaviershay xaviershay committed Nov 16, 2012
Showing with 16 additions and 3 deletions.
  1. +1 −1 README.md
  2. +4 −2 lib/cane/style_check.rb
  3. +11 −0 spec/style_check_spec.rb
View
@@ -44,7 +44,7 @@ Customize behaviour with a wealth of options:
--style-glob GLOB Glob to run style checks over (default: {app,lib,spec}/**/*.rb)
--style-measure VALUE Max line length (default: 80)
- --style-exclude FILE Exclude file from style checking
+ --style-exclude FILE Exclude file or glob from style checking
--no-style Disable style checking
--doc-glob GLOB Glob to run doc checks over (default: {app,lib}/**/*.rb)
@@ -23,7 +23,7 @@ def self.options
default: 80,
cast: :to_i,
clobber: :no_style],
- style_exclude: ['Exclude file from style checking',
+ style_exclude: ['Exclude file or glob from style checking',
variable: 'FILE',
type: Array,
default: [],
@@ -72,7 +72,9 @@ def map_lines(file_path, &block)
end
def exclusions
- @exclusions ||= opts.fetch(:style_exclude, []).flatten.to_set
+ @exclusions ||= opts.fetch(:style_exclude, []).flatten.map do |i|
+ Dir[i]
+ end.flatten.to_set
end
def excluded?(file)
@@ -33,6 +33,17 @@ def check(file_name, opts = {})
violations.length.should == 0
end
+ it 'skips declared glob-based exclusions' do
+ file_name = make_file(ruby_with_style_issue)
+
+ violations = check(file_name,
+ style_measure: 80,
+ style_exclude: ["#{File.dirname(file_name)}/*"]
+ ).violations
+
+ violations.length.should == 0
+ end
+
it 'does not include trailing new lines in the character count' do
file_name = make_file('#' * 80 + "\n" + '#' * 80)

0 comments on commit 628cc1e

Please sign in to comment.