middleman-xmlvalidator 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,6 @@ module Middleman
|
|
2
2
|
module Xmlvalidator
|
3
3
|
class << self
|
4
4
|
def registered(app)
|
5
|
-
require "nokogiri"
|
6
5
|
|
7
6
|
app.after_build do |builder|
|
8
7
|
puts "", "Validating with NokoGiri", ""
|
@@ -61,6 +60,4 @@ module Middleman
|
|
61
60
|
document = Nokogiri::XML(File.read(document_path))
|
62
61
|
schema.valid?(document)
|
63
62
|
end
|
64
|
-
end
|
65
|
-
|
66
|
-
::Middleman::Extensions.register(:validate_xml, Middleman::Xmlvalidator)
|
63
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-xmlvalidator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -90,8 +90,6 @@ files:
|
|
90
90
|
- Rakefile
|
91
91
|
- lib/.DS_Store
|
92
92
|
- lib/middleman-xmlvalidator.rb
|
93
|
-
- lib/middleman-xmlvalidator/extension.rb
|
94
|
-
- lib/middleman-xmlvalidator/version.rb
|
95
93
|
- lib/middleman/xmlvalidator/extension.rb
|
96
94
|
- lib/middleman/xmlvalidator/version.rb
|
97
95
|
- lib/middleman_extension.rb
|
@@ -1,66 +0,0 @@
|
|
1
|
-
module Middleman
|
2
|
-
module Xmlvalidator
|
3
|
-
class << self
|
4
|
-
def registered(app)
|
5
|
-
require "nokogiri"
|
6
|
-
|
7
|
-
app.after_build do |builder|
|
8
|
-
puts "", "Validating with NokoGiri", ""
|
9
|
-
|
10
|
-
Dir.glob("build/**/*BingSiteAuth.xml").each do |full_path|
|
11
|
-
puts " validating".blue + " #{full_path}....." + (ValidateNokoGiri.valid(full_path, 'BingSiteAuth.xsd') == true ? "COMPLETE".green : "ERRORS FOUND".red)
|
12
|
-
ValidateNokoGiri.validate(full_path, 'BingSiteAuth.xsd').each do |error|
|
13
|
-
puts " " + error.message
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
Dir.glob("build/**/*crossdomain.xml").each do |full_path|
|
18
|
-
puts " validating".blue + " #{full_path}....." + (ValidateNokoGiri.valid(full_path, 'crossdomain.xsd') == true ? "COMPLETE".green : "ERRORS FOUND".red)
|
19
|
-
ValidateNokoGiri.validate(full_path, 'crossdomain.xsd').each do |error|
|
20
|
-
puts " " + error.message
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
Dir.glob("build/**/*Sitemap.xml").each do |full_path|
|
25
|
-
puts " validating".blue + " #{full_path}....." + (ValidateNokoGiri.valid(full_path, 'Sitemap3.xsd') == true ? "COMPLETE".green : "ERRORS FOUND".red)
|
26
|
-
ValidateNokoGiri.validate(full_path, 'Sitemap3.xsd').each do |error|
|
27
|
-
puts " " + error.message
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
Dir.glob("build/**/*.rss").each do |full_path|
|
32
|
-
puts " validating".blue + " #{full_path}....." + (ValidateNokoGiri.valid(full_path, 'RSSSchema.xsd') == true ? "COMPLETE".green : "ERRORS FOUND".red)
|
33
|
-
ValidateNokoGiri.validate(full_path, 'RSSSchema.xsd').each do |error|
|
34
|
-
puts " " + error.message
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
Dir.glob("build/**/*.xml").each do |full_path|
|
39
|
-
if not (full_path.match(/^.*BingSiteAuth.xml$/) || full_path.match(/^.*crossdomain.xml$/) || full_path.match(/^.*Sitemap.xml$/))
|
40
|
-
puts " validating".blue + " #{full_path}....." + (ValidateNokoGiri.valid(full_path, 'XMLSchema.xsd') == true ? "COMPLETE".green : "ERRORS FOUND".red)
|
41
|
-
ValidateNokoGiri.validate(full_path, 'XMLSchema.xsd').each do |error|
|
42
|
-
puts " " + error.message
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
puts "", "Validation with NokoGiri " + "Complete".green, ""
|
48
|
-
end
|
49
|
-
end
|
50
|
-
alias :included :registered
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.validate(document_path, schema_path)
|
54
|
-
schema = Nokogiri::XML::Schema(File.read("lib/schema/" + schema_path))
|
55
|
-
document = Nokogiri::XML(File.read(document_path))
|
56
|
-
schema.validate(document)
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.valid(document_path, schema_path)
|
60
|
-
schema = Nokogiri::XML::Schema(File.read("lib/schema/" + schema_path))
|
61
|
-
document = Nokogiri::XML(File.read(document_path))
|
62
|
-
schema.valid?(document)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
::Middleman::Extensions.register(:validate_xml, Middleman::Xmlvalidator)
|