Created
July 28, 2009 19:44
-
-
Save bradly/157627 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| @paths_to_verify = ['./app', './lib'] | |
| def check_dir_syntax(dir) | |
| dir.each do |f| | |
| next if f =='.' || f == '..' | |
| path = File.join(dir.path, f) | |
| if File.directory?(path) | |
| check_dir_syntax(Dir.new(path)) | |
| elsif path.split('.')[-1] == 'rake' || path.split('.')[-1] == 'rb' | |
| file = File.new(path) | |
| check_file_syntax(file) | |
| file.close | |
| end | |
| end | |
| end | |
| def check_file_syntax(file) | |
| @files_counter += 1 | |
| @bad_files << file.path unless (`ruby -c #{file.path}`).strip == 'Syntax OK' | |
| end | |
| def check_syntax | |
| @start_time = Time.now | |
| @bad_files = [] | |
| @files_counter = 0 | |
| @paths_to_verify.each do |path| | |
| check_dir_syntax Dir.new(path) | |
| end | |
| puts "Checked #{@files_counter} files in #{Time.now - @start_time} seconds." | |
| exit 1 unless @bad_files.empty? | |
| end | |
| check_syntax() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment