cim 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/History.txt +19 -0
- data/LICENSE +58 -0
- data/README.rdoc +24 -8
- data/Rakefile +3 -23
- data/cim.gemspec +27 -0
- data/lib/cim.rb +54 -23
- data/lib/cim/association.rb +27 -1
- data/lib/cim/class.rb +51 -8
- data/lib/cim/class_feature.rb +40 -11
- data/lib/cim/indication.rb +14 -0
- data/lib/cim/instance.rb +18 -2
- data/lib/cim/method.rb +28 -1
- data/lib/cim/named_element.rb +55 -7
- data/lib/cim/property.rb +27 -5
- data/lib/cim/qualifier.rb +47 -2
- data/lib/cim/qualifier_declaration.rb +59 -13
- data/lib/cim/qualifier_flavors.rb +84 -10
- data/lib/cim/qualifier_scopes.rb +87 -0
- data/lib/cim/qualifier_set.rb +73 -0
- data/lib/cim/reference.rb +18 -0
- data/lib/cim/type.rb +82 -1
- data/lib/cim/variant.rb +39 -0
- data/tasks/clean.rake +9 -0
- data/tasks/doc.rake +14 -0
- data/tasks/test.rake +6 -0
- data/test/test_method.rb +2 -1
- data/test/test_qualifier_set.rb +39 -0
- metadata +37 -67
- data/Manifest.txt +0 -27
- data/lib/cim/qualifier_scope.rb +0 -37
- data/lib/cim/qualifiers.rb +0 -53
data/Gemfile
ADDED
data/History.txt
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
=== 0.5.0 2011-09-29
|
2
|
+
|
3
|
+
* Clean up Rakefile, support Bundler
|
4
|
+
* Add QualifierSet[] access function
|
5
|
+
* Make check functions like key?, etc. public
|
6
|
+
|
7
|
+
=== 0.4.1 2010-10-14
|
8
|
+
|
9
|
+
* More tests
|
10
|
+
* Refactor Qualifiers to QualifierSet, QualifierSet includes Qualifiers
|
11
|
+
|
12
|
+
=== 0.3.1 2010-10-05
|
13
|
+
|
14
|
+
* Extend API for mof
|
15
|
+
|
16
|
+
=== 0.3.0 2010-10-04
|
17
|
+
|
18
|
+
* Refactoring for mof
|
19
|
+
|
1
20
|
=== 0.2.7 2010-10-03
|
2
21
|
|
3
22
|
* 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
|
+
|
data/README.rdoc
CHANGED
@@ -1,18 +1,25 @@
|
|
1
|
-
=
|
1
|
+
= About Cim
|
2
2
|
|
3
3
|
* http://github.com/kkaempf/cim
|
4
4
|
|
5
|
+
* http://rubygems.org/gems/cim
|
6
|
+
|
7
|
+
* http://rdoc.info/github/kkaempf/cim/master/frames
|
8
|
+
|
9
|
+
* https://build.opensuse.org/package/show?package=rubygem-cim&project=devel:languages:ruby:extensions
|
10
|
+
|
5
11
|
== DESCRIPTION:
|
6
12
|
|
7
|
-
|
13
|
+
Cim is a pure-Ruby implementation of the CIM meta model.
|
14
|
+
|
15
|
+
Instances of Cim classes are used to define a CIM schema, often
|
16
|
+
represented as a +.mof+ file.
|
8
17
|
|
9
|
-
|
10
|
-
|
11
|
-
See http://www.dmtf.org/standards/cim and http://www.dmtf.org/education/mof
|
12
|
-
for details
|
18
|
+
See http://www.dmtf.org/standards/cim and http://www.dmtf.org/education/mof
|
19
|
+
for details
|
13
20
|
|
14
|
-
|
15
|
-
|
21
|
+
https://rubygems.org/gems/mof is a parser for .mof files and the
|
22
|
+
primary consumer of the cim gem.
|
16
23
|
|
17
24
|
== SYNOPSIS:
|
18
25
|
|
@@ -27,6 +34,15 @@
|
|
27
34
|
* sudo gem install cim
|
28
35
|
(resp. rpm -Uhv rubygem-cim)
|
29
36
|
|
37
|
+
== DEVELOPERS:
|
38
|
+
|
39
|
+
After checking out the source, run:
|
40
|
+
|
41
|
+
$ rake newb
|
42
|
+
|
43
|
+
This task will install any missing dependencies, run the tests/specs,
|
44
|
+
and generate the RDoc.
|
45
|
+
|
30
46
|
== LICENSE:
|
31
47
|
|
32
48
|
(The Ruby License)
|
data/Rakefile
CHANGED
@@ -1,26 +1,6 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
require 'hoe'
|
4
|
-
require 'fileutils'
|
5
|
-
require './lib/cim'
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
6
3
|
|
7
|
-
|
8
|
-
# Hoe.plugin :website
|
9
|
-
# Hoe.plugin :cucumberfeatures
|
4
|
+
task :default => [:test]
|
10
5
|
|
11
|
-
# Generate all the Rake tasks
|
12
|
-
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
-
$hoe = Hoe.spec 'cim' do
|
14
|
-
self.developer 'Klaus Kämpf', 'kkaempf@suse.de'
|
15
|
-
|
16
|
-
self.rubyforge_name = self.name # TODO this is default value
|
17
|
-
# self.extra_deps = [['activesupport','>= 2.0.2']]
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
require 'newgem/tasks'
|
22
6
|
Dir['tasks/**/*.rake'].each { |t| load t }
|
23
|
-
|
24
|
-
# TODO - want other tests/tasks run by default? Add them to the list
|
25
|
-
# remove_task :default
|
26
|
-
# task :default => [:spec, :features]
|
data/cim.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "cim"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "cim"
|
7
|
+
s.version = CIM::VERSION
|
8
|
+
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.authors = ["Klaus Kämpf"]
|
11
|
+
s.email = ["kkaempf@suse.de"]
|
12
|
+
s.homepage = "https://github.com/kkaempf/cim"
|
13
|
+
s.summary = %q{A pure-Ruby implementation of the CIM meta model}
|
14
|
+
s.description = %q{Instances of Cim classes are used to define a CIM
|
15
|
+
schema, often represented as a .mof file. See
|
16
|
+
http://www.dmtf.org/standards/cim and
|
17
|
+
http://www.dmtf.org/education/mof for details}
|
18
|
+
|
19
|
+
s.rubyforge_project = "cim"
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.files.reject! { |fn| fn == '.gitignore' }
|
23
|
+
s.extra_rdoc_files = Dir['README*', 'TODO*', 'CHANGELOG*', 'LICENSE']
|
24
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
26
|
+
s.require_paths = ["lib"]
|
27
|
+
end
|
data/lib/cim.rb
CHANGED
@@ -1,29 +1,60 @@
|
|
1
|
-
# cim
|
2
|
-
# A pure-Ruby implementation of the CIM metamodel
|
3
1
|
#
|
4
|
-
#
|
2
|
+
# cim.rb
|
3
|
+
#
|
4
|
+
# A pure-Ruby implementation of the CIM meta schema.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2010 Klaus Kämpf <kkaempf@suse.de>
|
7
|
+
#
|
8
|
+
# Licensed under the Ruby license
|
5
9
|
#
|
6
|
-
|
7
10
|
$:.unshift(File.dirname(__FILE__)) unless
|
8
11
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
13
|
+
#
|
14
|
+
# The CIM Ruby gem is an implementation of the Common Information Model (CIM) meta schema[1]
|
15
|
+
#
|
16
|
+
# = About
|
17
|
+
#
|
18
|
+
# The Common Information Model provides a common definition of management
|
19
|
+
# information for systems, networks, applications and services.[2]
|
20
|
+
#
|
21
|
+
# The CIM meta schema is used to describe elements of the CIM model, like
|
22
|
+
# types (CIM::Type), properties (CIM::Property), methods (CIM::Method)
|
23
|
+
# and classes (CIM::Class).
|
24
|
+
#
|
25
|
+
# Elements of the CIM model can be defined as text files using the Managed
|
26
|
+
# Object Format (MOF)[3] or by inspection on a running CIM Object Manager (CIMOM)[4]
|
27
|
+
#
|
28
|
+
# Primary users of the CIM gem are the MOF gem [5], a parser for MOF files,
|
29
|
+
# and ruby-sfcc[6], a Ruby CIM client api.
|
30
|
+
#
|
31
|
+
# = Usage
|
32
|
+
# require 'cim'
|
33
|
+
#
|
34
|
+
# = Links
|
35
|
+
# 1. http://www.wbemsolutions.com/tutorials/CIM/metaschema.html
|
36
|
+
# 2. http://www.dmtf.org/standards/cim
|
37
|
+
# 3. http://www.wbemsolutions.com/tutorials/CIM/cim-mof.html
|
38
|
+
# 4. http://www.wbemsolutions.com/tutorials/CIM/glossary.html#c-gloss
|
39
|
+
# 5. http://github.com/kkaempf/mof
|
40
|
+
# 6. http://github.com/dmacvicar/ruby-sfcc
|
41
|
+
#
|
42
|
+
|
43
|
+
module CIM
|
44
|
+
VERSION = '0.5.0'
|
45
|
+
require 'cim/type'
|
46
|
+
require 'cim/variant'
|
47
|
+
require 'cim/qualifier_flavors'
|
48
|
+
require 'cim/qualifier_scopes'
|
49
|
+
require 'cim/named_element'
|
50
|
+
require 'cim/qualifier_declaration'
|
51
|
+
require 'cim/qualifier'
|
52
|
+
require 'cim/qualifier_set'
|
53
|
+
require 'cim/class_feature'
|
54
|
+
require 'cim/property'
|
55
|
+
require 'cim/reference'
|
56
|
+
require 'cim/method'
|
57
|
+
require 'cim/class'
|
58
|
+
require 'cim/association'
|
59
|
+
require 'cim/indication'
|
29
60
|
end
|
data/lib/cim/association.rb
CHANGED
@@ -1,10 +1,36 @@
|
|
1
|
+
#
|
2
|
+
# cim/association.rb - class CIM::Association
|
3
|
+
#
|
4
|
+
# A pure-Ruby implementation of the CIM meta model.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2010 Klaus Kämpf <kkaempf@suse.de>
|
7
|
+
#
|
8
|
+
# Licensed under the Ruby license
|
9
|
+
#
|
1
10
|
module CIM
|
11
|
+
#
|
12
|
+
# An Association is a Class with the :association Qualifier
|
13
|
+
#
|
14
|
+
# Only such a class can have Reference properties
|
15
|
+
#
|
2
16
|
class Association < Class
|
3
|
-
|
17
|
+
#
|
18
|
+
# Create Association class
|
19
|
+
#
|
20
|
+
# call-seq:
|
21
|
+
# Association.new("AssocClass")
|
22
|
+
# Association.new("AssocClass", qualifiers)
|
23
|
+
# Association.new("AssocClass", qualifiers, "assoc_class")
|
24
|
+
# Association.new("AssocClass", qualifiers, "assoc_class", "SuperClass")
|
25
|
+
# Association.new("AssocClass", qualifiers, "assoc_class", "SuperClass", features)
|
26
|
+
#
|
27
|
+
def initialize name, qualifiers = nil, alias_name = nil, superclass = nil, features = nil
|
4
28
|
raise "Association needs 'association' qualifier" unless qualifiers.include?(:association, :bool)
|
5
29
|
super name, qualifiers, alias_name, superclass, features
|
6
30
|
end
|
31
|
+
#
|
7
32
|
# true if class has associations (association provider)
|
33
|
+
#
|
8
34
|
def association?
|
9
35
|
true
|
10
36
|
end
|
data/lib/cim/class.rb
CHANGED
@@ -1,25 +1,61 @@
|
|
1
|
+
#
|
2
|
+
# cim/class.rb - class CIM::Class
|
3
|
+
#
|
4
|
+
# A pure-Ruby implementation of the CIM meta model.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2010 Klaus Kämpf <kkaempf@suse.de>
|
7
|
+
#
|
8
|
+
# Licensed under the Ruby license
|
9
|
+
#
|
1
10
|
module CIM
|
2
11
|
require File.join(File.dirname(__FILE__),"qualifier")
|
12
|
+
#
|
13
|
+
# A Class is a central element in the object-oriented CIM schema
|
14
|
+
#
|
15
|
+
# Classes can be derived from other classes, creating a hierachical model.
|
16
|
+
#
|
17
|
+
# Classes have qualifiers to describe the class characteristics
|
18
|
+
# and contain features (properties or methods).
|
19
|
+
#
|
3
20
|
class Class < CIM::NamedElement
|
4
|
-
attr_reader :alias_name, :
|
5
|
-
|
6
|
-
|
7
|
-
|
21
|
+
attr_reader :alias_name, :superclass, :features
|
22
|
+
#
|
23
|
+
# Creates a new Class with name (String), qualifiers, alias, superclass and features
|
24
|
+
#
|
25
|
+
# Features are class attributes, namely Property, Method, or Reference
|
26
|
+
#
|
27
|
+
# call-seq:
|
28
|
+
# Class.new("MyClass")
|
29
|
+
# Class.new("MyClass", qualifiers)
|
30
|
+
# Class.new("MyClass", qualifiers, "my_class")
|
31
|
+
# Class.new("MyClass", qualifiers, "my_class", "SuperClass")
|
32
|
+
# Class.new("MyClass", qualifiers, "my_class", "SuperClass", features)
|
33
|
+
#
|
34
|
+
def initialize name, qualifiers = nil, alias_name = nil, superclass = nil, features = nil
|
8
35
|
@alias_name = alias_name
|
9
36
|
@superclass = superclass
|
10
|
-
features = nil if features.
|
37
|
+
features = nil if features.kind_of?(::Enumerable) && features.empty?
|
11
38
|
@features = features
|
12
39
|
# puts "CIM::Class.new(#{@features})"
|
13
|
-
super name
|
40
|
+
super name, qualifiers
|
14
41
|
end
|
15
|
-
|
16
|
-
|
42
|
+
#
|
43
|
+
# Iterate over features flagged as keys
|
44
|
+
#
|
45
|
+
def each_key
|
46
|
+
@features.each do |f|
|
47
|
+
yield f if f.key?
|
48
|
+
end
|
17
49
|
end
|
50
|
+
#
|
18
51
|
# true if class has instances (instance provider)
|
52
|
+
#
|
19
53
|
def instance?
|
20
54
|
@features.size > 0
|
21
55
|
end
|
56
|
+
#
|
22
57
|
# true if class has methods (method provider)
|
58
|
+
#
|
23
59
|
def method?
|
24
60
|
@features.each do |f|
|
25
61
|
case f
|
@@ -28,14 +64,21 @@ module CIM
|
|
28
64
|
end
|
29
65
|
false
|
30
66
|
end
|
67
|
+
#
|
31
68
|
# true if class has associations (association provider)
|
69
|
+
#
|
32
70
|
def association?
|
33
71
|
false
|
34
72
|
end
|
73
|
+
#
|
35
74
|
# true if class has indications (indication provider)
|
75
|
+
#
|
36
76
|
def indication?
|
37
77
|
false
|
38
78
|
end
|
79
|
+
#
|
80
|
+
# returns a string representation in MOF syntax format
|
81
|
+
#
|
39
82
|
def to_s
|
40
83
|
s = ""
|
41
84
|
s << "[#{@qualifiers.join(', ')}]\n" if @qualifiers
|
data/lib/cim/class_feature.rb
CHANGED
@@ -1,33 +1,62 @@
|
|
1
|
+
#
|
2
|
+
# cim/class_feature.rb - class CIM::ClassFeature
|
3
|
+
#
|
4
|
+
# A pure-Ruby implementation of the CIM meta model.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2010 Klaus Kämpf <kkaempf@suse.de>
|
7
|
+
#
|
8
|
+
# Licensed under the Ruby license
|
9
|
+
#
|
1
10
|
module CIM
|
2
|
-
#
|
11
|
+
#
|
12
|
+
# ClassFeature is the base class for Class Property and Method
|
13
|
+
#
|
14
|
+
# A ClassFeature has a type (Type), name (String), and optional Qualifiers
|
15
|
+
#
|
16
|
+
# Access to ClassFeature attributes is *protected*, use the derived
|
17
|
+
# classes Property, Method and Reference
|
18
|
+
#
|
3
19
|
class ClassFeature < NamedElement
|
4
|
-
attr_reader :type
|
5
|
-
|
6
|
-
@type = (type.is_a? CIM::Type) ? type : CIM::Type.new(type)
|
7
|
-
qualifiers = nil if qualifiers.is_a?(::Array) && qualifiers.empty?
|
8
|
-
@qualifiers = qualifiers
|
9
|
-
super name
|
10
|
-
end
|
20
|
+
attr_reader :type
|
21
|
+
#
|
11
22
|
# if has key qualifier
|
23
|
+
#
|
12
24
|
def key?
|
13
25
|
@qualifiers && @qualifiers.include?(:key,:bool)
|
14
26
|
end
|
27
|
+
#
|
15
28
|
# if static (class-level) feature
|
29
|
+
#
|
16
30
|
def static?
|
17
31
|
false
|
18
32
|
end
|
19
|
-
#
|
33
|
+
#
|
34
|
+
# if Property
|
35
|
+
#
|
20
36
|
def property?
|
21
37
|
false
|
22
38
|
end
|
23
|
-
#
|
39
|
+
#
|
40
|
+
# if Method
|
41
|
+
#
|
24
42
|
def method?
|
25
43
|
false
|
26
44
|
end
|
27
|
-
#
|
45
|
+
#
|
46
|
+
# if Reference
|
47
|
+
#
|
28
48
|
def reference?
|
29
49
|
false
|
30
50
|
end
|
51
|
+
protected
|
52
|
+
def initialize type, name, qualifiers = nil
|
53
|
+
# :notnew:
|
54
|
+
@type = (type.is_a? CIM::Type) ? type : CIM::Type.new(type)
|
55
|
+
super name, qualifiers
|
56
|
+
end
|
57
|
+
#
|
58
|
+
# returns a string representation in MOF syntax format
|
59
|
+
#
|
31
60
|
def to_s
|
32
61
|
s = ""
|
33
62
|
s << "#{@qualifiers}\n " if @qualifiers
|