Skip to content

Instantly share code, notes, and snippets.

@tjsingleton
Created May 12, 2010 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjsingleton/398821 to your computer and use it in GitHub Desktop.
Save tjsingleton/398821 to your computer and use it in GitHub Desktop.
# 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