Sha256: 6e4522d01111cf2a0fae390e76e1f97436de41b26e14a232ea8d31600579b2cc
Contents?: true
Size: 704 Bytes
Versions: 2
Compression:
Stored size: 704 Bytes
Contents
require 'nokogiri' require 'rest-client' module IcsValidator # Validate an iCalendar feed by URL. # class FeedValidator def initialize(feed_url) @feed_url = feed_url end def valid? if r = validation_results results = r.children.map{|c| c.attr(:result)} results.compact.uniq == ['pass'] end end private def validator_url "http://icalvalid.cloudapp.net/?uri=#{@feed_url}" end def validator_response RestClient.get(validator_url) end def validator_response_doc Nokogiri::XML(validator_response) end def validation_results validator_response_doc.at('validationResults') end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ics_validator-0.0.2 | lib/ics_validator/feed_validator.rb |
ics_validator-0.0.1 | lib/ics_validator/feed_validator.rb |