Created
May 12, 2010 16:54
-
-
Save tjsingleton/398821 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
# requires Ruby 1.9 | |
require "open-uri" | |
VALID_FORMAT = "[VALID] %s" | |
INVALID_FORMAT = "[INVALID] %s" | |
def valid?(url) | |
open(url).read.force_encoding("UTF-8").valid_encoding? | |
end | |
def validate_with_output(url) | |
format = if valid?(url) | |
VALID_FORMAT | |
else | |
INVALID_FORMAT | |
end | |
puts format % url | |
end | |
ARGV.each {|arg| validate_with_output(arg) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment