Class: ValidateWebsite::Validator
- Inherits:
-
Object
- Object
- ValidateWebsite::Validator
- Defined in:
- lib/validate_website/validator.rb
Overview
Document validation from DTD or XSD (webservice for html5)
Constant Summary collapse
- XHTML_PATH =
File.('../../../data/schemas', __FILE__)
Class Attribute Summary collapse
-
.html5_validator_service_url ⇒ Object
Returns the value of attribute html5_validator_service_url.
-
.xsd_schemas ⇒ Object
readonly
Returns the value of attribute xsd_schemas.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#dtd ⇒ Object
readonly
Returns the value of attribute dtd.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#original_doc ⇒ Object
readonly
Returns the value of attribute original_doc.
Class Method Summary collapse
Instance Method Summary collapse
-
#errors ⇒ Array
Of errors.
-
#initialize(original_doc, body, ignore = nil) ⇒ Validator
constructor
A new instance of Validator.
- #valid? ⇒ Boolean
Constructor Details
#initialize(original_doc, body, ignore = nil) ⇒ Validator
Returns a new instance of Validator.
46 47 48 49 50 51 52 53 54 |
# File 'lib/validate_website/validator.rb', line 46 def initialize(original_doc, body, ignore = nil) @errors = [] @document, @dtd_uri = nil @original_doc = original_doc @body = body @ignore = ignore @dtd = @original_doc.internal_subset @namespace = find_namespace(@dtd) end |
Class Attribute Details
.html5_validator_service_url ⇒ Object
Returns the value of attribute html5_validator_service_url.
11 12 13 |
# File 'lib/validate_website/validator.rb', line 11 def html5_validator_service_url @html5_validator_service_url end |
.xsd_schemas ⇒ Object (readonly)
Returns the value of attribute xsd_schemas.
23 24 25 |
# File 'lib/validate_website/validator.rb', line 23 def xsd_schemas @xsd_schemas end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
39 40 41 |
# File 'lib/validate_website/validator.rb', line 39 def body @body end |
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
39 40 41 |
# File 'lib/validate_website/validator.rb', line 39 def doc @doc end |
#dtd ⇒ Object (readonly)
Returns the value of attribute dtd.
39 40 41 |
# File 'lib/validate_website/validator.rb', line 39 def dtd @dtd end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
39 40 41 |
# File 'lib/validate_website/validator.rb', line 39 def namespace @namespace end |
#original_doc ⇒ Object (readonly)
Returns the value of attribute original_doc.
39 40 41 |
# File 'lib/validate_website/validator.rb', line 39 def original_doc @original_doc end |
Class Method Details
.validator_uri ⇒ Object
13 14 15 16 |
# File 'lib/validate_website/validator.rb', line 13 def validator_uri @validator_uri ||= ENV['VALIDATOR_NU_URL'] || @html5_validator_service_url end |
.xsd(namespace) ⇒ Object
70 71 72 73 |
# File 'lib/validate_website/validator.rb', line 70 def self.xsd(namespace) return unless namespace @xsd_schemas[namespace] if @xsd_schemas.key? namespace end |
Instance Method Details
#errors ⇒ Array
Returns of errors.
64 65 66 67 |
# File 'lib/validate_website/validator.rb', line 64 def errors @errors.map!(&:to_s) @ignore ? @errors.reject { |e| @ignore =~ e } : @errors end |
#valid? ⇒ Boolean
58 59 60 61 |
# File 'lib/validate_website/validator.rb', line 58 def valid? find_errors errors.empty? end |