Created
October 29, 2008 01:01
-
-
Save bruce/20572 to your computer and use it in GitHub Desktop.
This file contains 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 | |
require 'erb' | |
require 'find' | |
require 'open3' | |
require 'rubygems' | |
begin | |
require 'colorize' | |
rescue LoadError | |
abort "Please install the `colorize' gem" | |
end | |
trap(:SIGINT) { puts "\nThanks!"; exit } | |
Find.find(Dir.pwd) do |path| | |
next unless File.file?(path) | |
next unless File.extname(path) == '.erb' | |
next if path =~ /vendor/ | |
short_path = path[(Dir.pwd.size + 1)..-1] | |
source = ERB.new(File.read(path), 0, '-').src | |
error = Open3.popen3('ruby -c') do |stdin, stdout, stderr| | |
stdin.write source | |
stdin.close | |
if stdout.read == "" | |
stderr.read | |
end | |
end | |
unless error | |
puts short_path.colorize(:green) | |
else | |
puts short_path.colorize(:red).underline | |
puts error.split(/\r?\n/).map { |l| " #{l}" }.join("\n") | |
end | |
next | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment