w3c_validators 1.3.1 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YWFjNTU0OWFlMTA4ZGZlYTliNjRkYWE0MjE2ZjQ1N2RjMjA4ODU4OA==
5
- data.tar.gz: !binary |-
6
- YTQwZjFlNWI4MWViYzhlZmQwYmY5ZmUxODJhMTU0YjJlZmUyN2I0NA==
2
+ SHA256:
3
+ metadata.gz: 93c24630d8eff576b83949a26d71d048d5a126bc17829576c3fbe00f7715239f
4
+ data.tar.gz: 25513e9917618bdc76488ffe559a5366c2ebe87f465d53babedcac4467fe4d81
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NjY2OGFjOTAwNmNiNGFmNGFhMTNkMWY4MWNmNzViYzU4ZTRhYmUyNzkyYzYw
10
- YTFjMDI5NWZjZGU3ZTUyOTc3NDcwZTFlNWI1OWRkNjZlOTE3OTFlY2Y4OTY0
11
- OWJhOTVhZWU5NWMwY2VlNGI2OTM5NmQyYTA1MjZjNGU3ZGVlYjU=
12
- data.tar.gz: !binary |-
13
- OTE1OGJhNzhhYWYwYTNjOGEyYThkMmZhZTU1Nzg5ODFlNWYzNGNhZGJhMWNk
14
- Nzk5MDRlYzRhYWE4NWE5Zjk3N2U1Njg0MDY0MGE5MDJlZjY2OGI1NzdmZmY1
15
- ZjhmYWI2NmViMzViYjBiNGU0ZjliNmVmOGQwY2Y4MGExMGZkNzI=
6
+ metadata.gz: 60350bd80921cabf33d2b7407b89c9f42cf141df15089549f4a7d088a78be6fbf6393506c4ca0d65b497558eb41c3e93407d130430b493834853244386b55b05
7
+ data.tar.gz: 6a135e36f46733b84ccfae834a7e1c4ac69734bc69735ff9ee81ac2af72225df823651e05655d6836993afc48ab42377f5f91c3c0357b186795dc777e4dd5c8a
data/.gitignore CHANGED
@@ -2,4 +2,4 @@ docs/
2
2
  *.gem
3
3
  .ruby-version
4
4
  .ruby-gemset
5
- .Gemfile.lock
5
+ Gemfile.lock
@@ -1,7 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.1
4
- - 2.2.5
5
- - 2.1.9
6
- - 2.0.0
3
+ - ruby-head
4
+ - 2.7.1
5
+ - 2.6.6
6
+ - 2.5.8
7
+ - 2.4.10
8
+ - 2.3.8
7
9
 
data/CHANGELOG CHANGED
@@ -54,3 +54,25 @@
54
54
  * update gemspec
55
55
  * update test to point to project gh-pages
56
56
 
57
+ == Version 1.3.2
58
+ * relax constraint on json gem to >=1.8 instead of ~>2.0
59
+ * add test of ruby 2.4.0 + drop test of ruby 2.0.0
60
+
61
+ == Version 1.3.3
62
+ * add deprecation warning for class MarkupValidator
63
+ * raise ValidatorUnavailable when connection to uri is refused
64
+ * Change the Nu Validator URL to "https://validator.w3.org/nu/" (https://validator.nu is returning 502)
65
+
66
+ == Version 1.3.4
67
+ * migrate css validator to https (instead of http)
68
+ * add test of ruby 2.5
69
+ * remove unused variable in nu validator code
70
+
71
+ == Version 1.3.5
72
+ * replace Net::HTTPServerException (deprecated) by Net::HTTPClientException
73
+ * fix bad indentation of rescue in validators classes
74
+ * add test for ruby 2.6, update 2.5, 2.4, 2.3 tested version and remove 2.2 and 2.1 versions
75
+
76
+ == Version 1.3.6
77
+ * update README to clarify usage with Ruby frameworks
78
+ * update dependencies to be ready for ruby 3.0
data/README.md CHANGED
@@ -148,6 +148,36 @@ You can use a proxy server by passing in its information in the contructor.
148
148
  puts "#{key}: #{value}"
149
149
  end
150
150
  ```
151
+
152
+ ### Examples with Ruby Frameworks
153
+
154
+ ```
155
+ # you can easily incorporate this in your ruby based frameworks:
156
+
157
+ # Gemfile
158
+ group :test do
159
+ gem 'w3c_validators'
160
+ end
161
+
162
+ # And in your relevant test file:
163
+
164
+ require 'w3c_validators'
165
+
166
+ class FoosControllerTest < ActionDispatch::IntegrationTest
167
+ setup do
168
+ @validator = W3CValidators::NuValidator.new
169
+ end
170
+
171
+ test "index" do
172
+ get foos_url
173
+ assert_equal 0, @validator.validate_text(response.body).errors.length
174
+ end
175
+ end
176
+
177
+ # granted it's not perfect, but hopefully that will at least get you going
178
+ # you might want to customise things so that it delivers a particular output in case an error shows up.
179
+ ```
180
+
151
181
  ### Tests
152
182
 
153
183
  Run unit tests using <tt>rake test</tt>. Note that there is a one second delay
@@ -1,6 +1,6 @@
1
1
  module W3CValidators
2
2
  class CSSValidator < Validator
3
- CSS_VALIDATOR_URI = 'http://jigsaw.w3.org/css-validator/validator'
3
+ CSS_VALIDATOR_URI = 'https://jigsaw.w3.org/css-validator/validator'
4
4
 
5
5
  # Create a new instance of the CSSValidator.
6
6
  #
@@ -14,6 +14,7 @@ module W3CValidators
14
14
  #
15
15
  # See Validator#new for proxy server options.
16
16
  def initialize(options = {})
17
+ puts "The MarkupValidator class is deprecated (cf. https://validator.w3.org/docs/obsolete-api.html) as it cannot process HTML5 documents.\nPlease prefer the NuValidator class instead."
17
18
  if options[:validator_uri]
18
19
  @validator_uri = URI.parse(options[:validator_uri])
19
20
  options.delete(options[:validator_uri])
@@ -153,7 +154,7 @@ protected
153
154
 
154
155
  # Convert booleans to integers
155
156
  [:fbc, :fbd, :verbose, :debug, :ss, :outline].each do |k|
156
- if options.has_key?(k) and not options[k].kind_of?(Fixnum)
157
+ if options.has_key?(k) and not options[k].kind_of?(Integer)
157
158
  options[k] = options[k] ? 1 : 0
158
159
  end
159
160
  end
@@ -201,8 +202,8 @@ protected
201
202
  end
202
203
  return results
203
204
 
204
- rescue Exception => e
205
- handle_exception e
205
+ rescue Exception => e
206
+ handle_exception e
206
207
  end
207
208
 
208
209
  # Parse the HEAD response into HTMLValidator::Results.
@@ -2,7 +2,7 @@ require 'json'
2
2
 
3
3
  module W3CValidators
4
4
  class NuValidator < Validator
5
- MARKUP_VALIDATOR_URI = 'https://validator.nu/'
5
+ MARKUP_VALIDATOR_URI = 'https://validator.w3.org/nu/'
6
6
 
7
7
  # Create a new instance of the NuValidator.
8
8
  #
@@ -44,17 +44,15 @@ module W3CValidators
44
44
 
45
45
  # Validate the markup of a local file.
46
46
  #
47
- # +file_path+ may be either the fully-expanded path to the file or
47
+ # +file+ may be either the fully-expanded path to the file or
48
48
  # an IO object (like File).
49
49
  #
50
50
  # Returns W3CValidators::Results.
51
51
  def validate_file(file)
52
52
  if file.respond_to? :read
53
53
  src = file.read
54
- file_path = file.path ||= nil
55
54
  else
56
55
  src = read_local_file(file)
57
- file_path = file
58
56
  end
59
57
 
60
58
  return validate_text(src)
@@ -142,8 +140,8 @@ protected
142
140
 
143
141
  return results
144
142
 
145
- rescue Exception => e
146
- handle_exception e
143
+ rescue Exception => e
144
+ handle_exception e
147
145
  end
148
146
  end
149
147
  end
@@ -16,6 +16,7 @@ module W3CValidators
16
16
  HEAD_STATUS_HEADER = 'X-W3C-Validator-Status'
17
17
  HEAD_ERROR_COUNT_HEADER = 'X-W3C-Validator-Errors'
18
18
  SOAP_OUTPUT_PARAM = 'soap12'
19
+ USE_NEW_EXCEPTION = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6')
19
20
 
20
21
  attr_reader :results, :validator_uri
21
22
 
@@ -112,8 +113,8 @@ module W3CValidators
112
113
  response.value
113
114
  return response
114
115
 
115
- rescue Exception => e
116
- handle_exception e
116
+ rescue Exception => e
117
+ handle_exception e
117
118
  end
118
119
 
119
120
  def create_multipart_data(options) # :nodoc:
@@ -173,8 +174,13 @@ module W3CValidators
173
174
  # Big thanks to ara.t.howard and Joel VanderWerf on Ruby-Talk for the exception handling help.
174
175
  #++
175
176
  def handle_exception(e, msg = '') # :nodoc:
177
+ if USE_NEW_EXCEPTION
178
+ http_exception = Net::HTTPClientException
179
+ else
180
+ http_exception = Net::HTTPServerException
181
+ end
176
182
  case e
177
- when Net::HTTPServerException, SocketError
183
+ when http_exception, SocketError, Errno::ECONNREFUSED
178
184
  msg = "unable to connect to the validator at #{@validator_uri} (response was #{e.message})."
179
185
  raise ValidatorUnavailable, msg, caller
180
186
  when JSON::ParserError, Nokogiri::XML::SyntaxError
@@ -1,3 +1,3 @@
1
1
  module W3CValidators
2
- VERSION = "1.3.1"
2
+ VERSION = "1.3.6"
3
3
  end
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://jigsaw.w3.org/css-validator/validator
5
+ uri: https://jigsaw.w3.org/css-validator/validator
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: "--349832898984244898448024464570528145\r\nContent-Disposition: form-data;
@@ -27,7 +27,7 @@ http_interactions:
27
27
  Cache-Control:
28
28
  - no-cache
29
29
  Date:
30
- - Thu, 27 Oct 2016 20:13:57 GMT
30
+ - Fri, 10 Aug 2018 19:59:10 GMT
31
31
  Pragma:
32
32
  - no-cache
33
33
  Transfer-Encoding:
@@ -37,20 +37,37 @@ http_interactions:
37
37
  Content-Type:
38
38
  - application/soap+xml;charset=utf-8
39
39
  Server:
40
- - Jigsaw/2.3.0-beta2
40
+ - Jigsaw/2.3.0-beta3
41
41
  Vary:
42
42
  - Accept-Language
43
+ Access-Control-Allow-Origin:
44
+ - "*"
45
+ Access-Control-Allow-Headers:
46
+ - content-type,accept-charset
47
+ Access-Control-Allow-Methods:
48
+ - GET, HEAD, POST, OPTIONS
49
+ Access-Control-Max-Age:
50
+ - '600'
43
51
  X-W3c-Validator-Errors:
44
52
  - '1'
45
53
  X-W3c-Validator-Status:
46
54
  - Invalid
55
+ Strict-Transport-Security:
56
+ - max-age=15552015; includeSubDomains; preload
57
+ Public-Key-Pins:
58
+ - pin-sha256="cN0QSpPIkuwpT6iP2YjEo1bEwGpH/yiUn6yhdy+HNto="; pin-sha256="WGJkyYjx1QMdMe0UqlyOKXtydPDVrk7sl2fV+nNm1r4=";
59
+ pin-sha256="LrKdTxZLRTvyHM4/atX2nquX9BeHRZMCxg3cf4rhc2I="; max-age=864000
60
+ X-Frame-Options:
61
+ - deny
62
+ X-Xss-Protection:
63
+ - 1; mode=block
47
64
  body:
48
65
  encoding: UTF-8
49
66
  string: "<?xml version='1.0' encoding=\"utf-8\"?>\n<env:Envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\">\n
50
67
  \ <env:Body>\n <m:cssvalidationresponse\n env:encodingStyle=\"http://www.w3.org/2003/05/soap-encoding\"\n
51
68
  \ xmlns:m=\"http://www.w3.org/2005/07/css-validator\">\n <m:uri>TextArea</m:uri>\n
52
69
  \ <m:checkedby>http://jigsaw.w3.org/css-validator/</m:checkedby>\n
53
- \ <m:csslevel>css3</m:csslevel>\n <m:date>2016-10-27T08:13:57Z</m:date>\n
70
+ \ <m:csslevel>css3</m:csslevel>\n <m:date>2018-08-10T07:59:10Z</m:date>\n
54
71
  \ <m:validity>false</m:validity>\n <m:result>\n <m:errors
55
72
  xml:lang=\"en\">\n <m:errorcount>1</m:errorcount>\n \n
56
73
  \ <m:errorlist>\n <m:uri>file://localhost/TextArea</m:uri>\n
@@ -61,12 +78,12 @@ http_interactions:
61
78
  \ blue\n </m:skippedstring>\n
62
79
  \ <m:type>value</m:type>\n \n <m:message>\n
63
80
  \ \n Value Error : margin (nullbox.html#propdef-margin)\n
64
- \ \n blue is not a margin value : \n
65
- \ </m:message>\n </m:error>\n
81
+ \ \n &#8220;blue&#8221; is not a &#8220;margin&#8221;
82
+ value : \n </m:message>\n </m:error>\n
66
83
  \ \n </m:errorlist>\n \n </m:errors>\n
67
84
  \ <m:warnings xml:lang=\"en\">\n <m:warningcount>0</m:warningcount>\n
68
85
  \ </m:warnings>\n </m:result>\n </m:cssvalidationresponse>\n
69
86
  \ </env:Body>\n</env:Envelope>\n\n"
70
87
  http_version:
71
- recorded_at: Thu, 27 Oct 2016 20:13:57 GMT
88
+ recorded_at: Fri, 10 Aug 2018 19:59:10 GMT
72
89
  recorded_with: VCR 3.0.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: http://jigsaw.w3.org/css-validator/validator?output=soap12&profile=css21&text=%20%20%20%20a%20%7B%20color:%20white%3B%20%7D%0A%20%20%20%20body%20%7B%20margin:%20blue%3B%20%7D%0A%20%20%20%20%0A
5
+ uri: https://jigsaw.w3.org/css-validator/validator?output=soap12&profile=css21&text=%20%20%20%20a%20%7B%20color:%20white%3B%20%7D%0A%20%20%20%20body%20%7B%20margin:%20blue%3B%20%7D%0A%20%20%20%20%0A
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -10,7 +10,7 @@ http_interactions:
10
10
  Accept-Encoding:
11
11
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
12
  Accept:
13
- - ! '*/*'
13
+ - "*/*"
14
14
  User-Agent:
15
15
  - Ruby
16
16
  response:
@@ -21,7 +21,7 @@ http_interactions:
21
21
  Cache-Control:
22
22
  - no-cache
23
23
  Date:
24
- - Mon, 24 Oct 2016 21:28:26 GMT
24
+ - Fri, 10 Aug 2018 19:59:11 GMT
25
25
  Pragma:
26
26
  - no-cache
27
27
  Transfer-Encoding:
@@ -34,17 +34,34 @@ http_interactions:
34
34
  - Jigsaw/2.3.0-beta3
35
35
  Vary:
36
36
  - Accept-Language
37
+ Access-Control-Allow-Origin:
38
+ - "*"
39
+ Access-Control-Allow-Headers:
40
+ - content-type,accept-charset
41
+ Access-Control-Allow-Methods:
42
+ - GET, HEAD, POST, OPTIONS
43
+ Access-Control-Max-Age:
44
+ - '600'
37
45
  X-W3c-Validator-Errors:
38
46
  - '1'
39
47
  X-W3c-Validator-Status:
40
48
  - Invalid
49
+ Strict-Transport-Security:
50
+ - max-age=15552015; includeSubDomains; preload
51
+ Public-Key-Pins:
52
+ - pin-sha256="cN0QSpPIkuwpT6iP2YjEo1bEwGpH/yiUn6yhdy+HNto="; pin-sha256="WGJkyYjx1QMdMe0UqlyOKXtydPDVrk7sl2fV+nNm1r4=";
53
+ pin-sha256="LrKdTxZLRTvyHM4/atX2nquX9BeHRZMCxg3cf4rhc2I="; max-age=864000
54
+ X-Frame-Options:
55
+ - deny
56
+ X-Xss-Protection:
57
+ - 1; mode=block
41
58
  body:
42
- encoding: US-ASCII
43
- string: ! "<?xml version='1.0' encoding=\"utf-8\"?>\n<env:Envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\">\n
59
+ encoding: UTF-8
60
+ string: "<?xml version='1.0' encoding=\"utf-8\"?>\n<env:Envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\">\n
44
61
  \ <env:Body>\n <m:cssvalidationresponse\n env:encodingStyle=\"http://www.w3.org/2003/05/soap-encoding\"\n
45
62
  \ xmlns:m=\"http://www.w3.org/2005/07/css-validator\">\n <m:uri>file://localhost/TextArea</m:uri>\n
46
63
  \ <m:checkedby>http://jigsaw.w3.org/css-validator/</m:checkedby>\n
47
- \ <m:csslevel>css21</m:csslevel>\n <m:date>2016-10-24T09:28:26Z</m:date>\n
64
+ \ <m:csslevel>css21</m:csslevel>\n <m:date>2018-08-10T07:59:11Z</m:date>\n
48
65
  \ <m:validity>false</m:validity>\n <m:result>\n <m:errors
49
66
  xml:lang=\"en\">\n <m:errorcount>1</m:errorcount>\n \n
50
67
  \ <m:errorlist>\n <m:uri>file://localhost/TextArea</m:uri>\n
@@ -54,13 +71,13 @@ http_interactions:
54
71
  \ </m:errorsubtype>\n <m:skippedstring>\n
55
72
  \ blue\n </m:skippedstring>\n
56
73
  \ <m:type>value</m:type>\n \n <m:message>\n
57
- \ \n Value Error : margin (http://www.w3.org/TR/2011/REC-CSS2-20110607/box.html#propdef-margin)\n
58
- \ \n blue is not a margin value : \n
59
- \ </m:message>\n </m:error>\n
74
+ \ \n Value Error : margin ([error]box.html#propdef-margin)\n
75
+ \ \n &#8220;blue&#8221; is not a &#8220;margin&#8221;
76
+ value : \n </m:message>\n </m:error>\n
60
77
  \ \n </m:errorlist>\n \n </m:errors>\n
61
78
  \ <m:warnings xml:lang=\"en\">\n <m:warningcount>0</m:warningcount>\n
62
79
  \ </m:warnings>\n </m:result>\n </m:cssvalidationresponse>\n
63
80
  \ </env:Body>\n</env:Envelope>\n\n"
64
81
  http_version:
65
- recorded_at: Mon, 24 Oct 2016 21:28:26 GMT
82
+ recorded_at: Fri, 10 Aug 2018 19:59:11 GMT
66
83
  recorded_with: VCR 3.0.3
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: http://jigsaw.w3.org/css-validator/validator
5
+ uri: https://jigsaw.w3.org/css-validator/validator
6
6
  body:
7
7
  encoding: UTF-8
8
8
  string: "--349832898984244898448024464570528145\r\nContent-Disposition: form-data;
@@ -27,7 +27,7 @@ http_interactions:
27
27
  Cache-Control:
28
28
  - no-cache
29
29
  Date:
30
- - Thu, 27 Oct 2016 20:14:00 GMT
30
+ - Fri, 10 Aug 2018 19:59:12 GMT
31
31
  Pragma:
32
32
  - no-cache
33
33
  Transfer-Encoding:
@@ -37,20 +37,37 @@ http_interactions:
37
37
  Content-Type:
38
38
  - application/soap+xml;charset=utf-8
39
39
  Server:
40
- - Jigsaw/2.3.0-beta2
40
+ - Jigsaw/2.3.0-beta4
41
41
  Vary:
42
42
  - Accept-Language
43
+ Access-Control-Allow-Origin:
44
+ - "*"
45
+ Access-Control-Allow-Headers:
46
+ - content-type,accept-charset
47
+ Access-Control-Allow-Methods:
48
+ - GET, HEAD, POST, OPTIONS
49
+ Access-Control-Max-Age:
50
+ - '600'
43
51
  X-W3c-Validator-Errors:
44
52
  - '1'
45
53
  X-W3c-Validator-Status:
46
54
  - Invalid
55
+ Strict-Transport-Security:
56
+ - max-age=15552015; includeSubDomains; preload
57
+ Public-Key-Pins:
58
+ - pin-sha256="cN0QSpPIkuwpT6iP2YjEo1bEwGpH/yiUn6yhdy+HNto="; pin-sha256="WGJkyYjx1QMdMe0UqlyOKXtydPDVrk7sl2fV+nNm1r4=";
59
+ pin-sha256="LrKdTxZLRTvyHM4/atX2nquX9BeHRZMCxg3cf4rhc2I="; max-age=864000
60
+ X-Frame-Options:
61
+ - deny
62
+ X-Xss-Protection:
63
+ - 1; mode=block
47
64
  body:
48
65
  encoding: UTF-8
49
66
  string: "<?xml version='1.0' encoding=\"utf-8\"?>\n<env:Envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\">\n
50
67
  \ <env:Body>\n <m:cssvalidationresponse\n env:encodingStyle=\"http://www.w3.org/2003/05/soap-encoding\"\n
51
68
  \ xmlns:m=\"http://www.w3.org/2005/07/css-validator\">\n <m:uri>TextArea</m:uri>\n
52
69
  \ <m:checkedby>http://jigsaw.w3.org/css-validator/</m:checkedby>\n
53
- \ <m:csslevel>css3</m:csslevel>\n <m:date>2016-10-27T08:14:00Z</m:date>\n
70
+ \ <m:csslevel>css3</m:csslevel>\n <m:date>2018-08-10T07:59:12Z</m:date>\n
54
71
  \ <m:validity>false</m:validity>\n <m:result>\n <m:errors
55
72
  xml:lang=\"en\">\n <m:errorcount>1</m:errorcount>\n \n
56
73
  \ <m:errorlist>\n <m:uri>file://localhost/TextArea</m:uri>\n
@@ -61,12 +78,12 @@ http_interactions:
61
78
  \ blue\n </m:skippedstring>\n
62
79
  \ <m:type>value</m:type>\n \n <m:message>\n
63
80
  \ \n Value Error : margin (nullbox.html#propdef-margin)\n
64
- \ \n blue is not a margin value : \n
65
- \ </m:message>\n </m:error>\n
81
+ \ \n &#8220;blue&#8221; is not a &#8220;margin&#8221;
82
+ value : \n </m:message>\n </m:error>\n
66
83
  \ \n </m:errorlist>\n \n </m:errors>\n
67
84
  \ <m:warnings xml:lang=\"en\">\n <m:warningcount>0</m:warningcount>\n
68
85
  \ </m:warnings>\n </m:result>\n </m:cssvalidationresponse>\n
69
86
  \ </env:Body>\n</env:Envelope>\n\n"
70
87
  http_version:
71
- recorded_at: Thu, 27 Oct 2016 20:14:00 GMT
88
+ recorded_at: Fri, 10 Aug 2018 19:59:12 GMT
72
89
  recorded_with: VCR 3.0.3