cim 0.3.0 → 0.5.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.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in cim.gemspec
4
+ gemspec
@@ -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
+
@@ -1,18 +1,25 @@
1
- = cim
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
- * Cim is a pure-Ruby implementation of the CIM meta model.
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
- Instances of Cim classes are used to define a CIM schema, often
10
- represented as a .mof file.
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
- https://rubygems.org/gems/mof is a parser for .mof files and the
15
- primary consumer of the cim gem.
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 'rubygems'
2
- gem 'hoe', '>= 2.1.0'
3
- require 'hoe'
4
- require 'fileutils'
5
- require './lib/cim'
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
6
3
 
7
- Hoe.plugin :newgem
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]
@@ -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
- # Written by Klaus Kaempf <kkaempf@suse.de>
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
- module Cim
11
- VERSION = '0.3.0'
12
- cim_dir = File.join(File.dirname(__FILE__),"cim")
13
- require cim_dir + '/type'
14
- require cim_dir + '/variant'
15
- require cim_dir + '/qualifier_flavors'
16
- require cim_dir + '/qualifier_scope'
17
- require cim_dir + '/named_element'
18
- require cim_dir + '/qualifier_declaration'
19
- require cim_dir + '/qualifier'
20
- require cim_dir + '/qualifiers'
21
- require cim_dir + '/class_feature'
22
- require cim_dir + '/property'
23
- require cim_dir + '/reference'
24
- require cim_dir + '/method'
25
- require cim_dir + '/class'
26
- require cim_dir + '/association'
27
- require cim_dir + '/instance'
28
- require cim_dir + '/indication'
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
@@ -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
- def initialize name, qualifiers, alias_name, superclass, features
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
@@ -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, :qualifiers, :superclass, :features
5
- attr_accessor :parent
6
- def initialize name, qualifiers, alias_name, superclass, features
7
- @qualifiers = qualifiers
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.is_a?(Array) && features.empty?
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
- def add_type t
16
- @ptype << t
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
@@ -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
- # Shared between Property and Method
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, :qualifiers
5
- def initialize type, name, qualifiers = nil
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
- # if property
33
+ #
34
+ # if Property
35
+ #
20
36
  def property?
21
37
  false
22
38
  end
23
- # if method
39
+ #
40
+ # if Method
41
+ #
24
42
  def method?
25
43
  false
26
44
  end
27
- # if reference
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