w3c_validators 1.2 → 1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.travis.yml +7 -0
  4. data/CHANGELOG +14 -2
  5. data/Gemfile +3 -0
  6. data/Gemfile.lock +43 -0
  7. data/{README.rdoc → README.md} +41 -29
  8. data/Rakefile +64 -0
  9. data/lib/w3c_validators.rb +2 -1
  10. data/lib/w3c_validators/css_validator.rb +23 -16
  11. data/lib/w3c_validators/feed_validator.rb +4 -4
  12. data/lib/w3c_validators/markup_validator.rb +29 -29
  13. data/lib/w3c_validators/message.rb +6 -2
  14. data/lib/w3c_validators/nu_validator.rb +2 -2
  15. data/lib/w3c_validators/validator.rb +48 -43
  16. data/lib/w3c_validators/version.rb +3 -0
  17. data/test/fixtures/bootstrap.min.css +6 -0
  18. data/test/fixtures/invalid_css.css +2 -0
  19. data/test/fixtures/invalid_encoding.html +10 -0
  20. data/test/fixtures/invalid_feed.xml +19 -0
  21. data/test/fixtures/invalid_html5.html +16 -0
  22. data/test/fixtures/invalid_markup.html +11 -0
  23. data/test/fixtures/valid_css.css +2 -0
  24. data/test/fixtures/valid_feed.xml +20 -0
  25. data/test/fixtures/valid_html5.html +16 -0
  26. data/test/fixtures/valid_markup.html +11 -0
  27. data/test/http_recording/css_context.yml +72 -0
  28. data/test/http_recording/css_overriding_css_profile.yml +66 -0
  29. data/test/http_recording/css_skippedstring.yml +72 -0
  30. data/test/http_recording/css_validating_big_file.yml +1423 -0
  31. data/test/http_recording/css_validating_file.yml +72 -0
  32. data/test/http_recording/css_validating_text.yml +66 -0
  33. data/test/http_recording/css_validating_text_via_file.yml +72 -0
  34. data/test/http_recording/css_validating_uri.yml +65 -0
  35. data/test/http_recording/css_vendor_extensions_as_errors.yml +65 -0
  36. data/test/http_recording/css_vendor_extensions_as_warnings.yml +62 -0
  37. data/test/http_recording/css_vendor_extensions_default.yml +62 -0
  38. data/test/http_recording/feed_validating_file.yml +49 -0
  39. data/test/http_recording/feed_validating_text.yml +46 -0
  40. data/test/http_recording/feed_validating_text_via_file.yml +49 -0
  41. data/test/http_recording/feed_validating_uri_with_soap.yml +50 -0
  42. data/test/http_recording/html5_getting_request_data.yml +51 -0
  43. data/test/http_recording/html5_validating_uri.yml +74 -0
  44. data/test/http_recording/markup_debugging_uri.yml +83 -0
  45. data/test/http_recording/markup_overriding_charset.yml +125 -0
  46. data/test/http_recording/markup_overriding_charset_for_fallback_only.yml +76 -0
  47. data/test/http_recording/markup_overriding_doctype.yml +208 -0
  48. data/test/http_recording/markup_overriding_doctype_for_fallback_only.yml +84 -0
  49. data/test/http_recording/markup_validating_file.yml +93 -0
  50. data/test/http_recording/markup_validating_text.yml +67 -0
  51. data/test/http_recording/markup_validating_text_via_file.yml +93 -0
  52. data/test/http_recording/markup_validating_uri_with_head_request.yml +38 -0
  53. data/test/http_recording/markup_validating_uri_with_soap.yml +76 -0
  54. data/test/http_recording/markup_validator_abort.yml +50 -0
  55. data/test/http_recording/markup_validator_contains_details_of_error_conditions.yml +76 -0
  56. data/test/test_css_validator.rb +78 -17
  57. data/test/test_exceptions.rb +11 -8
  58. data/test/test_feed_validator.rb +42 -39
  59. data/test/test_helper.rb +7 -2
  60. data/test/test_html5_validator.rb +42 -34
  61. data/test/test_markup_validator.rb +75 -52
  62. data/test/test_proxy.rb +5 -2
  63. data/w3c_validators.gemspec +24 -0
  64. metadata +154 -68
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9cc7b916dd4e54b2c9c76269ad51c2cec12cb76c
4
+ data.tar.gz: efb3a5044a1fa78ea07eeadbcb793deb179f8cda
5
+ SHA512:
6
+ metadata.gz: 4be45ecae869797669466162849f2518c8501a8edb6bf413c385d8def5e84fafc4598bb4d8a7ee59db3cb44278f34e0b037a79b1afef8f70e392a26738f7dae1
7
+ data.tar.gz: cc89e2ffb16c24e9fa066e6a4b5bd3040a279e5767400e76cf06bd7b029f583a95ab3024027519e9b2f0ca80592c8863c4fa482bbc6abb6fd1eec261648b74cf
@@ -0,0 +1,4 @@
1
+ docs/
2
+ *.gem
3
+ .ruby-version
4
+ .ruby-gemset
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.1
4
+ - 2.2.5
5
+ - 2.1.9
6
+ - 2.0.0
7
+
data/CHANGELOG CHANGED
@@ -30,8 +30,20 @@
30
30
  == Version 1.1
31
31
  * Ruby 1.9 compatibility
32
32
  * Switched to Nokogiri for XML parsing
33
-
33
+
34
34
  == Version 1.2
35
35
  * Use CSS3 as default profile
36
36
  * Use Bundler and update to new RDoc command
37
- * Use POST in feed validator
37
+
38
+ == Version 1.3 (not yet published)
39
+ * drop ruby 1.9 compatibility
40
+ * Move markup and nu validators to https
41
+ * Use POST for file validation (avoid crash for big files)
42
+ * Use POST with x-www-form-urlencoded instead of multipart/form-data for feed validation
43
+ * Mock test with VCR to prevent w3c abuse ban when replaying tests
44
+ * Add support for context and skippedstring to CSS messages
45
+ * Create gemspec
46
+ * Move README from rdoc format to markdown format
47
+ * Add capability to manage vendor extension as warning or error
48
+ * Activate travis-ci build
49
+
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ w3c_validators (1.3)
5
+ json (~> 2.0)
6
+ nokogiri (~> 1.6)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.5.0)
12
+ public_suffix (~> 2.0, >= 2.0.2)
13
+ crack (0.4.3)
14
+ safe_yaml (~> 1.0.0)
15
+ hashdiff (0.3.1)
16
+ json (2.0.2)
17
+ mini_portile2 (2.1.0)
18
+ nokogiri (1.6.8.1)
19
+ mini_portile2 (~> 2.1.0)
20
+ power_assert (0.4.1)
21
+ public_suffix (2.0.4)
22
+ rake (11.3.0)
23
+ safe_yaml (1.0.4)
24
+ test-unit (3.2.3)
25
+ power_assert
26
+ vcr (3.0.3)
27
+ webmock (2.1.0)
28
+ addressable (>= 2.3.6)
29
+ crack (>= 0.3.2)
30
+ hashdiff
31
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ rake
37
+ test-unit
38
+ vcr
39
+ w3c_validators!
40
+ webmock
41
+
42
+ BUNDLED WITH
43
+ 1.13.6
@@ -1,50 +1,57 @@
1
- = W3C Validators Gem README
1
+ # W3C Validators Gem README
2
+ [![Build Status](https://travis-ci.org/w3c-validators/w3c_validators.svg?branch=master)](https://travis-ci.org/w3c-validators/w3c_validators)
2
3
 
3
4
  W3C Validators is a Ruby wrapper for the World Wide Web Consortium's online
4
5
  validation services.
5
6
 
6
7
  It supports the markup validator, the feed validator and the CSS validator.
7
8
 
8
- === Installation
9
+ ### Installation
9
10
 
11
+ ```bash
10
12
  gem install w3c_validators
13
+ ```
11
14
 
12
- === Usage
15
+ ### Usage
13
16
 
14
- There are three main validator classes available, the W3CValidators::MarkupValidator
15
- (used for HTML), the W3CValidators::FeedValidator and the
16
- W3CValidators::CSSValidator.
17
+ There are three main validator classes available, the `W3CValidators::MarkupValidator`
18
+ (used for HTML), the `W3CValidators::FeedValidator` and the `W3CValidators::CSSValidator`.
17
19
 
18
20
  Each validator has offers three different validation methods.
19
21
 
20
- * +validate_text+ methods take a string
21
- * +validate_file+ methods take a path to a file or an IO object
22
- * +validate_uri+ methods take a published URL
22
+ * `validate_text` methods take a string
23
+ * `validate_file` methods take a path to a file or an IO object
24
+ * `validate_uri` methods take a published URL
23
25
 
24
- In addition, the W3CValidators::MarkupValidator has a validate_uri_quickly method, which
25
- performs a HEAD request against the markup validation service. The Results
26
+ In addition, the `W3CValidators::MarkupValidator` has a `validate_uri_quickly` method, which
27
+ performs a HEAD request against the markup validation service. The Results
26
28
  of this call give an error count but no error details.
27
29
 
28
- ==== Using a local validator
30
+ #### Using a local validator
29
31
 
30
32
  Each of the three validators allows you to specify a custom path to the
31
33
  validator. You can set your own validator like this:
32
34
 
35
+ ```ruby
33
36
  validator = MarkupValidator.new(:validator_uri => 'http://localhost/check')
37
+ ```
34
38
 
35
- ==== Using a proxy server
39
+ #### Using a proxy server
36
40
 
37
41
  You can use a proxy server by passing in its information in the contructor.
38
42
 
39
- validator = MarkupValidator.new(:proxy_server => 'proxy.example.com',
40
- :proxy_port => 80,
41
- :proxy_user => 'optional',
42
- :proxy_pass => 'optional')
43
+ ```ruby
44
+ validator = MarkupValidator.new(:proxy_host => 'proxy.example.com',
45
+ :proxy_port => 80,
46
+ :proxy_user => 'optional',
47
+ :proxy_pass => 'optional')
48
+ ```
43
49
 
44
- === Examples
50
+ ### Examples
45
51
 
46
- ==== Example #1: Markup validator, local file
52
+ #### Example #1: Markup validator, local file
47
53
 
54
+ ```ruby
48
55
  require 'w3c_validators'
49
56
 
50
57
  include W3CValidators
@@ -73,10 +80,12 @@ You can use a proxy server by passing in its information in the contructor.
73
80
  results.debug_messages.each do |key, value|
74
81
  puts "#{key}: #{value}"
75
82
  end
83
+ ```
76
84
 
77
85
 
78
- ==== Example #2: Feed validator, remote file
86
+ #### Example #2: Feed validator, remote file
79
87
 
88
+ ```ruby
80
89
  require 'w3c_validators'
81
90
 
82
91
  include W3CValidators
@@ -92,9 +101,11 @@ You can use a proxy server by passing in its information in the contructor.
92
101
  else
93
102
  puts 'Valid!'
94
103
  end
104
+ ```
95
105
 
96
- ==== Example #3: CSS validator, text fragment
106
+ #### Example #3: CSS validator, text fragment
97
107
 
108
+ ```ruby
98
109
  require 'w3c_validators'
99
110
 
100
111
  include W3CValidators
@@ -110,23 +121,24 @@ You can use a proxy server by passing in its information in the contructor.
110
121
  else
111
122
  puts 'Valid!'
112
123
  end
124
+ ```
113
125
 
114
- === Tests
126
+ ### Tests
115
127
 
116
128
  Run unit tests using <tt>rake test</tt>. Note that there is a one second delay
117
129
  between each call to the W3C's validators per their request.
118
130
 
119
131
 
120
- === Credits and code
132
+ ### Credits and code
121
133
 
122
- Documentation is available at {http://code.dunae.ca/w3c_validators}[http://code.dunae.ca/w3c_validators].
134
+ Documentation is available at [http://code.dunae.ca/w3c_validators](http://code.dunae.ca/w3c_validators).
123
135
 
124
- Source is available on {GitHub}[https://github.com/alexdunae/w3c-validators]
136
+ Source is available on [GitHub](https://github.com/alexdunae/w3c-validators)
125
137
 
126
- Written by Alex Dunae ({dunae.ca}[http://dunae.ca/], e-mail 'code' at the same domain), 2007.
138
+ Written by Alex Dunae ([dunae.ca](http://dunae.ca/), e-mail 'code' at the same domain), 2007.
127
139
 
128
- Thanks to {Ryan King}[http://theryanking.com/] for creating the 0.9.2 update.
140
+ Thanks to [Ryan King](http://theryanking.com/) for creating the 0.9.2 update.
129
141
 
130
- Thanks to {Ryan King}[http://theryanking.com/], {Jonathan Julian}[http://jonathanjulian.org/] and Sylvain LaFleur for creating the 0.9.3 update.
142
+ Thanks to [Ryan King](http://theryanking.com/), [Jonathan Julian](http://jonathanjulian.org/) and Sylvain LaFleur for creating the 0.9.3 update.
131
143
 
132
- Thanks to {James Rosen}[http://github.com/jamesarosen] and {Roman Shterenzon}[http://github.com/romanbsd] for creating the 1.0.1 update.
144
+ Thanks to [James Rosen](http://github.com/jamesarosen) and [Roman Shterenzon](http://github.com/romanbsd) for creating the 1.0.1 update.
@@ -0,0 +1,64 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ $: << File.expand_path(File.dirname(__FILE__))
5
+ $: << File.expand_path(File.dirname(__FILE__)) + '/test'
6
+
7
+ require 'rake'
8
+ require 'rdoc/task'
9
+ require 'rake/testtask'
10
+ require 'lib/w3c_validators'
11
+ require 'fileutils'
12
+
13
+ include W3CValidators
14
+
15
+ desc 'Run the unit tests.'
16
+ Rake::TestTask.new do |t|
17
+ t.libs << 'lib'
18
+ t.libs << 'lib/test'
19
+ t.test_files = FileList['test/test*.rb'].exclude('test_helper.rb')
20
+ t.verbose = true
21
+ end
22
+
23
+ desc 'Generate documentation for W3C Validators.'
24
+ RDoc::Task.new do |rdoc|
25
+ rdoc.rdoc_dir = 'doc'
26
+ rdoc.title = 'Ruby W3C Validators'
27
+ rdoc.options << '--all' << '--inline-source' << '--line-numbers'
28
+ rdoc.rdoc_files.include('README.rdoc')
29
+ rdoc.rdoc_files.include('LICENSE')
30
+ rdoc.rdoc_files.include('CHANGELOG')
31
+ rdoc.rdoc_files.include('lib/*.rb')
32
+ rdoc.rdoc_files.include('lib/w3c_validators/*.rb')
33
+ end
34
+
35
+ desc 'Create the gem spec'
36
+ task :create_gemspec do
37
+ File.open("w3c_validators.gemspec","w") do |file|
38
+ file.puts <<-EOH
39
+ # Auto-generated gemspec
40
+ # Run 'rake generate_gemspec' to re-generate
41
+ Gem::Specification.new do |s|
42
+ s.name = "w3c_validators"
43
+ s.platform = Gem::Platform::RUBY
44
+ s.version = "1.1.1"
45
+ s.date = "2010-10-20"
46
+ s.summary = "Wrapper for the World Wide Web Consortium's online validation services."
47
+ s.email = "code@dunae.ca"
48
+ s.homepage = "http://code.dunae.ca/w3c_validators"
49
+ s.description = "W3C Validators is a Ruby wrapper for the World Wide Web Consortium's online validation services."
50
+ s.has_rdoc = true
51
+ s.author = "Alex Dunae"
52
+ s.add_dependency('nokogiri', 'json')
53
+ s.extra_rdoc_files = ['README.rdoc', 'CHANGELOG', 'LICENSE']
54
+ s.rdoc_options << '--all' << '--inline-source' << '--line-numbers' << '--charset' << 'utf-8'
55
+ EOH
56
+
57
+ file.puts " s.test_files = ['" + Dir.glob('test/test_*.rb').join("','") + "']"
58
+ file.puts " s.files = ['" + FileList["{lib}/**/*"].join("','") + "']"
59
+ file.puts 'end'
60
+ end
61
+ end
62
+
63
+ task :default => :test
64
+
@@ -1,6 +1,7 @@
1
1
  $:.unshift File.dirname(__FILE__)
2
+ require 'w3c_validators/version'
2
3
  require 'w3c_validators/validator'
3
4
  require 'w3c_validators/markup_validator'
4
5
  require 'w3c_validators/nu_validator'
5
6
  require 'w3c_validators/feed_validator'
6
- require 'w3c_validators/css_validator'
7
+ require 'w3c_validators/css_validator'
@@ -5,7 +5,7 @@ module W3CValidators
5
5
  # Create a new instance of the CSSValidator.
6
6
  #
7
7
  # ==== Options
8
- # You can pass in your own validator's URI (i.e.
8
+ # You can pass in your own validator's URI (i.e.
9
9
  # <tt>CSSValidator.new(:validator_uri => 'http://localhost/check')</tt>).
10
10
  #
11
11
  # See Validator#new for proxy server options.
@@ -19,7 +19,7 @@ module W3CValidators
19
19
  options[:profile] ||= 'css3'
20
20
  super(options)
21
21
  end
22
-
22
+
23
23
  # The CSS profile used for the validation.
24
24
  #
25
25
  # +charset+ can be a string or a symbl from the W3CValidators::CSS_PROFILES hash.
@@ -51,6 +51,13 @@ module W3CValidators
51
51
  @options[:lang] = lang
52
52
  end
53
53
 
54
+ # whether to treat presence of CSS vendor extension as error or merely a warning
55
+ def set_vendor_extension_warning!(level = 'Default')
56
+ @options[:vextwarning] = nil if level.to_s.downcase == 'default'
57
+ @options[:vextwarning] = 'true' if level.to_s.downcase == 'warnings'
58
+ @options[:vextwarning] = 'false' if level.to_s.downcase == 'errors'
59
+ end
60
+
54
61
  # Validate the CSS of an URI.
55
62
  #
56
63
  # Returns W3CValidators::Results.
@@ -61,10 +68,10 @@ module W3CValidators
61
68
  # Validate the CSS of a string.
62
69
  #
63
70
  # Returns W3CValidators::Results.
64
- def validate_text(text)
65
- return validate({:text => text})
71
+ def validate_text(text, request_mode = :get)
72
+ return validate({:text => text}, request_mode)
66
73
  end
67
-
74
+
68
75
  # Validate the CSS of a local file.
69
76
  #
70
77
  # +file_path+ may be either the fully-expanded path to the file or
@@ -77,14 +84,16 @@ module W3CValidators
77
84
  else
78
85
  src = read_local_file(file_path)
79
86
  end
80
- return validate_text(src)
87
+ # we force the :post mode otherwise it fails for
88
+ # big files
89
+ return validate_text(src, :post)
81
90
  end
82
91
 
83
92
 
84
93
  protected
85
- def validate(options) # :nodoc:
94
+ def validate(options, request_mode = :get) # :nodoc:
86
95
  options = get_request_options(options)
87
- response = send_request(options, :get)
96
+ response = send_request(options, request_mode)
88
97
  @results = parse_soap_response(response.body)
89
98
  @results
90
99
  end
@@ -92,9 +101,9 @@ protected
92
101
  # Perform sanity checks on request params
93
102
  def get_request_options(options) # :nodoc:
94
103
  options = @options.merge(options)
95
-
104
+
96
105
  options[:output] = SOAP_OUTPUT_PARAM
97
-
106
+
98
107
  unless options[:uri] or options[:text]
99
108
  raise ArgumentError, "an uri or text is required."
100
109
  end
@@ -111,11 +120,11 @@ protected
111
120
 
112
121
  def parse_soap_response(response) # :nodoc:
113
122
  doc = Nokogiri::XML(response)
114
- doc.remove_namespaces!
123
+ doc.remove_namespaces!
115
124
 
116
125
  result_params = {}
117
126
 
118
- {:uri => 'uri', :checked_by => 'checkedby', :validity => 'validity', :css_level => 'csslevel'}.each do |local_key, remote_key|
127
+ {:uri => 'uri', :checked_by => 'checkedby', :validity => 'validity', :css_level => 'csslevel'}.each do |local_key, remote_key|
119
128
  if val = doc.at('cssvalidationresponse ' + remote_key)
120
129
  result_params[local_key] = val.text
121
130
  end
@@ -124,7 +133,7 @@ protected
124
133
  results = Results.new(result_params)
125
134
 
126
135
  ['warninglist', 'errorlist'].each do |list_type|
127
- doc.css(list_type).each do |message_list|
136
+ doc.css(list_type).each do |message_list|
128
137
 
129
138
  if uri_node = message_list.at('uri')
130
139
  uri = uri_node.text
@@ -147,7 +156,5 @@ protected
147
156
  rescue Exception => e
148
157
  handle_exception e
149
158
  end
150
-
151
-
152
159
  end
153
- end
160
+ end
@@ -23,7 +23,7 @@ module W3CValidators
23
23
  #
24
24
  # Returns W3CValidators::Results.
25
25
  def validate_uri(url)
26
- return validate({:url => url})
26
+ return validate({:url => url}, :get)
27
27
  end
28
28
 
29
29
  # Validate a feed from a string.
@@ -49,9 +49,9 @@ module W3CValidators
49
49
  end
50
50
 
51
51
  protected
52
- def validate(options) # :nodoc:
52
+ def validate(options, mode = :post_url_encode) # :nodoc:
53
53
  options = get_request_options(options)
54
- response = send_request(options, :post)
54
+ response = send_request(options, mode)
55
55
  @results = parse_soap_response(response.body)
56
56
  @results
57
57
  end
@@ -110,4 +110,4 @@ protected
110
110
  handle_exception e
111
111
  end
112
112
  end
113
- end
113
+ end
@@ -1,15 +1,15 @@
1
1
  module W3CValidators
2
2
  class MarkupValidator < Validator
3
- MARKUP_VALIDATOR_URI = 'http://validator.w3.org/check'
3
+ MARKUP_VALIDATOR_URI = 'https://validator.w3.org/check'
4
4
 
5
5
  # Create a new instance of the MarkupValidator.
6
6
  #
7
7
  # ==== Options
8
- # The +options+ hash allows you to set request parameters (see
9
- # http://validator.w3.org/docs/api.html#requestformat) quickly. Request
8
+ # The +options+ hash allows you to set request parameters (see
9
+ # http://validator.w3.org/docs/api.html#requestformat) quickly. Request
10
10
  # parameters can also be set using set_charset!, set_debug! and set_doctype!.
11
11
  #
12
- # You can pass in your own validator's URI (i.e.
12
+ # You can pass in your own validator's URI (i.e.
13
13
  # <tt>MarkupValidator.new(:validator_uri => 'http://localhost/check')</tt>).
14
14
  #
15
15
  # See Validator#new for proxy server options.
@@ -22,14 +22,14 @@ module W3CValidators
22
22
  end
23
23
  super(options)
24
24
  end
25
-
26
- # Specify the character encoding to use when parsing the document.
25
+
26
+ # Specify the character encoding to use when parsing the document.
27
27
  #
28
- # When +only_as_fallback+ is +true+, the given encoding will only be
29
- # used as a fallback value, in case the +charset+ is absent or unrecognized.
28
+ # When +only_as_fallback+ is +true+, the given encoding will only be
29
+ # used as a fallback value, in case the +charset+ is absent or unrecognized.
30
30
  #
31
- # +charset+ can be a string (e.g. <tt>set_charset!('utf-8')</tt>) or
32
- # a symbol (e.g. <tt>set_charset!(:utf_8)</tt>) from the
31
+ # +charset+ can be a string (e.g. <tt>set_charset!('utf-8')</tt>) or
32
+ # a symbol (e.g. <tt>set_charset!(:utf_8)</tt>) from the
33
33
  # W3CValidators::CHARSETS hash.
34
34
  #
35
35
  # Has no effect when using validate_uri_quickly.
@@ -45,14 +45,14 @@ module W3CValidators
45
45
  @options[:fbc] = only_as_fallback
46
46
  end
47
47
 
48
- # Specify the Document Type (+DOCTYPE+) to use when parsing the document.
48
+ # Specify the Document Type (+DOCTYPE+) to use when parsing the document.
49
49
  #
50
- # When +only_as_fallback+ is +true+, the given document type will only be
51
- # used as a fallback value, in case the document's +DOCTYPE+ declaration
50
+ # When +only_as_fallback+ is +true+, the given document type will only be
51
+ # used as a fallback value, in case the document's +DOCTYPE+ declaration
52
52
  # is missing or unrecognized.
53
53
  #
54
- # +doctype+ can be a string (e.g. <tt>set_doctype!('HTML 3.2')</tt>) or
55
- # a symbol (e.g. <tt>set_doctype!(:html32)</tt>) from the
54
+ # +doctype+ can be a string (e.g. <tt>set_doctype!('HTML 3.2')</tt>) or
55
+ # a symbol (e.g. <tt>set_doctype!(:html32)</tt>) from the
56
56
  # W3CValidators::DOCTYPES hash.
57
57
  #
58
58
  # Has no effect when using validate_uri_quickly.
@@ -68,11 +68,11 @@ module W3CValidators
68
68
  @options[:fbd] = only_as_fallback
69
69
  end
70
70
 
71
- # When set the validator will output some extra debugging information on
72
- # the validated resource (such as HTTP headers) and validation process
71
+ # When set the validator will output some extra debugging information on
72
+ # the validated resource (such as HTTP headers) and validation process
73
73
  # (such as parser used, parse mode, etc.).
74
74
  #
75
- # Debugging information is stored in the Results +debug_messages+ hash.
75
+ # Debugging information is stored in the Results +debug_messages+ hash.
76
76
  # Custom debugging messages can be set with Results#add_debug_message.
77
77
  #
78
78
  # Has no effect when using validate_uri_quickly.
@@ -100,7 +100,7 @@ module W3CValidators
100
100
  def validate_text(text)
101
101
  return validate({:fragment => text}, false)
102
102
  end
103
-
103
+
104
104
  # Validate the markup of a local file.
105
105
  #
106
106
  # +file_path+ may be either the fully-expanded path to the file or
@@ -112,7 +112,7 @@ module W3CValidators
112
112
  src = file_path.read
113
113
  else
114
114
  src = read_local_file(file_path)
115
- end
115
+ end
116
116
 
117
117
  return validate({:uploaded_file => src, :file_path => file_path}, false)
118
118
  end
@@ -138,9 +138,9 @@ protected
138
138
  # Perform sanity checks on request params
139
139
  def get_request_options(options) # :nodoc:
140
140
  options = @options.merge(options)
141
-
141
+
142
142
  options[:output] = SOAP_OUTPUT_PARAM
143
-
143
+
144
144
  unless options[:uri] or options[:uploaded_file] or options[:fragment]
145
145
  raise ArgumentError, "an uri, uploaded file or fragment is required."
146
146
  end
@@ -150,7 +150,7 @@ protected
150
150
  if options[:uri] and not options[:uri].kind_of?(String)
151
151
  options[:uri] = options[:uri].to_s
152
152
  end
153
-
153
+
154
154
  # Convert booleans to integers
155
155
  [:fbc, :fbd, :verbose, :debug, :ss, :outline].each do |k|
156
156
  if options.has_key?(k) and not options[k].kind_of?(Fixnum)
@@ -169,12 +169,12 @@ protected
169
169
  # Returns W3CValidators::Results.
170
170
  def parse_soap_response(response) # :nodoc:
171
171
  doc = Nokogiri::XML(response)
172
- doc.remove_namespaces!
172
+ doc.remove_namespaces!
173
173
 
174
174
  result_params = {}
175
175
 
176
- {:doctype => 'doctype', :uri => 'uri', :charset => 'charset',
177
- :checked_by => 'checkedby', :validity => 'validity'}.each do |local_key, remote_key|
176
+ {:doctype => 'doctype', :uri => 'uri', :charset => 'charset',
177
+ :checked_by => 'checkedby', :validity => 'validity'}.each do |local_key, remote_key|
178
178
  if val = doc.css(remote_key)
179
179
  result_params[local_key] = val.text
180
180
  end
@@ -195,7 +195,7 @@ protected
195
195
  doc.css("Fault Reason Text").each do |message|
196
196
  results.add_message(:error, {:mesage => message.text})
197
197
  end
198
-
198
+
199
199
  doc.css("markupvalidationresponse debug").each do |debug|
200
200
  results.add_debug_message(debug.attribute('name').value, debug.text)
201
201
  end
@@ -212,7 +212,7 @@ protected
212
212
  # Returns Results.
213
213
  def parse_head_response(response, validated_uri = nil) # :nodoc:
214
214
  validity = (response[HEAD_STATUS_HEADER].downcase == 'valid')
215
-
215
+
216
216
  results = Results.new(:uri => validated_uri, :validity => validity)
217
217
 
218
218
  # Fill the results with empty error messages so we can count them
@@ -222,6 +222,6 @@ protected
222
222
  results
223
223
  end
224
224
 
225
-
225
+
226
226
  end
227
227
  end