turboladen / tailor

A RubyGem that allows for checking standard styling of Ruby files.
146 stars 18 forks source link

Can Tailor skip non-ruby files? #132

Closed leandronsp closed 11 years ago

leandronsp commented 11 years ago

I pointed a Rails app path on Tailor::CLI.new and he is trying to parse non-ruby files, like "rails.png". And, of course, I got encoding error.

In my branch I put a new line on method "check_style" from class Critic, just returning if the extension is not .rb

.critic.rb

def check_file(file, style)
  return if File.extname(file) != '.rb'

Would you agree with this?

erdeszt commented 11 years ago

This way you would skip Rakefile too, which is a ruby file and should be checked too. I think you should use:

Tailor.config.file_set '**/*.rb' ...
leandronsp commented 11 years ago

I aggree!

But this doesn't work for me:

Tailor.config.file_set '**/*.rb'
Tailor::CLI.new([path_to_rails_app]).result

neither this:

Tailor.config { |config| config.file_set '**/*.rb' }
Tailor::CLI.new([path_to_rails_app]).result

My .tailor file also is configured with:

config.recursive_file_set '*.rb'

But it is always getting .md, .png, .ico, .etc... May I'm doing it wrong?

erdeszt commented 11 years ago

How do you pass the path to the constructor? You should do it this way:

Tailor::CLI.new(Dir['**/*.rb'])
leandronsp commented 11 years ago

This way it works @erdeszt. Thanks!

Tailor::CLI.new(Dir['other_rails_app/**/*.rb'])