middleman-xmlvalidator 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,66 @@
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)
@@ -1,6 +1,6 @@
1
1
  module Middleman
2
2
  module Xmlvalidator
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  PACKAGE = "middleman-xmlvalidator"
5
5
  end
6
6
  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.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -92,6 +92,7 @@ files:
92
92
  - lib/middleman-xmlvalidator.rb
93
93
  - lib/middleman-xmlvalidator/extension.rb
94
94
  - lib/middleman-xmlvalidator/version.rb
95
+ - lib/middleman/xmlvalidator/extension.rb
95
96
  - lib/middleman/xmlvalidator/version.rb
96
97
  - lib/middleman_extension.rb
97
98
  - lib/schema/.DS_Store