#--------------------------- # Feeds validator. It uses the W3C feed validator api: # # Installation: # gem install feedvalidator # # Use: # ruby validator.rb HOST URI # # Expample: # ruby validator.rb 11870.com /feeds/calavera # #--------------------------- require 'rubygems' require 'feed_validator' require 'net/http' class FeedsValidator def messages(header, map) if map.length > 0 puts "\n#{header} :" puts '--------------------------------' map.each do |information| puts "message: #{information[:text]}" puts "element: #{information[:element]}" puts "line: #{information[:line]}" puts "col: #{information[:col]}" if information[:col] puts '--------------------------------' end end end def initialize @response = Net::HTTP.get_response ARGV[0], ARGV[1], 80 v = W3C::FeedValidator.new v.validate_data @response.body.to_s puts v.to_s unless v.valid? unless v.valid puts "THE FEED IS INVALID\n" messages "ERRORS", v.errors else puts "THE FEED IS VALID\n" end messages "WARNINGS", v.warnings messages "INFORMATIONS", v.informations end end FeedsValidator.new