Class: W3CValidators::FeedValidator
- Defined in:
- lib/w3c_validators/feed_validator.rb
Constant Summary collapse
- FEED_VALIDATOR_URI =
'https://validator.w3.org/feed/check.cgi'
Constants inherited from Validator
Validator::HEAD_ERROR_COUNT_HEADER, Validator::HEAD_STATUS_HEADER, Validator::SOAP_OUTPUT_PARAM, Validator::USER_AGENT, Validator::USE_NEW_EXCEPTION
Instance Attribute Summary
Attributes inherited from Validator
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ FeedValidator
constructor
Create a new instance of the FeedValidator.
-
#validate_file(file_path) ⇒ Object
Validate a local feed file.
-
#validate_text(text) ⇒ Object
Validate a feed from a string.
-
#validate_uri(url) ⇒ Object
Validate a feed URI using a
SOAP
request.
Constructor Details
#initialize(options = {}) ⇒ FeedValidator
Create a new instance of the FeedValidator.
Options
You can pass in your own validator’s URI (i.e. FeedValidator.new(:validator_uri => 'http://localhost/check')
).
See Validator#new for proxy server options.
12 13 14 15 16 17 18 19 20 |
# File 'lib/w3c_validators/feed_validator.rb', line 12 def initialize( = {}) if [:validator_uri] @validator_uri = URI.parse([:validator_uri]) .delete([:validator_uri]) else @validator_uri = URI.parse(FEED_VALIDATOR_URI) end super() end |
Instance Method Details
#validate_file(file_path) ⇒ Object
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.
42 43 44 45 46 47 48 49 |
# File 'lib/w3c_validators/feed_validator.rb', line 42 def validate_file(file_path) if file_path.respond_to? :read src = file_path.read else src = read_local_file(file_path) end return validate_text(src) end |
#validate_text(text) ⇒ Object
Validate a feed from a string.
Returns W3CValidators::Results.
32 33 34 |
# File 'lib/w3c_validators/feed_validator.rb', line 32 def validate_text(text) return validate({:rawdata => text}) end |
#validate_uri(url) ⇒ Object
Validate a feed URI using a SOAP
request.
Returns W3CValidators::Results.
25 26 27 |
# File 'lib/w3c_validators/feed_validator.rb', line 25 def validate_uri(url) return validate({:url => url}) end |