middleman-xmlvalidator 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 657c043b6cccfb08a4d56357544082d7d1283bdb
4
- data.tar.gz: 81aa7f5fe1f411b0e3874d08baa8fbdab9c7e8d4
3
+ metadata.gz: 7d22efc2ef768b664d5f318981965a54bf5c2a61
4
+ data.tar.gz: 7ae3edf7bbc7291043d4563e2e2ffce6ab5ffadc
5
5
  SHA512:
6
- metadata.gz: b4658ebc46f7a275320010f24b298aac5a18604d797cb6d3a07cc95224fea898d50d5cbafa8a8b3cd856fbe725daff36cec8d17b564c2b04e1613c69ab23ae1f
7
- data.tar.gz: a72cb0703089ac03f6a1a17a3dc4c0e11cac11dab3e3b9d204a20783c5b9bb27fd9f7f4fbc46d623acf7eb0d488c8c94fb40d9915c2ba2a33bc13af853662916
6
+ metadata.gz: 9c3351ad0bfff4375eac482ebbcdfbce8bdc0ad9735691b654940cd47c724cfdc9d580bbfc764bfc7541dfb594a28d0b0b77fddd8c2ed4ec843680783230e660
7
+ data.tar.gz: f97c0caf1e7dc370b2ab42cd94ccd3f6514ede9f8b18304a739812bfd9b236b0ef1dff7b0eb5858284ca3928e41c867d961b261bc738f0ff56eb5154d6be368b
@@ -6,41 +6,33 @@ module Middleman
6
6
 
7
7
  app.after_build do |builder|
8
8
  puts "", "Validating with NokoGiri", ""
9
- p Xmlvalidator.files_to_validate
10
-
11
- Xmlvalidator.files_to_validate.each do |full_path|
12
- file_name = full_path.split('/').last
13
- validator_file = file_name.gsub(/\.\w*/, '.xsd')
14
- validator_filepath = File.join(File.dirname(__FILE__), '/schema/' + validator_file)
15
- validator = File.exists?(validator_filepath) ? validator_file : (file_name.end_with?('.rss') ? "RSSSchema.xsd" : "XMLSchema.xsd")
16
-
17
- puts " validating".blue + " #{full_path}....." + (Xmlvalidator.valid(full_path, validator) == true ? "COMPLETE".green : "ERRORS FOUND".red)
18
- Xmlvalidator.validate(full_path, validator).each do |error|
19
- puts " " + error.message
20
- end
9
+
10
+ Dir.glob("build/**/*.{xml,rss}").each do |full_path|
11
+ Xmlvalidator.validate_file(full_path)
21
12
  end
22
13
 
23
14
  puts "", "Validation with NokoGiri " + "Complete".green, ""
24
15
  end
25
16
  end
26
17
 
27
- def files_to_validate
28
- Dir.glob("build/**/*.{xml,rss}")
29
- end
30
-
31
18
  alias :included :registered
32
19
  end
33
20
 
34
- def self.validate(document_path, schema_path)
35
- schema = Nokogiri::XML::Schema(File.read(File.join(File.dirname(File.expand_path(__FILE__)), "./schema/" + schema_path)))
36
- document = Nokogiri::XML(File.read(document_path))
37
- schema.validate(document)
21
+ def self.validate_file(file_path)
22
+ file_name = file_path.split('/').last
23
+ validator_file = file_name.gsub(/\.\w*/, '.xsd')
24
+ schema_path = File.join(File.dirname(__FILE__), '/schema/')
25
+ schema_path += File.exists?(schema_path + validator_file) ? validator_file : (file_name.end_with?('.rss') ? "RSSSchema.xsd" : "XMLSchema.xsd")
26
+
27
+ errors = Xmlvalidator.validate(file_path, schema_path)
28
+ puts " validating".blue + " #{file_path}....." + (errors.size == 0 ? "COMPLETE".green : "ERRORS FOUND".red)
29
+ errors.each { |error| puts " " + error.message }
38
30
  end
39
31
 
40
- def self.valid(document_path, schema_path)
41
- schema = Nokogiri::XML::Schema(File.read(File.join(File.dirname(File.expand_path(__FILE__)), "./schema/" + schema_path)))
32
+ def self.validate(document_path, schema_path)
33
+ schema = Nokogiri::XML::Schema(File.read(schema_path))
42
34
  document = Nokogiri::XML(File.read(document_path))
43
- schema.valid?(document)
35
+ schema.validate(document)
44
36
  end
45
37
 
46
38
  end
@@ -1,6 +1,6 @@
1
1
  module Middleman
2
2
  module Xmlvalidator
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  PACKAGE = "middleman-xmlvalidator"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-xmlvalidator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - briananders
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-16 00:00:00.000000000 Z
11
+ date: 2013-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler