mof 0.3.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in mof.gemspec
4
+ gemspec
@@ -1,4 +1,14 @@
1
+ === 0.3.1 2010-10-05
2
+
3
+ * Fix qualifier declaration parsing
4
+ added testcases
5
+
6
+ === 0.3.0 2010-10-04
7
+
8
+ * Refactoring
9
+ Establish 'MOF' namespace
10
+ Requires 'cim' gem now
11
+
1
12
  === 0.0.1 2010-10-03
2
13
 
3
- * 1 major enhancement:
4
- * Initial release
14
+ * Initial release
data/LICENSE ADDED
@@ -0,0 +1,58 @@
1
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.co.jp>.
2
+ You can redistribute it and/or modify it under either the terms of the GPL
3
+ (see COPYING.txt file), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a) place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b) use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c) rename any non-standard executables so the names do not conflict
21
+ with standard executables, which must also be provided.
22
+
23
+ d) make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or executable
26
+ form, provided that you do at least ONE of the following:
27
+
28
+ a) distribute the executables and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b) accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c) give non-standard executables non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d) make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under this terms.
43
+
44
+ They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
45
+ files under the ./missing directory. See each file for the copying
46
+ condition.
47
+
48
+ 5. The scripts and library files supplied as input to or produced as
49
+ output from the software do not automatically fall under the
50
+ copyright of the software, but belong to whomever generated them,
51
+ and may be sold commercially, and may be aggregated with this
52
+ software.
53
+
54
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
55
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
56
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
57
+ PURPOSE.
58
+
@@ -1,9 +1,5 @@
1
1
  = mof
2
2
 
3
- * http://github.com/kkaempf/mof
4
-
5
- == DESCRIPTION:
6
-
7
3
  A parser for the Managed Object Format (MOF) language used to describe
8
4
  classes and instances of the Common Information Model (CIM)
9
5
 
@@ -43,16 +39,13 @@ See http://www.dmtf.org/education/mof
43
39
  puts res
44
40
  end
45
41
 
46
-
47
42
  == REQUIREMENTS:
48
43
 
49
44
  * cim (http://rubygems.org/gems/cim)
50
- (https://build.opensuse.org/package/show?package=rubygem-cim&project=devel:languages:ruby:extensions)
51
45
 
52
46
  == INSTALL:
53
47
 
54
- * sudo gem install cim
55
- (or use rubygem-cim rpm)
48
+ gem install cim
56
49
 
57
50
  == LICENSE:
58
51
 
@@ -0,0 +1,57 @@
1
+ = mof
2
+
3
+ A parser for the Managed Object Format (MOF) language used to describe
4
+ classes and instances of the Common Information Model (CIM)
5
+
6
+ See http://www.dmtf.org/education/mof
7
+
8
+ == FEATURES/PROBLEMS:
9
+
10
+ * Uses Racc (Ruby Yacc) as parser generator
11
+ * Provides class information as Ruby objects (using the 'cim' gem)
12
+ * Can switch between DMTFs standard format and the one used in
13
+ Microsofts WMI implementation (http://msdn.microsoft.com/en-us/library/aa823192(VS.85).aspx)
14
+
15
+ == SYNOPSIS:
16
+
17
+ * A simple mof reader for validation of MOF files
18
+
19
+ require 'mof'
20
+ moffiles, options = Mofparser.argv_handler "moflint", ARGV
21
+ options[:style] ||= :cim;
22
+ options[:includes] ||= []
23
+ options[:includes].unshift(Pathname.new ".")
24
+ options[:includes].unshift(Pathname.new "/usr/share/mof/cim-current")
25
+
26
+ moffiles.unshift "qualifiers.mof" unless moffiles.include? "qualifiers.mof"
27
+
28
+ parser = Mofparser.new options
29
+
30
+ begin
31
+ result = parser.parse moffiles
32
+ rescue Exception => e
33
+ parser.error_handler e
34
+ exit 1
35
+ end
36
+
37
+ result.each do |name,res|
38
+ puts "/*=============== #{name} ===================*/\n"
39
+ puts res
40
+ end
41
+
42
+
43
+ == REQUIREMENTS:
44
+
45
+ * cim (http://rubygems.org/gems/cim)
46
+
47
+ == INSTALL:
48
+
49
+ gem install cim
50
+
51
+ == LICENSE:
52
+
53
+ (The Ruby License)
54
+
55
+ Copyright (c) 2010 Klaus Kämpf <kkaempf@suse.de>
56
+
57
+ See http://www.ruby-lang.org/en/LICENSE.txt for the full text
data/Rakefile CHANGED
@@ -1,29 +1,5 @@
1
- require 'rubygems'
2
- gem 'hoe', '>= 2.1.0'
3
- require 'hoe'
4
- require 'fileutils'
5
-
6
- Hoe.plugin :newgem
7
- # Hoe.plugin :website
8
- Hoe.plugin :cucumberfeatures
9
-
10
- # Generate all the Rake tasks
11
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
12
- $hoe = Hoe.spec 'mof' do
13
- self.developer 'Klaus Kämpf', 'kkaempf@suse.de'
14
- self.extra_deps = [['cim','>= 0.2.7']]
15
-
16
- end
17
-
18
- require 'newgem/tasks'
19
- Dir['tasks/**/*.rake'].each { |t| load t }
20
-
21
- # TODO - want other tests/tasks run by default? Add them to the list
22
- # remove_task :default
23
- # task :default => [:spec, :features]
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
24
3
 
25
4
  task :default => [:test]
26
-
27
- task :test => [:build]
28
-
29
- task :build => ["lib/mof/parser.rb"]
5
+ Dir['tasks/**/*.rake'].each { |t| load t }
@@ -19,6 +19,11 @@ options[:includes].unshift(Pathname.new ".")
19
19
 
20
20
  parser = MOF::Parser.new options
21
21
 
22
+ if moffiles.empty?
23
+ $stderr.puts "Usage: moflint [-I <incdir>] <moffile> [ <moffile> ... ]"
24
+ exit 1
25
+ end
26
+
22
27
  begin
23
28
  result = parser.parse moffiles
24
29
  rescue Exception => e
@@ -0,0 +1,7 @@
1
+ // definitions for SBLIM
2
+
3
+ Qualifier Provider : string,
4
+ Scope(class, association, indication, reference);
5
+
6
+
7
+ // EOF
@@ -0,0 +1,213 @@
1
+ // definitions for Microsoft WBEM
2
+
3
+ #pragma locale ("en_US")
4
+
5
+ #pragma include( "qualifiers.mof" )
6
+ #pragma include ("qualifiers_optional.mof")
7
+
8
+ /* --- Qualifiers */
9
+
10
+ Qualifier Locale : uint32 = 0,
11
+ Scope(class, association, indication, reference);
12
+
13
+ Qualifier UUID : string,
14
+ Scope(class, association, indication, reference);
15
+
16
+ Qualifier CIM_key : boolean,
17
+ Scope(property, association, indication, reference);
18
+
19
+ Qualifier SupportsDelete : boolean,
20
+ Scope(class);
21
+
22
+ Qualifier DeleteBy : string,
23
+ Scope(class);
24
+
25
+ Qualifier Fixed : boolean,
26
+ Scope(property);
27
+
28
+ Qualifier Implemented : boolean,
29
+ Scope(method);
30
+
31
+ Qualifier Constructor : boolean,
32
+ Scope(method);
33
+
34
+ Qualifier Destructor : boolean,
35
+ Scope(method);
36
+
37
+ Qualifier optional : boolean,
38
+ Scope(parameter);
39
+
40
+ Qualifier Privileges : string[],
41
+ Scope(class,association,method,property);
42
+
43
+ Qualifier Dynamic : boolean,
44
+ Scope(class,association,indication);
45
+
46
+ Qualifier Singleton : boolean,
47
+ Scope(class,association);
48
+
49
+ Qualifier SupportsCreate : boolean,
50
+ Scope(class,association);
51
+
52
+ Qualifier SupportsUpdate : boolean,
53
+ Scope(class,association);
54
+
55
+ Qualifier CreateBy : string,
56
+ Scope(class,association);
57
+
58
+ Qualifier Value : string,
59
+ Scope(property);
60
+
61
+ Qualifier Values : string[],
62
+ Scope(property);
63
+
64
+ Qualifier Value_Map : string[],
65
+ Scope(property);
66
+
67
+ Qualifier DefineValues : string[],
68
+ Scope(property);
69
+
70
+ Qualifier ValueDescriptions : string[],
71
+ Scope(property);
72
+
73
+ Qualifier Amendment : boolean,
74
+ Scope(class,association);
75
+
76
+ Qualifier PropertyContext : string = Null,
77
+ Scope(property);
78
+
79
+ Qualifier Overwrite : boolean,
80
+ Scope(property);
81
+
82
+ Qualifier HasClassRefs : boolean,
83
+ Scope(class);
84
+
85
+ Qualifier ClassRef : string[],
86
+ Scope(property);
87
+
88
+ Qualifier DefaultValue : string,
89
+ Scope(property);
90
+
91
+ Qualifier Guid : string,
92
+ Scope(class);
93
+
94
+ Qualifier Not_Null : boolean,
95
+ Scope(property);
96
+
97
+ Qualifier NotNull : boolean,
98
+ Scope(property);
99
+
100
+ Qualifier Template : boolean,
101
+ Scope(property);
102
+
103
+ Qualifier ClassContext : string,
104
+ Scope(class);
105
+
106
+ /* Typo in whqlprov.mof */
107
+ Qualifier Decription : string,
108
+ Scope(property);
109
+
110
+ Qualifier ImplementationSource : string,
111
+ Scope(property);
112
+
113
+ Qualifier Volatile : boolean,
114
+ Scope(property);
115
+
116
+ Qualifier Range : string,
117
+ Scope(property);
118
+
119
+ Qualifier EnumPrivileges : string,
120
+ Scope(property);
121
+
122
+ Qualifier bypass_getobject : boolean,
123
+ Scope(method);
124
+
125
+ Qualifier EventId : uint32,
126
+ Scope(class);
127
+
128
+ Qualifier EventType : uint32,
129
+ Scope(class);
130
+
131
+ Qualifier InsertionStringTemplates : string[],
132
+ Scope(class);
133
+
134
+ Qualifier WritePrivileges : string[],
135
+ Scope(property);
136
+
137
+ Qualifier DynProps : boolean,
138
+ Scope(class);
139
+
140
+ Qualifier SubType : string,
141
+ Scope(property);
142
+
143
+ /* --- Classes */
144
+
145
+ class __Namespace {
146
+ [Description( "Windows internal namespace" ), key]
147
+ string Name;
148
+ };
149
+
150
+
151
+ class __ExtendedStatus {
152
+ };
153
+
154
+ [indication]
155
+ class __ExtrinsicEvent {
156
+ };
157
+
158
+ /*
159
+ * put this into qualifiers.mof
160
+ *
161
+ * Qualifier Read : boolean = true,
162
+ * Scope(property,reference); // add reference
163
+ *
164
+ * Qualifier Max : uint32 = null,
165
+ * Scope(reference, property); // add property
166
+ *
167
+ *
168
+ */
169
+
170
+ class __Win32Provider {
171
+ [key]
172
+ string Name; // = "CIMWin32";
173
+
174
+ string ClsId; // = "{d63a5850-8f16-11cf-9f47-00aa00bf345c}";
175
+ uint16 ImpersonationLevel; // = 1;
176
+ string PerUserInitialization; // = "FALSE";
177
+ string HostingModel; // = "NetworkServiceHost";
178
+ };
179
+
180
+
181
+ /* --- Associations */
182
+
183
+ [Association]
184
+ class __InstanceProviderRegistration {
185
+ __Namespace Ref Namespace;
186
+
187
+ [key]
188
+ __Win32Provider Ref Provider; // = $P;
189
+ string SupportsGet; // = "TRUE";
190
+ string SupportsPut; // = "TRUE";
191
+ string SupportsDelete; // = "TRUE";
192
+ string SupportsEnumeration; // = "TRUE";
193
+ string QuerySupportLevels[]; // = {"WQL:UnarySelect"};
194
+ };
195
+
196
+ [Association]
197
+ class __MethodProviderRegistration {
198
+ __Namespace Ref Namespace;
199
+
200
+ [key]
201
+ __Win32Provider Ref Provider; // = $P;
202
+ };
203
+
204
+ [Association]
205
+ class __EventProviderRegistration {
206
+ __Namespace Ref Namespace;
207
+
208
+ [key]
209
+ __Win32Provider Ref Provider; // = $P;
210
+ string EventQueryList;
211
+ };
212
+
213
+ // EOF
data/lib/mof.rb CHANGED
@@ -2,6 +2,6 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module MOF
5
- VERSION = '0.3.0'
5
+ VERSION = '0.3.2'
6
6
  require "mof/parser"
7
7
  end
@@ -49,16 +49,18 @@ module Helper
49
49
  # $stderr.puts "\tNope"
50
50
  end
51
51
  end
52
+ # still not found in include dirs ?
52
53
  unless file
53
- if name && name[0,1] != "/" # not absolute
54
- dir = File.dirname(name) # try same dir as last file
55
- f = File.join(dir, p)
54
+ # might be relative to last path
55
+ if @name && @name[0,1] != "/" # not absolute
56
+ dir = File.dirname(@name) # try same dir as last file
57
+ f = File.join(dir, name)
56
58
  file = File.open(f) if File.readable?( f )
57
59
  end
58
60
  end
59
-
61
+ # no luck opening the file, give up
60
62
  unless file
61
- return if origin == :pragma
63
+ return if origin == :pragma # silently ignore failing pragmas
62
64
  $stderr.puts "'#{name}' not found, searched in"
63
65
  @includes.each { |incdir| $stderr.puts " #{incdir}" }
64
66
  raise "Cannot open #{name}"