cim 1.3 → 1.4
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/lib/cim.rb +1 -1
- data/lib/cim/class_feature.rb +0 -12
- data/lib/cim/method.rb +16 -0
- data/lib/cim/property.rb +16 -0
- metadata +17 -41
- data/Gemfile +0 -4
- data/History.txt +0 -35
- data/Rakefile +0 -6
- data/cim.gemspec +0 -30
- data/tasks/clean.rake +0 -9
- data/tasks/doc.rake +0 -14
- data/tasks/test.rake +0 -6
- data/test/test_loading.rb +0 -2
- data/test/test_method.rb +0 -29
- data/test/test_property.rb +0 -23
- data/test/test_qualifier.rb +0 -16
- data/test/test_qualifier_flavors.rb +0 -19
- data/test/test_qualifier_scopes.rb +0 -19
- data/test/test_qualifier_set.rb +0 -39
- data/test/test_reference.rb +0 -13
- data/test/test_type.rb +0 -33
data/lib/cim.rb
CHANGED
data/lib/cim/class_feature.rb
CHANGED
@@ -19,18 +19,6 @@ module CIM
|
|
19
19
|
class ClassFeature < NamedElement
|
20
20
|
attr_reader :type
|
21
21
|
#
|
22
|
-
# if has key qualifier
|
23
|
-
#
|
24
|
-
def key?
|
25
|
-
@qualifiers && @qualifiers.include?(:key,:boolean)
|
26
|
-
end
|
27
|
-
#
|
28
|
-
# if static (class-level) feature
|
29
|
-
#
|
30
|
-
def static?
|
31
|
-
false
|
32
|
-
end
|
33
|
-
#
|
34
22
|
# if Property
|
35
23
|
#
|
36
24
|
def property?
|
data/lib/cim/method.rb
CHANGED
@@ -45,5 +45,21 @@ module CIM
|
|
45
45
|
p = parameters.join(", ")
|
46
46
|
"#{super}(#{p})"
|
47
47
|
end
|
48
|
+
#
|
49
|
+
# Check for qualifiers
|
50
|
+
#
|
51
|
+
# # check for existance
|
52
|
+
# method.qualifier? -> true or false
|
53
|
+
#
|
54
|
+
# # check value
|
55
|
+
# method.description -> String or nil
|
56
|
+
#
|
57
|
+
def method_missing name, *args
|
58
|
+
if name.to_s[-1,1] == "?"
|
59
|
+
@qualifiers && @qualifiers.include?(name.to_s[0...-1])
|
60
|
+
else
|
61
|
+
(@qualifiers[name].value || @qualifiers[name].declaration.default.value) rescue nil
|
62
|
+
end
|
63
|
+
end
|
48
64
|
end
|
49
65
|
end
|
data/lib/cim/property.rb
CHANGED
@@ -33,6 +33,22 @@ module CIM
|
|
33
33
|
def property?
|
34
34
|
true
|
35
35
|
end
|
36
|
+
#
|
37
|
+
# Check for qualifiers
|
38
|
+
#
|
39
|
+
# # check for existance
|
40
|
+
# element.qualifier? -> true or false
|
41
|
+
#
|
42
|
+
# # check value
|
43
|
+
# element.description -> String or nil
|
44
|
+
#
|
45
|
+
def method_missing name, *args
|
46
|
+
if name.to_s[-1,1] == "?"
|
47
|
+
@qualifiers && @qualifiers.include?(name.to_s[0...-1])
|
48
|
+
else
|
49
|
+
(@qualifiers[name].value || @qualifiers[name].declaration.default.value) rescue nil
|
50
|
+
end
|
51
|
+
end
|
36
52
|
end
|
37
53
|
end
|
38
54
|
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: "1.
|
8
|
+
- 4
|
9
|
+
version: "1.4"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- "Klaus K\xC3\xA4mpf"
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-
|
17
|
+
date: 2012-06-27 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -60,39 +60,23 @@ extra_rdoc_files:
|
|
60
60
|
- README.rdoc
|
61
61
|
- LICENSE
|
62
62
|
files:
|
63
|
-
- Gemfile
|
64
|
-
- History.txt
|
65
|
-
- LICENSE
|
66
|
-
- README.rdoc
|
67
|
-
- Rakefile
|
68
|
-
- cim.gemspec
|
69
63
|
- lib/cim.rb
|
70
|
-
- lib/cim/class.rb
|
71
|
-
- lib/cim/class_feature.rb
|
72
|
-
- lib/cim/instance.rb
|
73
|
-
- lib/cim/method.rb
|
74
|
-
- lib/cim/named_element.rb
|
75
64
|
- lib/cim/property.rb
|
76
|
-
- lib/cim/
|
77
|
-
- lib/cim/
|
78
|
-
- lib/cim/qualifier_flavors.rb
|
65
|
+
- lib/cim/type.rb
|
66
|
+
- lib/cim/method.rb
|
79
67
|
- lib/cim/qualifier_scopes.rb
|
68
|
+
- lib/cim/instance.rb
|
80
69
|
- lib/cim/qualifier_set.rb
|
81
70
|
- lib/cim/reference.rb
|
82
|
-
- lib/cim/
|
71
|
+
- lib/cim/qualifier_flavors.rb
|
83
72
|
- lib/cim/variant.rb
|
84
|
-
-
|
85
|
-
-
|
86
|
-
-
|
87
|
-
-
|
88
|
-
-
|
89
|
-
-
|
90
|
-
-
|
91
|
-
- test/test_qualifier_flavors.rb
|
92
|
-
- test/test_qualifier_scopes.rb
|
93
|
-
- test/test_qualifier_set.rb
|
94
|
-
- test/test_reference.rb
|
95
|
-
- test/test_type.rb
|
73
|
+
- lib/cim/class_feature.rb
|
74
|
+
- lib/cim/class.rb
|
75
|
+
- lib/cim/named_element.rb
|
76
|
+
- lib/cim/qualifier_declaration.rb
|
77
|
+
- lib/cim/qualifier.rb
|
78
|
+
- README.rdoc
|
79
|
+
- LICENSE
|
96
80
|
has_rdoc: true
|
97
81
|
homepage: https://github.com/kkaempf/cim
|
98
82
|
licenses: []
|
@@ -127,13 +111,5 @@ rubygems_version: 1.5.0
|
|
127
111
|
signing_key:
|
128
112
|
specification_version: 3
|
129
113
|
summary: A pure-Ruby implementation of the CIM meta model
|
130
|
-
test_files:
|
131
|
-
|
132
|
-
- test/test_method.rb
|
133
|
-
- test/test_property.rb
|
134
|
-
- test/test_qualifier.rb
|
135
|
-
- test/test_qualifier_flavors.rb
|
136
|
-
- test/test_qualifier_scopes.rb
|
137
|
-
- test/test_qualifier_set.rb
|
138
|
-
- test/test_reference.rb
|
139
|
-
- test/test_type.rb
|
114
|
+
test_files: []
|
115
|
+
|
data/Gemfile
DELETED
data/History.txt
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
=== 1.3 2011-11-16
|
2
|
-
|
3
|
-
* Make QualifierScope and QualifierFlavor Array
|
4
|
-
(remove :elements and :flavors accessors)
|
5
|
-
|
6
|
-
* Rename CIM::QualifierScopesError to CIM::QualifierScopeError
|
7
|
-
|
8
|
-
=== 1.2.1 2011-11-08
|
9
|
-
|
10
|
-
* Ruby 1.9 support
|
11
|
-
|
12
|
-
=== 1.2.0
|
13
|
-
|
14
|
-
=== 0.5.0 2011-09-29
|
15
|
-
|
16
|
-
* Clean up Rakefile, support Bundler
|
17
|
-
* Add QualifierSet[] access function
|
18
|
-
* Make check functions like key?, etc. public
|
19
|
-
|
20
|
-
=== 0.4.1 2010-10-14
|
21
|
-
|
22
|
-
* More tests
|
23
|
-
* Refactor Qualifiers to QualifierSet, QualifierSet includes Qualifiers
|
24
|
-
|
25
|
-
=== 0.3.1 2010-10-05
|
26
|
-
|
27
|
-
* Extend API for mof
|
28
|
-
|
29
|
-
=== 0.3.0 2010-10-04
|
30
|
-
|
31
|
-
* Refactoring for mof
|
32
|
-
|
33
|
-
=== 0.2.7 2010-10-03
|
34
|
-
|
35
|
-
* Initial release
|
data/Rakefile
DELETED
data/cim.gemspec
DELETED
@@ -1,30 +0,0 @@
|
|
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.add_development_dependency('rake')
|
22
|
-
s.add_development_dependency('bundler')
|
23
|
-
|
24
|
-
s.files = `git ls-files`.split("\n")
|
25
|
-
s.files.reject! { |fn| fn == '.gitignore' }
|
26
|
-
s.extra_rdoc_files = Dir['README*', 'TODO*', 'CHANGELOG*', 'LICENSE']
|
27
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
28
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
29
|
-
s.require_paths = ["lib"]
|
30
|
-
end
|
data/tasks/clean.rake
DELETED
data/tasks/doc.rake
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'yard'
|
3
|
-
YARD::Rake::YardocTask.new(:doc) do |t|
|
4
|
-
t.files = ['lib/**/*.rb']
|
5
|
-
t.options = ['--no-private']
|
6
|
-
end
|
7
|
-
rescue LoadError
|
8
|
-
STDERR.puts "Install yard if you want prettier docs"
|
9
|
-
require 'rdoc/task'
|
10
|
-
Rake::RDocTask.new(:doc) do |rdoc|
|
11
|
-
rdoc.rdoc_dir = "doc"
|
12
|
-
rdoc.title = "dm-keeper-adapter #{CIM::VERSION}"
|
13
|
-
end
|
14
|
-
end
|
data/tasks/test.rake
DELETED
data/test/test_loading.rb
DELETED
data/test/test_method.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
$: << File.join(File.dirname(__FILE__),"..","lib")
|
2
|
-
|
3
|
-
require "test/unit"
|
4
|
-
require "cim"
|
5
|
-
|
6
|
-
class MethodTest < Test::Unit::TestCase
|
7
|
-
def test_init
|
8
|
-
m = CIM::Method.new :real32, "Foo", CIM::QualifierDeclaration.new(:description, :string, "This is a foo method", :class)
|
9
|
-
assert m
|
10
|
-
assert_equal "Foo", m.name
|
11
|
-
assert m.qualifiers.size > 0
|
12
|
-
assert m.qualifiers.include?( :description )
|
13
|
-
assert m.qualifiers.include?( :description, :string )
|
14
|
-
# assert_equal "This is a foo method", m.description
|
15
|
-
assert_equal false, m.to_s.empty?
|
16
|
-
end
|
17
|
-
def test_nodesc
|
18
|
-
m = CIM::Method.new :boolean, "Foo"
|
19
|
-
assert m
|
20
|
-
assert_equal "Foo", m.name
|
21
|
-
assert_equal m.type, :boolean
|
22
|
-
# assert_equal nil, m.description
|
23
|
-
end
|
24
|
-
def test_raise
|
25
|
-
assert_raise TypeError do
|
26
|
-
m = CIM::Method.new :foo, "Foo"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/test/test_property.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
$: << File.join(File.dirname(__FILE__),"..","lib")
|
2
|
-
|
3
|
-
require "test/unit"
|
4
|
-
require "cim"
|
5
|
-
|
6
|
-
class PropertyTest < Test::Unit::TestCase
|
7
|
-
def test_init
|
8
|
-
p = CIM::Property.new :string, "String", CIM::QualifierDeclaration.new(:key, :boolean), CIM::QualifierDeclaration.new(:description, :string, "This is a string", :class)
|
9
|
-
assert p
|
10
|
-
assert p.is_a? CIM::Property
|
11
|
-
assert_equal "String", p.name
|
12
|
-
# assert p.key?
|
13
|
-
end
|
14
|
-
def test_name
|
15
|
-
p = CIM::Property.new :uint32, "foo"
|
16
|
-
assert_equal "foo", p.name
|
17
|
-
end
|
18
|
-
def test_raise
|
19
|
-
assert_raise TypeError do
|
20
|
-
p = CIM::Property.new :foo, "foo"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/test/test_qualifier.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
$: << File.join(File.dirname(__FILE__),"..","lib")
|
2
|
-
|
3
|
-
require "test/unit"
|
4
|
-
require "cim"
|
5
|
-
|
6
|
-
class QualifierTest < Test::Unit::TestCase
|
7
|
-
def test_key
|
8
|
-
q = CIM::QualifierDeclaration.new :key, :boolean
|
9
|
-
assert q
|
10
|
-
end
|
11
|
-
def test_raise
|
12
|
-
assert_raise RuntimeError do
|
13
|
-
CIM::Qualifier.new(:unknown)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
$: << File.join(File.dirname(__FILE__),"..","lib")
|
2
|
-
|
3
|
-
require "test/unit"
|
4
|
-
require "cim"
|
5
|
-
|
6
|
-
class QualifierFlavorsTest < Test::Unit::TestCase
|
7
|
-
def test_new
|
8
|
-
assert CIM::QualifierFlavors.new
|
9
|
-
f = CIM::QualifierFlavors.new(:enableoverride)
|
10
|
-
assert f
|
11
|
-
assert_equal 1,f.size
|
12
|
-
assert f.include? :enableoverride
|
13
|
-
end
|
14
|
-
def test_raise
|
15
|
-
assert_raise CIM::QualifierFlavorError do
|
16
|
-
CIM::QualifierFlavors.new(:unknown)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
$: << File.join(File.dirname(__FILE__),"..","lib")
|
2
|
-
|
3
|
-
require "test/unit"
|
4
|
-
require "cim"
|
5
|
-
|
6
|
-
class QualifierScopesTest < Test::Unit::TestCase
|
7
|
-
def test_new
|
8
|
-
assert CIM::QualifierScopes.new
|
9
|
-
s = CIM::QualifierScopes.new(:association)
|
10
|
-
assert s
|
11
|
-
assert_equal 1,s.size
|
12
|
-
assert s.include? :association
|
13
|
-
end
|
14
|
-
def test_raise
|
15
|
-
assert_raise CIM::QualifierScopeError do
|
16
|
-
CIM::QualifierScopes.new(:unknown)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/test/test_qualifier_set.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
$: << File.join(File.dirname(__FILE__),"..","lib")
|
2
|
-
|
3
|
-
require "test/unit"
|
4
|
-
require "cim"
|
5
|
-
|
6
|
-
class QualifierSetTest < Test::Unit::TestCase
|
7
|
-
def setup
|
8
|
-
qboolean = CIM::QualifierDeclaration.new("flag")
|
9
|
-
qint = CIM::QualifierDeclaration.new("value", :uint32)
|
10
|
-
qstring = CIM::QualifierDeclaration.new("description", :string, "This is a description")
|
11
|
-
@qualifiers = CIM::QualifierSet.new
|
12
|
-
@qualifiers << CIM::Qualifier.new(qboolean)
|
13
|
-
@qualifiers << CIM::Qualifier.new(qint)
|
14
|
-
@qualifiers << CIM::Qualifier.new(qstring)
|
15
|
-
end
|
16
|
-
def test_key
|
17
|
-
assert_equal 3, @qualifiers.size
|
18
|
-
end
|
19
|
-
def test_prefill
|
20
|
-
q = CIM::QualifierSet.new "a", :b
|
21
|
-
assert_equal 2, q.size
|
22
|
-
assert q.include?( "a" )
|
23
|
-
assert q.include?( "b", :boolean )
|
24
|
-
end
|
25
|
-
def test_include
|
26
|
-
assert @qualifiers.include?( :flag )
|
27
|
-
assert @qualifiers.include?( "flag" )
|
28
|
-
assert @qualifiers.include?( "flag", :boolean )
|
29
|
-
assert @qualifiers.include?( "flag", "boolean" )
|
30
|
-
assert !@qualifiers.include?( "flag", :string )
|
31
|
-
end
|
32
|
-
def test_access
|
33
|
-
assert @qualifiers[:flag]
|
34
|
-
assert @qualifiers["flag"]
|
35
|
-
assert @qualifiers["flag", :boolean]
|
36
|
-
assert @qualifiers["flag", "boolean"]
|
37
|
-
assert !@qualifiers["flag", :string]
|
38
|
-
end
|
39
|
-
end
|
data/test/test_reference.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
$: << File.join(File.dirname(__FILE__),"..","lib")
|
2
|
-
|
3
|
-
require "test/unit"
|
4
|
-
require "cim"
|
5
|
-
|
6
|
-
class ReferenceTest < Test::Unit::TestCase
|
7
|
-
def test_init
|
8
|
-
r = CIM::Reference.new :string, "String"
|
9
|
-
assert r
|
10
|
-
assert r.is_a? CIM::Reference
|
11
|
-
assert r.kind_of? CIM::ClassFeature
|
12
|
-
end
|
13
|
-
end
|
data/test/test_type.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
$: << File.join(File.dirname(__FILE__),"..","lib")
|
2
|
-
|
3
|
-
require "test/unit"
|
4
|
-
require "cim"
|
5
|
-
|
6
|
-
class TypeTest < Test::Unit::TestCase
|
7
|
-
def test_init
|
8
|
-
t = CIM::Type.new :null
|
9
|
-
assert t
|
10
|
-
assert_equal "null", t.to_s
|
11
|
-
assert !t.array?
|
12
|
-
end
|
13
|
-
def test_raise
|
14
|
-
assert_raise TypeError do
|
15
|
-
t = CIM::Type.new :foo
|
16
|
-
end
|
17
|
-
end
|
18
|
-
def test_alias
|
19
|
-
assert_equal CIM::Type.new(:bool), CIM::Type.new(:boolean)
|
20
|
-
assert_equal CIM::Type.new(:datetime), CIM::Type.new(:dateTime)
|
21
|
-
end
|
22
|
-
def test_normalize
|
23
|
-
assert_equal CIM::Type.new(:null), CIM::Type.normalize(:null)
|
24
|
-
assert_equal CIM::Type.normalize(:null), CIM::Type.normalize(CIM::Type.new(:null))
|
25
|
-
end
|
26
|
-
def test_matches
|
27
|
-
assert CIM::Type.new(:null).matches? nil
|
28
|
-
assert CIM::Type.new(:uint64).matches? 1
|
29
|
-
assert CIM::Type.new(:uint64).matches? Integer
|
30
|
-
assert CIM::Type.new(:real32).matches? 3.1415
|
31
|
-
assert CIM::Type.new(:string).matches? String
|
32
|
-
end
|
33
|
-
end
|