validate-website 1.9.1 → 1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +5 -0
- data/lib/validate_website/option_parser.rb +1 -0
- data/lib/validate_website/validator.rb +17 -25
- data/lib/validate_website/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc639550c1560c9c30de32a770a398594030920917b57994d257c817715f8373
|
4
|
+
data.tar.gz: fbc6b126cb99f1f6276b2e7e384a640b971330813d985ddb317311d323e1c916
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32079467f77389509dd01dd8ce400acbd9bb6a0821658b8d604e891eb5129f1f25413b1f1ec37c53550b4ebe065a603ae14ffdad12ebf8c6fbb7ba99c8a26ab0
|
7
|
+
data.tar.gz: 540b198e6ecdd6f804ec9afb63f7e8282eef0c13bb5825d252770f7eed864696a3e77e196932640ac94e6d3d0176a6bbd77e77e82a3240e7c706870672662793
|
data/History.md
CHANGED
@@ -11,26 +11,24 @@ module ValidateWebsite
|
|
11
11
|
extend ValidatorClassMethods
|
12
12
|
|
13
13
|
@html5_validator_service_url = 'https://checker.html5.org/'
|
14
|
+
XHTML_SCHEMA_PATH = File.expand_path('../../data/schemas', __dir__)
|
15
|
+
@mutex = Mutex.new
|
16
|
+
|
14
17
|
class << self
|
15
18
|
attr_accessor :html5_validator_service_url
|
16
|
-
end
|
17
|
-
|
18
|
-
XHTML_PATH = File.expand_path('../../data/schemas', __dir__)
|
19
|
-
|
20
|
-
@xsd_schemas ||= {}
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
rescue Nokogiri::XML::SyntaxError
|
31
|
-
STDERR.puts "XSD SCHEMA: #{schema} cannot be loaded"
|
20
|
+
# http://www.w3.org/TR/xhtml1-schema/
|
21
|
+
def schema(namespace)
|
22
|
+
@mutex.synchronize do
|
23
|
+
Dir.chdir(XHTML_SCHEMA_PATH) do
|
24
|
+
if File.exist?("#{namespace}.xsd")
|
25
|
+
Nokogiri::XML::Schema(File.read("#{namespace}.xsd"))
|
26
|
+
end
|
27
|
+
end
|
32
28
|
end
|
33
29
|
end
|
30
|
+
|
31
|
+
alias xsd schema
|
34
32
|
end
|
35
33
|
|
36
34
|
attr_reader :original_doc, :body, :dtd, :doc, :namespace, :html5_validator
|
@@ -65,12 +63,6 @@ module ValidateWebsite
|
|
65
63
|
@ignore ? @errors.reject { |e| @ignore =~ e } : @errors
|
66
64
|
end
|
67
65
|
|
68
|
-
# http://www.w3.org/TR/xhtml1-schema/
|
69
|
-
def self.xsd(namespace)
|
70
|
-
return unless namespace
|
71
|
-
@xsd_schemas[namespace] if @xsd_schemas.key? namespace
|
72
|
-
end
|
73
|
-
|
74
66
|
private
|
75
67
|
|
76
68
|
# http://www.w3.org/TR/xhtml1/#dtds
|
@@ -95,11 +87,11 @@ module ValidateWebsite
|
|
95
87
|
def validate
|
96
88
|
if document =~ /^\<!DOCTYPE html\>/i
|
97
89
|
html5_validate
|
98
|
-
elsif self.class.
|
99
|
-
self.class.
|
90
|
+
elsif self.class.schema(@namespace)
|
91
|
+
self.class.schema(@namespace).validate(xhtml_doc)
|
100
92
|
else
|
101
93
|
# dont have xsd fall back to dtd
|
102
|
-
Dir.chdir(
|
94
|
+
Dir.chdir(XHTML_SCHEMA_PATH) do
|
103
95
|
Nokogiri::HTML.parse(document)
|
104
96
|
end.errors
|
105
97
|
end
|
@@ -138,7 +130,7 @@ module ValidateWebsite
|
|
138
130
|
end
|
139
131
|
|
140
132
|
def xhtml_doc
|
141
|
-
Dir.chdir(
|
133
|
+
Dir.chdir(XHTML_SCHEMA_PATH) do
|
142
134
|
Nokogiri::XML(document) { |cfg| cfg.nonoent.dtdload.dtdvalid.nonet }
|
143
135
|
end
|
144
136
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validate-website
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Laurent Arnoud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: crass
|