mof 0.3.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
3
 
4
- task :default => [:test]
5
4
  Dir['tasks/**/*.rake'].each { |t| load t }
5
+
6
+ task :default => [:test]
@@ -10,6 +10,9 @@
10
10
 
11
11
  require 'rubygems'
12
12
  require 'pathname'
13
+
14
+ $:.push(File.join(File.dirname(__FILE__), '..', 'lib'))
15
+
13
16
  require 'mof'
14
17
 
15
18
  moffiles, options = MOF::Parser.argv_handler "moflint", ARGV
data/lib/mof.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
+ # keep version separate so mof.gemspec can source it without all the rest
5
+ require "mof/version"
6
+
4
7
  module MOF
5
- VERSION = '0.3.2'
6
8
  require "mof/parser"
7
9
  end
@@ -124,7 +124,8 @@ module Helper
124
124
  s = stack[idx]
125
125
  c = s.class
126
126
  case s
127
- when String, NilClass: s = s.inspect
127
+ when String, NilClass
128
+ s = s.inspect
128
129
  else
129
130
  s = s.to_s
130
131
  end
@@ -22,14 +22,14 @@ module MOF
22
22
 
23
23
  class Parser < Racc::Parser
24
24
 
25
- module_eval <<'..end lib/mof/parser.y modeval..ide18a0f9dc8', 'lib/mof/parser.y', 583
25
+ module_eval <<'..end lib/mof/parser.y modeval..idbe2b713bdc', 'lib/mof/parser.y', 566
26
26
 
27
27
  #
28
28
  # Initialize MOF::Parser
29
29
  # MOF::Parser.new options = {}
30
30
  #
31
31
  # options -> Hash of options
32
- # :debug -> bool
32
+ # :debug -> boolean
33
33
  # :includes -> array of include dirs
34
34
  # :style -> :cim or :wmi
35
35
  #
@@ -61,7 +61,7 @@ end
61
61
  options = { :namespace => "" }
62
62
  while argv.size > 0
63
63
  case opt = argv.shift
64
- when "-h":
64
+ when "-h"
65
65
  $stderr.puts "Ruby MOF compiler"
66
66
  $stderr.puts "#{name} [-h] [-d] [-I <dir>] [<moffiles>]"
67
67
  $stderr.puts "Compiles <moffile>"
@@ -75,10 +75,10 @@ end
75
75
  $stderr.puts "\t-q quiet"
76
76
  $stderr.puts "\t<moffiles> file(s) to read (else use $stdin)"
77
77
  exit 0
78
- when "-f": options[:force] = true
79
- when "-s": options[:style] = argv.shift.to_sym
80
- when "-d": options[:debug] = true
81
- when "-q": options[:quiet] = true
78
+ when "-f" then options[:force] = true
79
+ when "-s" then options[:style] = argv.shift.to_sym
80
+ when "-d" then options[:debug] = true
81
+ when "-q" then options[:quiet] = true
82
82
  when "-I"
83
83
  options[:includes] ||= []
84
84
  dirname = argv.shift
@@ -87,9 +87,9 @@ end
87
87
  dirname = File.dirname(dirname)
88
88
  end
89
89
  options[:includes] << Pathname.new(dirname)
90
- when "-n": options[:namespace] = argv.shift
91
- when "-o": options[:output] = argv.shift
92
- when /^-.+/:
90
+ when "-n" then options[:namespace] = argv.shift
91
+ when "-o" then options[:output] = argv.shift
92
+ when /^-.+/
93
93
  $stderr.puts "Undefined option #{opt}"
94
94
  else
95
95
  files << opt
@@ -101,7 +101,7 @@ end
101
101
  include Helper
102
102
  include Scanner
103
103
 
104
- ..end lib/mof/parser.y modeval..ide18a0f9dc8
104
+ ..end lib/mof/parser.y modeval..idbe2b713bdc
105
105
 
106
106
  ##### racc 1.4.5 generates ###
107
107
 
@@ -503,7 +503,7 @@ racc_token_table = {
503
503
  :DT_REAL64 => 42,
504
504
  :DT_CHAR16 => 43,
505
505
  :DT_STR => 44,
506
- :DT_BOOL => 45,
506
+ :DT_BOOLEAN => 45,
507
507
  :DT_DATETIME => 46,
508
508
  :positiveDecimalValue => 47,
509
509
  :stringValue => 48,
@@ -595,7 +595,7 @@ Racc_token_to_s_table = [
595
595
  'DT_REAL64',
596
596
  'DT_CHAR16',
597
597
  'DT_STR',
598
- 'DT_BOOL',
598
+ 'DT_BOOLEAN',
599
599
  'DT_DATETIME',
600
600
  'positiveDecimalValue',
601
601
  'stringValue',
@@ -797,41 +797,24 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 97
797
797
 
798
798
  # reduce 18 omitted
799
799
 
800
- module_eval <<'.,.,', 'lib/mof/parser.y', 129
800
+ module_eval <<'.,.,', 'lib/mof/parser.y', 112
801
801
  def _reduce_19( val, _values, result )
802
802
  qualifiers = val[0]
803
803
  features = val[6]
804
- if qualifiers and qualifiers.include?(:association, :bool)
805
- # FIXME: 'association' must be first
806
- # Context:
807
- #
808
- # The remaining qualifier list must not include
809
- # the ASSOCIATION qualifier again. If the
810
- # association has no super association, then at
811
- # least two references must be specified! The
812
- # ASSOCIATION qualifier may be omitted in
813
- # sub associations.
814
- result = CIM::Association.new(val[2],qualifiers,val[3],val[4],features)
815
- elsif qualifiers and qualifiers.include?(:indication, :bool)
816
- # FIXME: 'indication' must be first
817
- # FIXME: features must not include references
818
- result = CIM::Indication.new(val[2],qualifiers,val[3],val[4],features)
819
- else
820
- # FIXME: features must not include references
821
- result = CIM::Class.new(val[2],qualifiers,val[3],val[4],features)
822
- end
804
+ # FIXME: features must not include references
805
+ result = CIM::Class.new(val[2],qualifiers,val[3],val[4],features)
823
806
  result
824
807
  end
825
808
  .,.,
826
809
 
827
- module_eval <<'.,.,', 'lib/mof/parser.y', 134
810
+ module_eval <<'.,.,', 'lib/mof/parser.y', 117
828
811
  def _reduce_20( val, _values, result )
829
812
  result = []
830
813
  result
831
814
  end
832
815
  .,.,
833
816
 
834
- module_eval <<'.,.,', 'lib/mof/parser.y', 136
817
+ module_eval <<'.,.,', 'lib/mof/parser.y', 119
835
818
  def _reduce_21( val, _values, result )
836
819
  result = val[0] << val[1]
837
820
  result
@@ -846,14 +829,14 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 136
846
829
 
847
830
  # reduce 25 omitted
848
831
 
849
- module_eval <<'.,.,', 'lib/mof/parser.y', 149
832
+ module_eval <<'.,.,', 'lib/mof/parser.y', 132
850
833
  def _reduce_26( val, _values, result )
851
834
  result = CIM::QualifierSet.new val[0]
852
835
  result
853
836
  end
854
837
  .,.,
855
838
 
856
- module_eval <<'.,.,', 'lib/mof/parser.y', 155
839
+ module_eval <<'.,.,', 'lib/mof/parser.y', 138
857
840
  def _reduce_27( val, _values, result )
858
841
  result = val[2]
859
842
  result.unshift val[1] if val[1]
@@ -861,14 +844,14 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 155
861
844
  end
862
845
  .,.,
863
846
 
864
- module_eval <<'.,.,', 'lib/mof/parser.y', 160
847
+ module_eval <<'.,.,', 'lib/mof/parser.y', 143
865
848
  def _reduce_28( val, _values, result )
866
849
  result = []
867
850
  result
868
851
  end
869
852
  .,.,
870
853
 
871
- module_eval <<'.,.,', 'lib/mof/parser.y', 164
854
+ module_eval <<'.,.,', 'lib/mof/parser.y', 147
872
855
  def _reduce_29( val, _values, result )
873
856
  result = val[0]
874
857
  result << val[2] if val[2]
@@ -876,13 +859,13 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 164
876
859
  end
877
860
  .,.,
878
861
 
879
- module_eval <<'.,.,', 'lib/mof/parser.y', 186
862
+ module_eval <<'.,.,', 'lib/mof/parser.y', 169
880
863
  def _reduce_30( val, _values, result )
881
864
  # Get qualifier decl
882
865
  qualifier = case val[0]
883
- when CIM::Qualifier: val[0].definition
884
- when CIM::QualifierDeclaration: val[0]
885
- when String: @qualifiers[val[0].downcase]
866
+ when CIM::Qualifier then val[0].definition
867
+ when CIM::QualifierDeclaration then val[0]
868
+ when String then @qualifiers[val[0].downcase]
886
869
  else
887
870
  nil
888
871
  end
@@ -890,7 +873,7 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 186
890
873
  value = val[1]
891
874
  raise MOF::Helper::Error.new(@name,@lineno,@line,"#{value.inspect} does not match qualifier type '#{qualifier.type}'") unless qualifier.type.matches?(value)||@style == :wmi
892
875
  # Don't propagate a boolean 'false'
893
- if qualifier.type == :bool && value == false
876
+ if qualifier.type == :boolean && value == false
894
877
  result = nil
895
878
  else
896
879
  result = CIM::Qualifier.new(qualifier,value,val[2])
@@ -901,7 +884,7 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 186
901
884
 
902
885
  # reduce 31 omitted
903
886
 
904
- module_eval <<'.,.,', 'lib/mof/parser.y', 192
887
+ module_eval <<'.,.,', 'lib/mof/parser.y', 175
905
888
  def _reduce_32( val, _values, result )
906
889
  result = CIM::QualifierFlavors.new val[1]
907
890
  result
@@ -912,7 +895,7 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 192
912
895
 
913
896
  # reduce 34 omitted
914
897
 
915
- module_eval <<'.,.,', 'lib/mof/parser.y', 202
898
+ module_eval <<'.,.,', 'lib/mof/parser.y', 185
916
899
  def _reduce_35( val, _values, result )
917
900
  result = val[1]
918
901
  result
@@ -933,7 +916,7 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 202
933
916
 
934
917
  # reduce 42 omitted
935
918
 
936
- module_eval <<'.,.,', 'lib/mof/parser.y', 213
919
+ module_eval <<'.,.,', 'lib/mof/parser.y', 196
937
920
  def _reduce_43( val, _values, result )
938
921
  case val[0].to_sym
939
922
  when :amended, :toinstance
@@ -951,35 +934,35 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 213
951
934
 
952
935
  # reduce 47 omitted
953
936
 
954
- module_eval <<'.,.,', 'lib/mof/parser.y', 228
937
+ module_eval <<'.,.,', 'lib/mof/parser.y', 211
955
938
  def _reduce_48( val, _values, result )
956
939
  raise ParseError.new("Class name must be prefixed by '<schema>_'") unless val[0].include?("_") || @style == :wmi
957
940
  result
958
941
  end
959
942
  .,.,
960
943
 
961
- module_eval <<'.,.,', 'lib/mof/parser.y', 233
944
+ module_eval <<'.,.,', 'lib/mof/parser.y', 216
962
945
  def _reduce_49( val, _values, result )
963
946
  result = val[1]
964
947
  result
965
948
  end
966
949
  .,.,
967
950
 
968
- module_eval <<'.,.,', 'lib/mof/parser.y', 238
951
+ module_eval <<'.,.,', 'lib/mof/parser.y', 221
969
952
  def _reduce_50( val, _values, result )
970
953
  result = val[1]
971
954
  result
972
955
  end
973
956
  .,.,
974
957
 
975
- module_eval <<'.,.,', 'lib/mof/parser.y', 243
958
+ module_eval <<'.,.,', 'lib/mof/parser.y', 226
976
959
  def _reduce_51( val, _values, result )
977
960
  result = val[1]
978
961
  result
979
962
  end
980
963
  .,.,
981
964
 
982
- module_eval <<'.,.,', 'lib/mof/parser.y', 255
965
+ module_eval <<'.,.,', 'lib/mof/parser.y', 238
983
966
  def _reduce_52( val, _values, result )
984
967
  if val[3]
985
968
  type = CIM::Array.new val[3],val[1]
@@ -991,7 +974,7 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 255
991
974
  end
992
975
  .,.,
993
976
 
994
- module_eval <<'.,.,', 'lib/mof/parser.y', 263
977
+ module_eval <<'.,.,', 'lib/mof/parser.y', 246
995
978
  def _reduce_53( val, _values, result )
996
979
  if val[4]
997
980
  raise StyleError.new(@name,@lineno,@line,"Array not allowed in reference declaration") unless @style == :wmi
@@ -1001,7 +984,7 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 263
1001
984
  end
1002
985
  .,.,
1003
986
 
1004
- module_eval <<'.,.,', 'lib/mof/parser.y', 268
987
+ module_eval <<'.,.,', 'lib/mof/parser.y', 251
1005
988
  def _reduce_54( val, _values, result )
1006
989
  result = CIM::Method.new(val[1],val[2],val[0],val[4])
1007
990
  result
@@ -1010,7 +993,7 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 268
1010
993
 
1011
994
  # reduce 55 omitted
1012
995
 
1013
- module_eval <<'.,.,', 'lib/mof/parser.y', 276
996
+ module_eval <<'.,.,', 'lib/mof/parser.y', 259
1014
997
  def _reduce_56( val, _values, result )
1015
998
  # tmplprov.mof has 'string Property;'
1016
999
  raise StyleError.new(@name,@lineno,@line,"Invalid keyword '#{val[0]}' used for property name") unless @style == :wmi
@@ -1020,7 +1003,7 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 276
1020
1003
 
1021
1004
  # reduce 57 omitted
1022
1005
 
1023
- module_eval <<'.,.,', 'lib/mof/parser.y', 282
1006
+ module_eval <<'.,.,', 'lib/mof/parser.y', 265
1024
1007
  def _reduce_58( val, _values, result )
1025
1008
  result = "Indication"
1026
1009
  result
@@ -1057,14 +1040,14 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 282
1057
1040
 
1058
1041
  # reduce 73 omitted
1059
1042
 
1060
- module_eval <<'.,.,', 'lib/mof/parser.y', 305
1043
+ module_eval <<'.,.,', 'lib/mof/parser.y', 288
1061
1044
  def _reduce_74( val, _values, result )
1062
1045
  raise StyleError.new(@name,@lineno,@line,"'void' is not a valid datatype") unless @style == :wmi
1063
1046
  result
1064
1047
  end
1065
1048
  .,.,
1066
1049
 
1067
- module_eval <<'.,.,', 'lib/mof/parser.y', 313
1050
+ module_eval <<'.,.,', 'lib/mof/parser.y', 296
1068
1051
  def _reduce_75( val, _values, result )
1069
1052
  # WMI uses class names as data types (without REF ?!)
1070
1053
  raise StyleError.new(@name,@lineno,@line,"Expected 'ref' keyword after classname '#{val[0]}'") unless @style == :wmi
@@ -1073,7 +1056,7 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 313
1073
1056
  end
1074
1057
  .,.,
1075
1058
 
1076
- module_eval <<'.,.,', 'lib/mof/parser.y', 316
1059
+ module_eval <<'.,.,', 'lib/mof/parser.y', 299
1077
1060
  def _reduce_76( val, _values, result )
1078
1061
  result = CIM::ReferenceType.new val[0]
1079
1062
  result
@@ -1084,28 +1067,28 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 316
1084
1067
 
1085
1068
  # reduce 78 omitted
1086
1069
 
1087
- module_eval <<'.,.,', 'lib/mof/parser.y', 326
1070
+ module_eval <<'.,.,', 'lib/mof/parser.y', 309
1088
1071
  def _reduce_79( val, _values, result )
1089
1072
  result = val[1].unshift val[0]
1090
1073
  result
1091
1074
  end
1092
1075
  .,.,
1093
1076
 
1094
- module_eval <<'.,.,', 'lib/mof/parser.y', 331
1077
+ module_eval <<'.,.,', 'lib/mof/parser.y', 314
1095
1078
  def _reduce_80( val, _values, result )
1096
1079
  result = []
1097
1080
  result
1098
1081
  end
1099
1082
  .,.,
1100
1083
 
1101
- module_eval <<'.,.,', 'lib/mof/parser.y', 333
1084
+ module_eval <<'.,.,', 'lib/mof/parser.y', 316
1102
1085
  def _reduce_81( val, _values, result )
1103
1086
  result = val[0] << val[2]
1104
1087
  result
1105
1088
  end
1106
1089
  .,.,
1107
1090
 
1108
- module_eval <<'.,.,', 'lib/mof/parser.y', 344
1091
+ module_eval <<'.,.,', 'lib/mof/parser.y', 327
1109
1092
  def _reduce_82( val, _values, result )
1110
1093
  if val[3]
1111
1094
  type = CIM::Array.new val[3], val[1]
@@ -1129,21 +1112,21 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 344
1129
1112
 
1130
1113
  # reduce 88 omitted
1131
1114
 
1132
- module_eval <<'.,.,', 'lib/mof/parser.y', 364
1115
+ module_eval <<'.,.,', 'lib/mof/parser.y', 347
1133
1116
  def _reduce_89( val, _values, result )
1134
1117
  raise "Default parameter value not allowed in syntax style '{@style}'" unless @style == :wmi
1135
1118
  result
1136
1119
  end
1137
1120
  .,.,
1138
1121
 
1139
- module_eval <<'.,.,', 'lib/mof/parser.y', 369
1122
+ module_eval <<'.,.,', 'lib/mof/parser.y', 352
1140
1123
  def _reduce_90( val, _values, result )
1141
1124
  result = val[1]
1142
1125
  result
1143
1126
  end
1144
1127
  .,.,
1145
1128
 
1146
- module_eval <<'.,.,', 'lib/mof/parser.y', 374
1129
+ module_eval <<'.,.,', 'lib/mof/parser.y', 357
1147
1130
  def _reduce_91( val, _values, result )
1148
1131
  result = -1
1149
1132
  result
@@ -1156,7 +1139,7 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 374
1156
1139
 
1157
1140
  # reduce 94 omitted
1158
1141
 
1159
- module_eval <<'.,.,', 'lib/mof/parser.y', 385
1142
+ module_eval <<'.,.,', 'lib/mof/parser.y', 368
1160
1143
  def _reduce_95( val, _values, result )
1161
1144
  result = val[1]
1162
1145
  result
@@ -1169,7 +1152,7 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 385
1169
1152
 
1170
1153
  # reduce 98 omitted
1171
1154
 
1172
- module_eval <<'.,.,', 'lib/mof/parser.y', 396
1155
+ module_eval <<'.,.,', 'lib/mof/parser.y', 379
1173
1156
  def _reduce_99( val, _values, result )
1174
1157
  result = val[1]
1175
1158
  result
@@ -1178,14 +1161,14 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 396
1178
1161
 
1179
1162
  # reduce 100 omitted
1180
1163
 
1181
- module_eval <<'.,.,', 'lib/mof/parser.y', 402
1164
+ module_eval <<'.,.,', 'lib/mof/parser.y', 385
1182
1165
  def _reduce_101( val, _values, result )
1183
1166
  result = [ val[0] ]
1184
1167
  result
1185
1168
  end
1186
1169
  .,.,
1187
1170
 
1188
- module_eval <<'.,.,', 'lib/mof/parser.y', 404
1171
+ module_eval <<'.,.,', 'lib/mof/parser.y', 387
1189
1172
  def _reduce_102( val, _values, result )
1190
1173
  result = val[0] << val[2]
1191
1174
  result
@@ -1204,7 +1187,7 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 404
1204
1187
 
1205
1188
  # reduce 108 omitted
1206
1189
 
1207
- module_eval <<'.,.,', 'lib/mof/parser.y', 415
1190
+ module_eval <<'.,.,', 'lib/mof/parser.y', 398
1208
1191
  def _reduce_109( val, _values, result )
1209
1192
  raise "Instance as property value not allowed in syntax style '{@style}'" unless @style == :wmi
1210
1193
  result
@@ -1223,7 +1206,7 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 415
1223
1206
 
1224
1207
  # reduce 115 omitted
1225
1208
 
1226
- module_eval <<'.,.,', 'lib/mof/parser.y', 429
1209
+ module_eval <<'.,.,', 'lib/mof/parser.y', 412
1227
1210
  def _reduce_116( val, _values, result )
1228
1211
  result = val[0] + val[1]
1229
1212
  result
@@ -1256,7 +1239,7 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 429
1256
1239
 
1257
1240
  # reduce 129 omitted
1258
1241
 
1259
- module_eval <<'.,.,', 'lib/mof/parser.y', 484
1242
+ module_eval <<'.,.,', 'lib/mof/parser.y', 467
1260
1243
  def _reduce_130( val, _values, result )
1261
1244
  result = CIM::QualifierDeclaration.new( val[1], val[2][0], val[2][1], val[3], val[4])
1262
1245
  result
@@ -1275,7 +1258,7 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 484
1275
1258
 
1276
1259
  # reduce 136 omitted
1277
1260
 
1278
- module_eval <<'.,.,', 'lib/mof/parser.y', 504
1261
+ module_eval <<'.,.,', 'lib/mof/parser.y', 487
1279
1262
  def _reduce_137( val, _values, result )
1280
1263
  type = val[2].nil? ? val[1] : CIM::Array.new(val[2],val[1])
1281
1264
  result = [ type, val[3] ]
@@ -1283,21 +1266,21 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 504
1283
1266
  end
1284
1267
  .,.,
1285
1268
 
1286
- module_eval <<'.,.,', 'lib/mof/parser.y', 509
1269
+ module_eval <<'.,.,', 'lib/mof/parser.y', 492
1287
1270
  def _reduce_138( val, _values, result )
1288
1271
  result = CIM::QualifierScopes.new(val[3])
1289
1272
  result
1290
1273
  end
1291
1274
  .,.,
1292
1275
 
1293
- module_eval <<'.,.,', 'lib/mof/parser.y', 514
1276
+ module_eval <<'.,.,', 'lib/mof/parser.y', 497
1294
1277
  def _reduce_139( val, _values, result )
1295
1278
  result = [ val[0] ]
1296
1279
  result
1297
1280
  end
1298
1281
  .,.,
1299
1282
 
1300
- module_eval <<'.,.,', 'lib/mof/parser.y', 516
1283
+ module_eval <<'.,.,', 'lib/mof/parser.y', 499
1301
1284
  def _reduce_140( val, _values, result )
1302
1285
  result = val[0] << val[2]
1303
1286
  result
@@ -1324,21 +1307,21 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 516
1324
1307
 
1325
1308
  # reduce 150 omitted
1326
1309
 
1327
- module_eval <<'.,.,', 'lib/mof/parser.y', 534
1310
+ module_eval <<'.,.,', 'lib/mof/parser.y', 517
1328
1311
  def _reduce_151( val, _values, result )
1329
1312
  result = CIM::QualifierFlavors.new val[3]
1330
1313
  result
1331
1314
  end
1332
1315
  .,.,
1333
1316
 
1334
- module_eval <<'.,.,', 'lib/mof/parser.y', 539
1317
+ module_eval <<'.,.,', 'lib/mof/parser.y', 522
1335
1318
  def _reduce_152( val, _values, result )
1336
1319
  result = [ val[0] ]
1337
1320
  result
1338
1321
  end
1339
1322
  .,.,
1340
1323
 
1341
- module_eval <<'.,.,', 'lib/mof/parser.y', 541
1324
+ module_eval <<'.,.,', 'lib/mof/parser.y', 524
1342
1325
  def _reduce_153( val, _values, result )
1343
1326
  result = val[0] << val[2]
1344
1327
  result
@@ -1355,7 +1338,7 @@ module_eval <<'.,.,', 'lib/mof/parser.y', 541
1355
1338
 
1356
1339
  # reduce 158 omitted
1357
1340
 
1358
- module_eval <<'.,.,', 'lib/mof/parser.y', 565
1341
+ module_eval <<'.,.,', 'lib/mof/parser.y', 548
1359
1342
  def _reduce_159( val, _values, result )
1360
1343
  raise "Instance property '#{val[1]} must have a value" unless @style == :wmi
1361
1344
  result
@@ -18,7 +18,7 @@ class MOF::Parser
18
18
  DT_VOID
19
19
  DT_UINT8 DT_SINT8 DT_UINT16 DT_SINT16 DT_UINT32 DT_SINT32
20
20
  DT_UINT64 DT_SINT64 DT_REAL32 DT_REAL64 DT_CHAR16 DT_STR
21
- DT_BOOL DT_DATETIME
21
+ DT_BOOLEAN DT_DATETIME
22
22
  positiveDecimalValue
23
23
  stringValue
24
24
  realValue
@@ -108,25 +108,8 @@ rule
108
108
  : qualifierList_opt CLASS className alias_opt superClass_opt "{" classFeatures "}" ";"
109
109
  { qualifiers = val[0]
110
110
  features = val[6]
111
- if qualifiers and qualifiers.include?(:association, :bool)
112
- # FIXME: 'association' must be first
113
- # Context:
114
- #
115
- # The remaining qualifier list must not include
116
- # the ASSOCIATION qualifier again. If the
117
- # association has no super association, then at
118
- # least two references must be specified! The
119
- # ASSOCIATION qualifier may be omitted in
120
- # sub associations.
121
- result = CIM::Association.new(val[2],qualifiers,val[3],val[4],features)
122
- elsif qualifiers and qualifiers.include?(:indication, :bool)
123
- # FIXME: 'indication' must be first
124
- # FIXME: features must not include references
125
- result = CIM::Indication.new(val[2],qualifiers,val[3],val[4],features)
126
- else
127
- # FIXME: features must not include references
128
- result = CIM::Class.new(val[2],qualifiers,val[3],val[4],features)
129
- end
111
+ # FIXME: features must not include references
112
+ result = CIM::Class.new(val[2],qualifiers,val[3],val[4],features)
130
113
  }
131
114
  ;
132
115
 
@@ -169,9 +152,9 @@ rule
169
152
  : qualifierName qualifierParameter_opt flavor_opt
170
153
  { # Get qualifier decl
171
154
  qualifier = case val[0]
172
- when CIM::Qualifier: val[0].definition
173
- when CIM::QualifierDeclaration: val[0]
174
- when String: @qualifiers[val[0].downcase]
155
+ when CIM::Qualifier then val[0].definition
156
+ when CIM::QualifierDeclaration then val[0]
157
+ when String then @qualifiers[val[0].downcase]
175
158
  else
176
159
  nil
177
160
  end
@@ -179,7 +162,7 @@ rule
179
162
  value = val[1]
180
163
  raise MOF::Helper::Error.new(@name,@lineno,@line,"#{value.inspect} does not match qualifier type '#{qualifier.type}'") unless qualifier.type.matches?(value)||@style == :wmi
181
164
  # Don't propagate a boolean 'false'
182
- if qualifier.type == :bool && value == false
165
+ if qualifier.type == :boolean && value == false
183
166
  result = nil
184
167
  else
185
168
  result = CIM::Qualifier.new(qualifier,value,val[2])
@@ -300,7 +283,7 @@ rule
300
283
  | DT_REAL64
301
284
  | DT_CHAR16
302
285
  | DT_STR
303
- | DT_BOOL
286
+ | DT_BOOLEAN
304
287
  | DT_DATETIME
305
288
  | DT_VOID
306
289
  { raise StyleError.new(@name,@lineno,@line,"'void' is not a valid datatype") unless @style == :wmi }
@@ -586,7 +569,7 @@ require File.join(File.dirname(__FILE__), 'helper')
586
569
  # MOF::Parser.new options = {}
587
570
  #
588
571
  # options -> Hash of options
589
- # :debug -> bool
572
+ # :debug -> boolean
590
573
  # :includes -> array of include dirs
591
574
  # :style -> :cim or :wmi
592
575
  #
@@ -618,7 +601,7 @@ end
618
601
  options = { :namespace => "" }
619
602
  while argv.size > 0
620
603
  case opt = argv.shift
621
- when "-h":
604
+ when "-h"
622
605
  $stderr.puts "Ruby MOF compiler"
623
606
  $stderr.puts "#{name} [-h] [-d] [-I <dir>] [<moffiles>]"
624
607
  $stderr.puts "Compiles <moffile>"
@@ -632,10 +615,10 @@ end
632
615
  $stderr.puts "\t-q quiet"
633
616
  $stderr.puts "\t<moffiles> file(s) to read (else use $stdin)"
634
617
  exit 0
635
- when "-f": options[:force] = true
636
- when "-s": options[:style] = argv.shift.to_sym
637
- when "-d": options[:debug] = true
638
- when "-q": options[:quiet] = true
618
+ when "-f" then options[:force] = true
619
+ when "-s" then options[:style] = argv.shift.to_sym
620
+ when "-d" then options[:debug] = true
621
+ when "-q" then options[:quiet] = true
639
622
  when "-I"
640
623
  options[:includes] ||= []
641
624
  dirname = argv.shift
@@ -644,9 +627,9 @@ end
644
627
  dirname = File.dirname(dirname)
645
628
  end
646
629
  options[:includes] << Pathname.new(dirname)
647
- when "-n": options[:namespace] = argv.shift
648
- when "-o": options[:output] = argv.shift
649
- when /^-.+/:
630
+ when "-n" then options[:namespace] = argv.shift
631
+ when "-o" then options[:output] = argv.shift
632
+ when /^-.+/
650
633
  $stderr.puts "Undefined option #{opt}"
651
634
  else
652
635
  files << opt
@@ -118,49 +118,49 @@ module Scanner
118
118
 
119
119
  when m = scanner.scan(%r{\w+})
120
120
  case m.downcase
121
- when "amended": @q.push [:AMENDED, m]
122
- when "any": @q.push [:ANY, m]
123
- when "as": @q.push [:AS, nil]
124
- when "association": @q.push [:ASSOCIATION, m]
125
- when "class": @q.push( [:CLASS, m] )
126
- when "disableoverride": @q.push [:DISABLEOVERRIDE, m]
127
- when "void": @q.push [:DT_VOID, CIM::Type.new(:void)]
128
- when "boolean": @q.push [:DT_BOOL, CIM::Type.new(:bool)]
129
- when "char16": @q.push [:DT_CHAR16, CIM::Type.new(m)]
130
- when "datetime": @q.push [:DT_DATETIME, CIM::Type.new(m)]
131
- when "real32": @q.push [:DT_REAL32, CIM::Type.new(m)]
132
- when "real64": @q.push [:DT_REAL64, CIM::Type.new(m)]
133
- when "sint16": @q.push [:DT_SINT16, CIM::Type.new(m)]
134
- when "sint32": @q.push [:DT_SINT32, CIM::Type.new(m)]
135
- when "sint64": @q.push [:DT_SINT64, CIM::Type.new(m)]
136
- when "sint8": @q.push [:DT_SINT8, CIM::Type.new(m)]
137
- when "string": @q.push [:DT_STR, CIM::Type.new(m)]
138
- when "uint16": @q.push [:DT_UINT16, CIM::Type.new(m)]
139
- when "uint32": @q.push [:DT_UINT32, CIM::Type.new(m)]
140
- when "uint64": @q.push [:DT_UINT64, CIM::Type.new(m)]
141
- when "uint8": @q.push [:DT_UINT8, CIM::Type.new(m)]
142
- when "enableoverride": @q.push [:ENABLEOVERRIDE, m]
143
- when "false": @q.push [:booleanValue, false]
144
- when "flavor": @q.push [:FLAVOR, nil]
145
- when "include": @q.push [:INCLUDE, nil]
146
- when "indication": @q.push [:INDICATION, m]
147
- when "instance": @q.push [:INSTANCE, m]
148
- when "method": @q.push [:METHOD, m]
149
- when "null": @q.push [:nullValue, CIM::Variant.new(:null,nil)]
150
- when "of": @q.push [:OF, nil]
151
- when "parameter": @q.push [:PARAMETER, m]
152
- when "pragma": @q.push [:PRAGMA, nil]
153
- when "property": @q.push [:PROPERTY, m]
154
- when "qualifier": @q.push [:QUALIFIER, m]
155
- when "ref": @q.push [:REF, nil]
156
- when "reference": @q.push [:REFERENCE, m]
157
- when "restricted": @q.push [:RESTRICTED, m]
158
- when "schema": @q.push [:SCHEMA, m]
159
- when "scope": @q.push [:SCOPE, nil]
160
- when "toinstance": @q.push [:TOINSTANCE, m]
161
- when "tosubclass": @q.push [:TOSUBCLASS, m]
162
- when "translatable": @q.push [:TRANSLATABLE, m]
163
- when "true": @q.push [:booleanValue, true]
121
+ when "amended" then @q.push [:AMENDED, m]
122
+ when "any" then @q.push [:ANY, m]
123
+ when "as" then @q.push [:AS, nil]
124
+ when "association" then @q.push [:ASSOCIATION, m]
125
+ when "class" then @q.push( [:CLASS, m] )
126
+ when "disableoverride" then @q.push [:DISABLEOVERRIDE, m]
127
+ when "void" then @q.push [:DT_VOID, CIM::Type.new(:void)]
128
+ when "boolean" then @q.push [:DT_BOOLEAN, CIM::Type.new(:boolean)]
129
+ when "char16" then @q.push [:DT_CHAR16, CIM::Type.new(m)]
130
+ when "datetime" then @q.push [:DT_DATETIME, CIM::Type.new(m)]
131
+ when "real32" then @q.push [:DT_REAL32, CIM::Type.new(m)]
132
+ when "real64" then @q.push [:DT_REAL64, CIM::Type.new(m)]
133
+ when "sint16" then @q.push [:DT_SINT16, CIM::Type.new(m)]
134
+ when "sint32" then @q.push [:DT_SINT32, CIM::Type.new(m)]
135
+ when "sint64" then @q.push [:DT_SINT64, CIM::Type.new(m)]
136
+ when "sint8" then @q.push [:DT_SINT8, CIM::Type.new(m)]
137
+ when "string" then @q.push [:DT_STR, CIM::Type.new(m)]
138
+ when "uint16" then @q.push [:DT_UINT16, CIM::Type.new(m)]
139
+ when "uint32" then @q.push [:DT_UINT32, CIM::Type.new(m)]
140
+ when "uint64" then @q.push [:DT_UINT64, CIM::Type.new(m)]
141
+ when "uint8" then @q.push [:DT_UINT8, CIM::Type.new(m)]
142
+ when "enableoverride" then @q.push [:ENABLEOVERRIDE, m]
143
+ when "false" then @q.push [:booleanValue, false]
144
+ when "flavor" then @q.push [:FLAVOR, nil]
145
+ when "include" then @q.push [:INCLUDE, nil]
146
+ when "indication" then @q.push [:INDICATION, m]
147
+ when "instance" then @q.push [:INSTANCE, m]
148
+ when "method" then @q.push [:METHOD, m]
149
+ when "null" then @q.push [:nullValue, CIM::Variant.new(:null,nil)]
150
+ when "of" then @q.push [:OF, nil]
151
+ when "parameter" then @q.push [:PARAMETER, m]
152
+ when "pragma" then @q.push [:PRAGMA, nil]
153
+ when "property" then @q.push [:PROPERTY, m]
154
+ when "qualifier" then @q.push [:QUALIFIER, m]
155
+ when "ref" then @q.push [:REF, nil]
156
+ when "reference" then @q.push [:REFERENCE, m]
157
+ when "restricted" then @q.push [:RESTRICTED, m]
158
+ when "schema" then @q.push [:SCHEMA, m]
159
+ when "scope" then @q.push [:SCOPE, nil]
160
+ when "toinstance" then @q.push [:TOINSTANCE, m]
161
+ when "tosubclass" then @q.push [:TOSUBCLASS, m]
162
+ when "translatable" then @q.push [:TRANSLATABLE, m]
163
+ when "true" then @q.push [:booleanValue, true]
164
164
  else
165
165
  @q.push( [:IDENTIFIER, m] )
166
166
  end # case m.downcase
@@ -0,0 +1,3 @@
1
+ module MOF
2
+ VERSION = '1.2.0'
3
+ end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- require "mof"
3
+ require "mof/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "mof"
@@ -18,7 +18,10 @@ See http://www.dmtf.org/education/mof}
18
18
  s.rubyforge_project = "mof"
19
19
 
20
20
  # CIM metamodel
21
- s.add_dependency("cim", ["~> 0.5"])
21
+ s.add_dependency("cim", ["~> 1.2"])
22
+
23
+ s.add_development_dependency('rake')
24
+ s.add_development_dependency('bundler')
22
25
 
23
26
  s.files = `git ls-files`.split("\n") << "lib/mof/parser.rb"
24
27
  s.files.reject! { |fn| fn == '.gitignore' }
@@ -3,5 +3,6 @@ rule '.rb' => '.y' do |t|
3
3
  end
4
4
 
5
5
  task :test => [:racc]
6
+ task :build => [:racc]
6
7
 
7
8
  task :racc => ["lib/mof/parser.rb"]
@@ -1,7 +1,12 @@
1
1
  qualifier Description : string,
2
2
  Scope(class);
3
+ qualifier Indication : boolean,
4
+ Scope(class);
5
+ qualifier Association : boolean,
6
+ Scope(class);
3
7
 
4
- [ Description("This is a class with a Description qualifier") ]
8
+ [ Association, Indication, Description("This is a class with a Description qualifier") ]
5
9
  class MOF_Test : Parent_Class
6
10
  {
11
+ CIM_OperatingSystem REF GroupComponent;
7
12
  };
@@ -2,10 +2,10 @@ $d = File.expand_path(File.dirname(__FILE__))
2
2
  require "test/unit"
3
3
  require File.join($d,'..','lib','mof')
4
4
 
5
- class TestQualifiers < Test::Unit::TestCase
5
+ class TestAssociationQualifiers < Test::Unit::TestCase
6
6
 
7
7
  def setup
8
- @moffiles, @options = MOF::Parser.argv_handler "test_qualifier", ["association_qualifier.mof"]
8
+ @moffiles, @options = MOF::Parser.argv_handler "test_association_qualifier", ["association_qualifier.mof"]
9
9
  @options[:style] ||= :cim
10
10
  @options[:includes] ||= [ $d, File.join($d,"mof")]
11
11
 
@@ -24,7 +24,7 @@ class TestQualifiers < Test::Unit::TestCase
24
24
  assert_equal 1, res.qualifiers.size
25
25
  q = res.qualifiers.shift
26
26
  assert q.is_a? CIM::QualifierDeclaration
27
- assert q.type == :bool
27
+ assert q.type == :boolean
28
28
  assert q.default == false
29
29
  # has one qualifier scopes
30
30
  assert_equal 1, q.scopes.size
@@ -0,0 +1,29 @@
1
+ $d = File.expand_path(File.dirname(__FILE__))
2
+ require "test/unit"
3
+ require File.join($d,'..','lib','mof')
4
+
5
+ class TestClassQualifiers < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @moffiles, @options = MOF::Parser.argv_handler "test_class_qualifier", ["class_qualifiers.mof"]
9
+ @options[:style] ||= :cim
10
+ @options[:includes] ||= [ $d, File.join($d,"mof")]
11
+
12
+ @parser = MOF::Parser.new @options
13
+ end
14
+
15
+ def test_parse
16
+ result = @parser.parse @moffiles
17
+ assert result
18
+ # parsed one file
19
+ assert_equal 1, result.size
20
+
21
+ name,res = result.shift
22
+ assert !res.qualifiers.empty?
23
+ # parsed three qualifier
24
+ assert_equal 3, res.qualifiers.size
25
+ assert res.qualifiers.include? :association
26
+ assert res.qualifiers.include? :indication
27
+ assert res.qualifiers.include? :description
28
+ end
29
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mof
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
- - 0
8
- - 3
7
+ - 1
9
8
  - 2
10
- version: 0.3.2
9
+ - 0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Klaus K\xC3\xA4mpf"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-29 00:00:00 +02:00
18
+ date: 2012-05-03 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,13 +26,41 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 1
29
+ hash: 11
30
30
  segments:
31
- - 0
32
- - 5
33
- version: "0.5"
31
+ - 1
32
+ - 2
33
+ version: "1.2"
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ type: :development
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: bundler
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ type: :development
63
+ version_requirements: *id003
36
64
  description: |-
37
65
  The Managed Object Format (MOF) language used to
38
66
  describe classes and instances of the Common Information Model (CIM).
@@ -45,7 +73,6 @@ extensions: []
45
73
 
46
74
  extra_rdoc_files:
47
75
  - README.rdoc
48
- - README.rdoc~
49
76
  - LICENSE
50
77
  files:
51
78
  - Gemfile
@@ -61,6 +88,7 @@ files:
61
88
  - lib/mof/parser.y
62
89
  - lib/mof/result.rb
63
90
  - lib/mof/scanner.rb
91
+ - lib/mof/version.rb
64
92
  - mof.gemspec
65
93
  - parser/doc/mof.bnf
66
94
  - tasks/clean.rake
@@ -77,10 +105,10 @@ files:
77
105
  - test/mof/simple.mof
78
106
  - test/test_array_initializer.rb
79
107
  - test/test_association_qualifier.rb
108
+ - test/test_class_qualifiers.rb
80
109
  - test/test_loading.rb
81
110
  - test/test_qualifier.rb
82
111
  - lib/mof/parser.rb
83
- - README.rdoc~
84
112
  has_rdoc: true
85
113
  homepage: https://github.com/kkaempf/mof
86
114
  licenses: []
@@ -111,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
139
  requirements: []
112
140
 
113
141
  rubyforge_project: mof
114
- rubygems_version: 1.5.2
142
+ rubygems_version: 1.5.0
115
143
  signing_key:
116
144
  specification_version: 3
117
145
  summary: A pure Ruby parser for MOF (Managed Object Format) files
@@ -126,5 +154,6 @@ test_files:
126
154
  - test/mof/simple.mof
127
155
  - test/test_array_initializer.rb
128
156
  - test/test_association_qualifier.rb
157
+ - test/test_class_qualifiers.rb
129
158
  - test/test_loading.rb
130
159
  - test/test_qualifier.rb
@@ -1,57 +0,0 @@
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