| Class | W3CValidators::FeedValidator |
| In: |
lib/w3c_validators/feed_validator.rb
|
| Parent: | Validator |
| FEED_VALIDATOR_URI | = | 'http://validator.w3.org/feed/check.cgi' |
Create a new instance of the FeedValidator.
You can pass in your own validator‘s URI (i.e. FeedValidator.new(:validator_uri => ‘localhost/check’)).
# File lib/w3c_validators/feed_validator.rb, line 10
10: def initialize(options = {})
11: if options[:validator_uri]
12: @validator_uri = URI.parse(options[:validator_uri])
13: options.delete(options[:validator_uri])
14: else
15: @validator_uri = URI.parse(FEED_VALIDATOR_URI)
16: end
17: super(options)
18: end
Validate a local feed file.
file_path may be either the fully-expanded path to the file or an IO object (like File).
Returns W3CValidators::Results.
# File lib/w3c_validators/feed_validator.rb, line 40
40: def validate_file(file_path)
41: if file_path.respond_to? :read
42: src = file_path.read
43: else
44: src = read_local_file(file_path)
45: end
46: return validate_text(src)
47: end
Validate a feed from a string.
Returns W3CValidators::Results.
# File lib/w3c_validators/feed_validator.rb, line 30
30: def validate_text(text)
31: return validate({:rawdata => text})
32: end
Validate a feed URI using a SOAP request.
Returns W3CValidators::Results.
# File lib/w3c_validators/feed_validator.rb, line 23
23: def validate_uri(url)
24: return validate({:url => url})
25: end