xmlvalidate 0.1.0

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.
Files changed (5) hide show
  1. data/CHANGELOG.rdoc +2 -0
  2. data/MIT-LICENSE +22 -0
  3. data/README.rdoc +20 -0
  4. data/bin/xmlvalidate +41 -0
  5. metadata +95 -0
@@ -0,0 +1,2 @@
1
+ = 0.1.0 - 2010-03-15
2
+ - Initial gemmification checkin
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2008-2009 David Brady github@shinybit.com
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,20 @@
1
+ = xmlvalidate
2
+ A tool to validate XML against XSD.
3
+
4
+ == Usage
5
+ Simply run xmlvalidate, passing in the two filenames to check:
6
+
7
+ xmlvalidate schema.xsd document.xml
8
+
9
+ If the filenames differ only in the extension .xml/.xsd, you may pass
10
+ just the basename:
11
+
12
+ xmlvalidate document
13
+
14
+ == TODO
15
+ * Needs specs
16
+ * Needs documentation (Look into YARD!)
17
+ * Needs to be refactored into a libfile with methods easily usable
18
+ from in-code, like XML::validate()
19
+
20
+
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # xmlvalidate - validate an xml file with an xsd file (local files only)
4
+ #
5
+ # There are three ways to call xmlvalidate. The first is the full/long
6
+ # form, the other two are convenient shorthands for the first:
7
+ #
8
+ # xmlvalidate <xsd> <xml>
9
+ # xmlvalidate <basename>
10
+ #
11
+ # TODO:
12
+ # - Add help
13
+ # - Gemmify
14
+ # - Refactor to libs for in-code reuse (XML::validate, XML::validate!, etc)
15
+ # - Publish to gemcutter
16
+ require 'xml'
17
+
18
+ errors = []
19
+ args = ARGV.dup
20
+
21
+ # Detect first shorthand
22
+ if args.size == 1
23
+ args = [ args.last + ".xml", args.last + ".xsd" ]
24
+ end
25
+
26
+ document = LibXML::XML::Document.file(args.last)
27
+ schema = LibXML::XML::Schema.new(args.first)
28
+
29
+ result = document.validate_schema(schema) do |message,flag|
30
+ errors << message
31
+ end
32
+
33
+ if errors.length > 0
34
+ puts "#{args.last} contains errors:"
35
+ puts errors.map {|e| "ERROR: #{e}"}
36
+ else
37
+ puts "#{args.last} validates ok according to its schema."
38
+ end
39
+
40
+ exit errors.length
41
+
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xmlvalidate
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - David Brady
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-03-15 00:00:00 -06:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: trollop
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ name: libxml-ruby
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
41
+ version: "0"
42
+ type: :runtime
43
+ version_requirements: *id002
44
+ description: xmlvalidate, a tool to validate XML documents against an XSD schema
45
+ email: github@shinybit.com
46
+ executables:
47
+ - xmlvalidate
48
+ extensions: []
49
+
50
+ extra_rdoc_files:
51
+ - README.rdoc
52
+ - MIT-LICENSE
53
+ - CHANGELOG.rdoc
54
+ files:
55
+ - CHANGELOG.rdoc
56
+ - MIT-LICENSE
57
+ - README.rdoc
58
+ - bin/xmlvalidate
59
+ has_rdoc: true
60
+ homepage: http://github.com/dbrady/xmlvalidate/
61
+ licenses: []
62
+
63
+ post_install_message:
64
+ rdoc_options:
65
+ - --line-numbers
66
+ - --inline-source
67
+ - --main
68
+ - README.rdoc
69
+ - --title
70
+ - xmlvalidate
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ requirements: []
88
+
89
+ rubyforge_project:
90
+ rubygems_version: 1.3.6
91
+ signing_key:
92
+ specification_version: 3
93
+ summary: Tool to validate XML using an XSD
94
+ test_files: []
95
+