rubywbem 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.
@@ -0,0 +1,93 @@
1
+ #
2
+ # Copyright 2006, Red Hat, Inc
3
+ # Scott Seago <sseago@redhat.com>
4
+ #
5
+ # derived from pywbem, written by Tim Potter <tpot@hp.com>, Martin Pool <mbp@hp.com>
6
+ #
7
+ # This program is free software; you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation; either version 2 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # You should have received a copy of the GNU General Public License
13
+ # along with this program; if not, write to the Free Software
14
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
+ #
16
+
17
+ # Validate XML input on stdin against the CIM DTD.
18
+
19
+
20
+
21
+ DTD_FILE = 'CIM_DTD_V22.dtd'
22
+
23
+ module WBEM
24
+ module Validate
25
+ def validate_xml(data, dtd_directory = nil)
26
+
27
+ # Run xmllint to validate file
28
+
29
+ dtd_file = DTD_FILE
30
+ unless dtd_directory.nil?
31
+ dtd_file = '%s/%s' % [dtd_directory, DTD_FILE]
32
+ end
33
+
34
+ pid, stdin, stdout, stderr = run_pipe('xmllint --dtdvalid %s --noout -' % dtd_file)
35
+ stdin.puts(data)
36
+ stdin.close_write
37
+ exited_pid, waitstatus = Process.waitpid2(pid, 0)
38
+ out = stdout.gets(nil)
39
+ log(out) if out
40
+ err = stderr.gets(nil)
41
+ log(err) if err
42
+
43
+ if (waitstatus.signaled? || waitstatus.exitstatus != 0)
44
+ return false
45
+ end
46
+
47
+ return true
48
+ end
49
+
50
+ def run_pipe(cmd)
51
+ #"""Run a command, capturing stdin, stdout, stderr, and PID
52
+ #
53
+ #
54
+ #Returns (pid, stdin, stdout, stderr)."""
55
+ inread, inwrite = IO.pipe
56
+ outread, outwrite = IO.pipe
57
+ errread, errwrite = IO.pipe
58
+ pid = fork()
59
+ if pid.nil?
60
+ # child
61
+ begin
62
+ inwrite.close
63
+ outread.close
64
+ errread.close
65
+ $stdout.reopen(outwrite)
66
+ $stderr.reopen(errwrite)
67
+ $stdin.reopen(inread)
68
+ if cmd.is_a?(String)
69
+ cmd = ['/bin/sh', '-c', cmd]
70
+ end
71
+ exec(*cmd)
72
+ ensure
73
+ exit!(127)
74
+ end
75
+ else
76
+ # parent
77
+ inread.close
78
+ outwrite.close
79
+ errwrite.close
80
+ return pid, inwrite, outread, errread
81
+
82
+ end
83
+ end
84
+
85
+
86
+ end
87
+ end
88
+
89
+ if __FILE__ == $0
90
+
91
+ data = string.join(STDIN.readlines(), '')
92
+ exit(validate_xml(data))
93
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: rubywbem
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2006-09-21 00:00:00 -04:00
8
+ summary: "RubyWBEM: a pure-Ruby library for performing operations using the WBEM management protocol."
9
+ require_paths:
10
+ - lib
11
+ email:
12
+ homepage:
13
+ rubyforge_project:
14
+ description: This is a short description
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ authors: []
29
+
30
+ files:
31
+ - lib/wbem.rb
32
+ - lib/wbem/cim_constants.rb
33
+ - lib/wbem/cim_operations.rb
34
+ - lib/wbem/cim_types.rb
35
+ - lib/wbem/tupletree.rb
36
+ - lib/wbem/tupleparse.rb
37
+ - lib/wbem/cim_xml.rb
38
+ - lib/wbem/cim_obj.rb
39
+ - lib/wbem/cim_http.rb
40
+ - CHANGELOG
41
+ - Rakefile
42
+ - AUTHORS
43
+ - LICENSE
44
+ - README
45
+ - ruby-wbem.spec
46
+ - testsuite/test_cim_obj.rb
47
+ - testsuite/test_cim_operations.rb
48
+ - testsuite/test_tupleparse.rb
49
+ - testsuite/test_nocasehash.rb
50
+ - testsuite/test_cim_xml.rb
51
+ - testsuite/comfychair.rb
52
+ - testsuite/validate.rb
53
+ - testsuite/runtests.sh
54
+ - testsuite/CIM_DTD_V22.dtd
55
+ test_files: []
56
+
57
+ rdoc_options: []
58
+
59
+ extra_rdoc_files: []
60
+
61
+ executables: []
62
+
63
+ extensions: []
64
+
65
+ requirements:
66
+ - none
67
+ dependencies: []
68
+