Class: RogerW3cvalidator::Test
- Inherits:
-
Object
- Object
- RogerW3cvalidator::Test
- Defined in:
- lib/roger_w3cvalidator/test.rb
Instance Method Summary collapse
- #call(test, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Test
constructor
A new instance of Test.
Constructor Details
#initialize(options = {}) ⇒ Test
Returns a new instance of Test.
7 8 9 10 11 12 13 |
# File 'lib/roger_w3cvalidator/test.rb', line 7 def initialize(={}) @options = { :match => ["html/**/*.html"], :skip => [] } @options.update() if end |
Instance Method Details
#call(test, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/roger_w3cvalidator/test.rb', line 15 def call(test, ={}) = {}.update(@options).update() test.log(self, "Validating all files matching #{[:match].inspect}") success = true test.get_files([:match], [:skip]).each do |file_path| validator = W3CValidator.new(File.read(file_path)) validator.validate! if !validator.valid test.log(self, "#{file_path} is invalid (errors: #{validator.errors}, warnings: #{validator.warnings})") do validator.response["messages"].each do || test.debug(self, ["message"]) end end success = false else test.debug(self, "#{file_path} is valid") end end success end |