occi-core 4.0.0.alpha.1 → 4.0.0.alpha.2
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.
- checksums.yaml +4 -4
- data/lib/occi/core/category.rb +1 -0
- data/lib/occi/core/link.rb +3 -1
- data/lib/occi/core/mixins.rb +10 -7
- data/lib/occi/core.rb +0 -1
- data/lib/occi/parser/text.rb +47 -18
- data/lib/occi/parser.rb +1 -1
- data/lib/occi/version.rb +1 -1
- data/spec/occi/parser/text_spec.rb +83 -15
- data/spec/occi/parser_spec.rb +2 -0
- metadata +2 -3
- data/lib/occi/core/attribute.rb +0 -99
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 945b3678e21953e765735aff0ace9d400780c9d1
|
4
|
+
data.tar.gz: a479e10184d38cd9a45ac8cc6aa42fc2a91e9b7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 366e5a6cadb42058c98eae50b7b7a72216da444dd9c769b63054cc83b7619137e631c16472fc33ec27902cfcec770a735a5327b1c8e678c76e154f2410ae95b8
|
7
|
+
data.tar.gz: 2870063f118d8a93629343ce95c9b81799c7980f173fe1b401f4fbc677daa864d4e84a12ffb43b5e58ea2ddf21ccf58c58f0aeb41fea6281f2a5679034d8ae2b
|
data/lib/occi/core/category.rb
CHANGED
@@ -68,6 +68,7 @@ module Occi
|
|
68
68
|
class_name = term.gsub('-', '_').capitalize
|
69
69
|
if namespace.const_defined? class_name
|
70
70
|
klass = namespace.const_get class_name
|
71
|
+
return klass.mixin if klass.respond_to? :mixin
|
71
72
|
unless klass.ancestors.include? Occi::Core::Entity or klass.ancestors.include? Occi::Core::Category
|
72
73
|
raise "OCCI Kind with type identifier #{scheme + term} could not be created as the corresponding class #{klass.to_s} already exists and is not derived from Occi::Core::Entity"
|
73
74
|
end
|
data/lib/occi/core/link.rb
CHANGED
@@ -37,6 +37,7 @@ module Occi
|
|
37
37
|
# set target attribute of link
|
38
38
|
# @param [String] target
|
39
39
|
def target=(target)
|
40
|
+
self.attributes['occi.core.target'] = target.to_s
|
40
41
|
@target = target
|
41
42
|
end
|
42
43
|
|
@@ -49,6 +50,7 @@ module Occi
|
|
49
50
|
# set source attribute of link
|
50
51
|
# @param [String] source
|
51
52
|
def source=(source)
|
53
|
+
self.attributes['occi.core.source'] = source.to_s
|
52
54
|
@source = source
|
53
55
|
end
|
54
56
|
|
@@ -63,7 +65,7 @@ module Occi
|
|
63
65
|
def as_json(options={})
|
64
66
|
link = super
|
65
67
|
link.rel = @rel.to_s if @rel
|
66
|
-
link.source = self.source.to_s
|
68
|
+
link.source = self.source.to_s unless self.source.to_s.blank?
|
67
69
|
link.target = self.target.to_s if self.target
|
68
70
|
link
|
69
71
|
end
|
data/lib/occi/core/mixins.rb
CHANGED
@@ -23,17 +23,20 @@ module Occi
|
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
# TODO: fix mixin conversion
|
27
|
+
def convert(mixin)
|
28
|
+
mixin = super mixin
|
28
29
|
|
29
|
-
if
|
30
|
-
scheme, term =
|
30
|
+
if mixin.kind_of? String
|
31
|
+
scheme, term = mixin.split '#'
|
31
32
|
scheme += '#'
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
mixin = Occi::Core::Category.get_class scheme, term, [Occi::Core::Mixin.new]
|
35
|
+
if mixin.respond_to? :new
|
36
|
+
mixin = mixin.new(scheme, term)
|
37
|
+
end
|
35
38
|
end
|
36
|
-
|
39
|
+
mixin
|
37
40
|
end
|
38
41
|
|
39
42
|
end
|
data/lib/occi/core.rb
CHANGED
data/lib/occi/parser/text.rb
CHANGED
@@ -5,17 +5,19 @@ module Occi
|
|
5
5
|
if RUBY_VERSION =~ /1.8/
|
6
6
|
require 'oniguruma'
|
7
7
|
REGEXP = Oniguruma::ORegexp
|
8
|
+
ONIG = true
|
8
9
|
else
|
9
10
|
REGEXP = Regexp
|
11
|
+
ONIG = false
|
10
12
|
end
|
11
13
|
|
12
14
|
# Regular expressions
|
13
15
|
REGEXP_QUOTED_STRING = /([^"\\]|\\.)*/
|
14
16
|
REGEXP_LOALPHA = /[a-z]/
|
15
17
|
REGEXP_DIGIT = /[0-9]/
|
16
|
-
REGEXP_INT = /#{REGEXP_DIGIT}
|
17
|
-
REGEXP_FLOAT = /#{
|
18
|
-
REGEXP_NUMBER = /#{
|
18
|
+
REGEXP_INT = /#{REGEXP_DIGIT}+/
|
19
|
+
REGEXP_FLOAT = /#{REGEXP_INT}\.#{REGEXP_INT}/
|
20
|
+
REGEXP_NUMBER = /#{REGEXP_FLOAT}|#{REGEXP_INT}/
|
19
21
|
REGEXP_BOOL = /true|false/
|
20
22
|
|
21
23
|
# Regular expressions for OCCI
|
@@ -67,12 +69,21 @@ module Occi
|
|
67
69
|
end
|
68
70
|
|
69
71
|
# Regular expression for OCCI Link Instance References
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
if Occi::Settings.compatibility
|
73
|
+
REGEXP_LINK = "Link:\\s*\\<(?<uri>#{URI::URI_REF})\\>" << # uri (mandatory)
|
74
|
+
";\\s*rel=\"(?<rel>#{REGEXP_RESOURCE_TYPE})\"" << # rel (mandatory)
|
75
|
+
"(;\\s*self=\"(?<self>#{REGEXP_LINK_INSTANCE})\")?" << # self (optional)
|
76
|
+
"(;\\s*category=\"(?<category>(;?\\s*(#{REGEXP_LINK_TYPE}))+)\")?" << # category (optional)
|
77
|
+
"(?<attributes>(;?\\s*(#{REGEXP_ATTRIBUTE_REPR}))*)" << # attributes (optional)
|
78
|
+
';?' # additional semicolon at the end (not specified, for interoperability)
|
79
|
+
else
|
80
|
+
REGEXP_LINK = "Link:\\s*\\<(?<uri>#{URI::URI_REF})\\>" << # uri (mandatory)
|
81
|
+
";\\s*rel=\"(?<rel>#{REGEXP_RESOURCE_TYPE})\"" << # rel (mandatory)
|
82
|
+
"(;\\s*self=\"(?<self>#{REGEXP_LINK_INSTANCE})\")?" << # self (optional)
|
83
|
+
"(;\\s*category=\"(?<category>(;?\\s*(#{REGEXP_LINK_TYPE}))+)\")?" << # category (optional)
|
84
|
+
"(?<attributes>(;\\s*(#{REGEXP_ATTRIBUTE_REPR}))*)" << # attributes (optional)
|
85
|
+
';?' # additional semicolon at the end (not specified, for interoperability)
|
86
|
+
end
|
76
87
|
|
77
88
|
# Regular expression for OCCI Entity Attributes
|
78
89
|
REGEXP_ATTRIBUTE = "X-OCCI-Attribute:\\s*(?<name>#{REGEXP_ATTRIBUTE_NAME})=(\"(?<string>#{REGEXP_QUOTED_STRING})\"|(?<number>#{REGEXP_NUMBER})|(?<bool>#{REGEXP_BOOL}))" <<
|
@@ -106,7 +117,9 @@ module Occi
|
|
106
117
|
when /^X-OCCI-Attribute:/
|
107
118
|
resource.attributes.merge! self.attribute(line)
|
108
119
|
when /^Link:/
|
109
|
-
|
120
|
+
link = self.link_string(line, resource)
|
121
|
+
resource.links << link
|
122
|
+
collection << link
|
110
123
|
end
|
111
124
|
end
|
112
125
|
collection << resource if resource.kind_of? Occi::Core::Resource
|
@@ -190,7 +203,11 @@ module Occi
|
|
190
203
|
raise "could not match #{string}" unless match
|
191
204
|
|
192
205
|
value = match[:string] if match[:string]
|
193
|
-
|
206
|
+
|
207
|
+
if match[:number]
|
208
|
+
match[:number].include?('.') ? value = match[:number].to_f : value = match[:number].to_i
|
209
|
+
end
|
210
|
+
|
194
211
|
value = match[:bool] == "true" if match[:bool]
|
195
212
|
Occi::Core::Attributes.split match[:name] => value
|
196
213
|
end
|
@@ -203,16 +220,28 @@ module Occi
|
|
203
220
|
|
204
221
|
raise "could not match #{string}" unless match
|
205
222
|
|
206
|
-
categories = match[:category].split
|
207
|
-
kind = categories.shift
|
208
|
-
mixins = categories
|
209
|
-
actions = nil
|
210
|
-
rel = match[:rel]
|
211
223
|
target = match[:uri]
|
224
|
+
rel = match[:rel]
|
225
|
+
if match[:category].blank?
|
226
|
+
kind = Occi::Core::Link.kind
|
227
|
+
else
|
228
|
+
categories = match[:category].split
|
229
|
+
kind = categories.shift
|
230
|
+
mixins = categories
|
231
|
+
end
|
232
|
+
actions = nil
|
212
233
|
location = match[:self]
|
213
234
|
|
214
235
|
# create an array of the list of attributes
|
215
|
-
attributes =
|
236
|
+
attributes = []
|
237
|
+
regexp=REGEXP.new '(\\s*'+REGEXP_ATTRIBUTE_REPR.to_s+')'
|
238
|
+
attr_line = match[:attributes].sub(/^\s*;\s*/, ' ')
|
239
|
+
if ONIG
|
240
|
+
attr_line_scans = regexp.scan(attr_line)
|
241
|
+
attributes = attr_line_scans.collect {|matches| matches.captures.first} if attr_line_scans
|
242
|
+
else
|
243
|
+
attributes = attr_line.scan(regexp).collect {|matches| matches.first}
|
244
|
+
end
|
216
245
|
# parse each attribute and create an OCCI Attribute object from it
|
217
246
|
attributes = attributes.inject(Hashie::Mash.new) { |hsh, attribute| hsh.merge!(Occi::Parser::Text.attribute('X-OCCI-Attribute: ' + attribute)) }
|
218
247
|
Occi::Core::Link.new kind, mixins, attributes, actions, rel, target, source, location
|
@@ -231,4 +260,4 @@ module Occi
|
|
231
260
|
|
232
261
|
end
|
233
262
|
end
|
234
|
-
end
|
263
|
+
end
|
data/lib/occi/parser.rb
CHANGED
data/lib/occi/version.rb
CHANGED
@@ -6,26 +6,94 @@ module Occi
|
|
6
6
|
|
7
7
|
describe '.category' do
|
8
8
|
|
9
|
-
it 'parses a string to an OCCI Category' do
|
9
|
+
it 'parses a string with an OCCI Category to an OCCI Category' do
|
10
10
|
category_string = 'Category: a_a1-_;scheme="http://a.a/a#";class="kind";title="aA1!\"§$%&/()=?`´ß+*#-_.:,;<>";rel="http://a.a/b#a";location="/a1-A/";attributes="a_1-_.a1-_a a-1.a.b";actions="http://a.a/a1#a1 http://a.b1/b1#b2"'
|
11
|
+
|
11
12
|
category = Occi::Parser::Text.category category_string
|
12
|
-
category.term.should
|
13
|
-
category.scheme.should
|
14
|
-
category.class.should
|
15
|
-
category.title.should
|
16
|
-
category.related.first.should
|
17
|
-
category.location.should
|
18
|
-
category.attributes['a_1-_'].class.should
|
19
|
-
category.attributes['a_1-_']['a1-_a'].class.should
|
20
|
-
category.attributes['a-1'].class.should
|
21
|
-
category.attributes['a-1']['a'].class.should
|
22
|
-
category.attributes['a-1']['a']['b'].class.should
|
23
|
-
category.actions.to_a.first.to_s
|
24
|
-
category.actions.to_a.last.to_s
|
13
|
+
category.term.should eq 'a_a1-_'
|
14
|
+
category.scheme.should eq 'http://a.a/a#'
|
15
|
+
category.class.should eq Occi::Core::Kind
|
16
|
+
category.title.should eq 'aA1!\"§$%&/()=?`´ß+*#-_.:,;<>'
|
17
|
+
category.related.first.should eq 'http://a.a/b#a'
|
18
|
+
category.location.should eq '/a1-A/'
|
19
|
+
category.attributes['a_1-_'].class.should eq Occi::Core::Attributes
|
20
|
+
category.attributes['a_1-_']['a1-_a'].class.should eq Occi::Core::Properties
|
21
|
+
category.attributes['a-1'].class.should eq Occi::Core::Attributes
|
22
|
+
category.attributes['a-1']['a'].class.should eq Occi::Core::Attributes
|
23
|
+
category.attributes['a-1']['a']['b'].class.should eq Occi::Core::Properties
|
24
|
+
category.actions.to_a.first.to_s.should eq 'http://a.a/a1#a1'
|
25
|
+
category.actions.to_a.last.to_s.should eq 'http://a.b1/b1#b2'
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '.resource' do
|
31
|
+
|
32
|
+
it 'parses a string with an OCCI Resource including attributes' do
|
33
|
+
resource_string = %Q|Category: compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind"\nCategory: compute;scheme="http://opennebula.org/occi/infrastructure#";class="mixin"|
|
34
|
+
resource_string << %Q|\nCategory: monitoring;scheme="https://occi.carach5.ics.muni.cz/occi/infrastructure/os_tpl#";class="mixin"|
|
35
|
+
resource_string << %Q|\nCategory: small;scheme="https://occi.carach5.ics.muni.cz/occi/infrastructure/resource_tpl#";class="mixin"|
|
36
|
+
resource_string << %Q|\nX-OCCI-Attribute: occi.core.id="ee13808d-7708-4341-a4ba-0e42e4818218"|
|
37
|
+
resource_string << %Q|\nX-OCCI-Attribute: occi.core.title="TestVM"|
|
38
|
+
resource_string << %Q|\nX-OCCI-Attribute: occi.compute.cores=1|
|
39
|
+
resource_string << %Q|\nX-OCCI-Attribute: occi.compute.memory=1.7|
|
40
|
+
resource_string << %Q|\nX-OCCI-Attribute: occi.compute.architecture="x86"|
|
41
|
+
resource_string << %Q|\nX-OCCI-Attribute: occi.compute.speed=1|
|
42
|
+
resource_string << %Q|\nX-OCCI-Attribute: occi.compute.state="active"|
|
43
|
+
resource_string << %Q|\nX-OCCI-Attribute: org.opennebula.compute.cpu=1.0|
|
44
|
+
|
45
|
+
collection = Occi::Parser::Text.resource resource_string.lines
|
46
|
+
collection.resources.first.attributes['occi.compute.cores'].should eq(1)
|
47
|
+
collection.resources.first.attributes['org.opennebula.compute.cpu'].should eq(1.0)
|
48
|
+
collection.resources.first.attributes['occi.compute.architecture'].should eq("x86")
|
49
|
+
collection.resources.first.attributes['occi.compute.memory'].should eq(1.7)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'parses a string with an OCCI Resource including inline OCCI Link definitions' do
|
53
|
+
resource_string = %Q|Category: compute;scheme="http://schemas.ogf.org/occi/infrastructure#";class="kind"\nCategory: compute;scheme="http://opennebula.org/occi/infrastructure#";class="mixin"|
|
54
|
+
resource_string << %Q|\nCategory: monitoring;scheme="https://occi.carach5.ics.muni.cz/occi/infrastructure/os_tpl#";class="mixin"|
|
55
|
+
resource_string << %Q|\nCategory: small;scheme="https://occi.carach5.ics.muni.cz/occi/infrastructure/resource_tpl#";class="mixin"|
|
56
|
+
resource_string << %Q|\nX-OCCI-Attribute: occi.core.id="ee13808d-7708-4341-a4ba-0e42e4818218"|
|
57
|
+
resource_string << %Q|\nX-OCCI-Attribute: occi.core.title="TestVM"|
|
58
|
+
resource_string << %Q|\nX-OCCI-Attribute: occi.compute.cores=1|
|
59
|
+
resource_string << %Q|\nX-OCCI-Attribute: occi.compute.memory=1.7|
|
60
|
+
resource_string << %Q|\nX-OCCI-Attribute: occi.compute.architecture="x86"|
|
61
|
+
resource_string << %Q|\nX-OCCI-Attribute: occi.compute.speed=1|
|
62
|
+
resource_string << %Q|\nX-OCCI-Attribute: occi.compute.state="active"|
|
63
|
+
resource_string << %Q|\nX-OCCI-Attribute: org.opennebula.compute.cpu=1.0|
|
64
|
+
resource_string << %Q|\nLink: </storage/e60aa2b8-0c86-5973-b93e-30c5c46d6eac>;rel="http://schemas.ogf.org/occi/infrastructure#storage";self="/storagelink/b2f7f1de-c60c-5b08-879c-81f52429c4ef";category="http://schemas.ogf.org/occi/infrastructure#storagelink";occi.core.id="b2f7f1de-c60c-5b08-879c-81f52429c4ef" occi.core.title="link to storage" occi.storagelink.deviceid="xvda" occi.storagelink.state="inactive" org.opennebula.storagelink.bus="ide" org.opennebula.storagelink.driver="tap2:tapdisk:aio:"|
|
65
|
+
resource_string << %Q|\nLink: </network/e4bd81c4-adda-5626-840d-39bb7959db97>;rel="http://schemas.ogf.org/occi/infrastructure#network";self="/networkinterface/e75ab249-9325-511c-82b8-a7e4430381e3";category="http://schemas.ogf.org/occi/infrastructure#networkinterface";occi.core.id="e75ab249-9325-511c-82b8-a7e4430381e3" occi.core.title="link to network interface" occi.networkinterface.address="192.168.254.8" occi.networkinterface.mac="02:00:c0:a8:fe:08" occi.networkinterface.state="inactive" org.opennebula.networkinterface.bridge="xenbr0"|
|
66
|
+
|
67
|
+
collection = Occi::Parser::Text.resource resource_string.lines
|
68
|
+
collection.resources.should have(1).resource
|
69
|
+
collection.links.should have(2).links
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'parses a string with an OCCI Resource including inline OCCI Link definitions and OCCI Mixins' do
|
73
|
+
resource_string = %Q|Category: compute; scheme="http://schemas.ogf.org/occi/infrastructure#"; class="kind"; title="Compute Resource"; rel="http://schemas.ogf.org/occi/core#resource"; location="https://egi-cloud.zam.kfa-juelich.de:8787/compute/"; attributes="occi.compute.architecture occi.compute.state{immutable} occi.compute.speed occi.compute.memory occi.compute.cores occi.compute.hostname"; actions="http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#stop http://schemas.ogf.org/occi/infrastructure/compute/action#restart http://schemas.ogf.org/occi/infrastructure/compute/action#suspend"
|
74
|
+
Category: os_vms; scheme="http://schemas.openstack.org/compute/instance#"; class="mixin"; location="https://egi-cloud.zam.kfa-juelich.de:8787/os_vms/"; attributes="org.openstack.compute.console.vnc{immutable} org.openstack.compute.state{immutable}"; actions="http://schemas.openstack.org/instance/action#chg_pwd http://schemas.openstack.org/instance/action#create_image"
|
75
|
+
Link: </compute/04106bce-87eb-4f8f-a665-2f624e54ba46?action=stop>; rel="http://schemas.ogf.org/occi/infrastructure/compute/action#stop"
|
76
|
+
Link: </compute/04106bce-87eb-4f8f-a665-2f624e54ba46?action=suspend>; rel="http://schemas.ogf.org/occi/infrastructure/compute/action#suspend"
|
77
|
+
Link: </compute/04106bce-87eb-4f8f-a665-2f624e54ba46?action=restart>; rel="http://schemas.ogf.org/occi/infrastructure/compute/action#restart"
|
78
|
+
Link: </network/public>; rel="http://schemas.ogf.org/occi/infrastructure#network"; self="/network/interface/6a7a9446-a146-4faf-a961-52f66d2808df"; category="http://schemas.ogf.org/occi/infrastructure#networkinterface http://schemas.ogf.org/occi/infrastructure/networkinterface#ipnetworkinterface"; occi.networkinterface.gateway="0.0.0.0"; occi.networkinterface.mac="aa:bb:cc:dd:ee:ff"; occi.networkinterface.interface="eth0"; occi.networkinterface.state="active"; occi.networkinterface.allocation="static"; occi.networkinterface.address="134.94.32.154"; occi.core.source="/compute/04106bce-87eb-4f8f-a665-2f624e54ba46"; occi.core.target="/network/public"; occi.core.id="/network/interface/6a7a9446-a146-4faf-a961-52f66d2808df"
|
79
|
+
Link: </network/admin>; rel="http://schemas.ogf.org/occi/infrastructure#network"; self="/network/interface/02b630f6-087e-4969-b04c-1e22d9480dec"; category="http://schemas.ogf.org/occi/infrastructure#networkinterface http://schemas.ogf.org/occi/infrastructure/networkinterface#ipnetworkinterface"; occi.networkinterface.gateway="192.168.16.1"; occi.networkinterface.mac="fa:16:3e:45:1c:26"; occi.networkinterface.interface="eth0"; occi.networkinterface.state="active"; occi.networkinterface.allocation="static"; occi.networkinterface.address="192.168.16.103"; occi.core.source="/compute/04106bce-87eb-4f8f-a665-2f624e54ba46"; occi.core.target="/network/admin"; occi.core.id="/network/interface/02b630f6-087e-4969-b04c-1e22d9480dec"
|
80
|
+
X-OCCI-Attribute: org.openstack.compute.console.vnc="http://134.94.32.4:6080/vnc_auto.html?token=9923dc1b-eca0-4c62-81a8-a0dd6848341a"
|
81
|
+
X-OCCI-Attribute: occi.compute.architecture="x86"
|
82
|
+
X-OCCI-Attribute: occi.compute.state="active"
|
83
|
+
X-OCCI-Attribute: occi.compute.speed="0.0"
|
84
|
+
X-OCCI-Attribute: occi.compute.cores="1"
|
85
|
+
X-OCCI-Attribute: occi.compute.memory="1.0"
|
86
|
+
X-OCCI-Attribute: org.openstack.compute.state="active"
|
87
|
+
X-OCCI-Attribute: occi.compute.hostname="openmodeller-test-bjoernh"
|
88
|
+
X-OCCI-Attribute: occi.core.id="04106bce-87eb-4f8f-a665-2f624e54ba46"|
|
89
|
+
|
90
|
+
collection = Occi::Parser::Text.resource resource_string.lines
|
91
|
+
collection.resources.should have(1).resource
|
92
|
+
collection.links.should have(5).links
|
25
93
|
end
|
26
94
|
|
27
95
|
end
|
28
96
|
|
29
97
|
end
|
30
98
|
end
|
31
|
-
end
|
99
|
+
end
|
data/spec/occi/parser_spec.rb
CHANGED
@@ -33,6 +33,8 @@ module Occi
|
|
33
33
|
link = resource.links.create
|
34
34
|
link.id = UUIDTools::UUID.random_create.to_s
|
35
35
|
link.target = 'http://example.com/resource/aee5acf5-71de-40b0-bd1c-2284658bfd0e'
|
36
|
+
link.source = resource
|
37
|
+
collection << link
|
36
38
|
|
37
39
|
# render collection to text/plain MIME type
|
38
40
|
rendered_collection = collection.to_text
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: occi-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.alpha.
|
4
|
+
version: 4.0.0.alpha.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Feldhaus
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-07-
|
13
|
+
date: 2013-07-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -208,7 +208,6 @@ files:
|
|
208
208
|
- lib/occi/core/action.rb
|
209
209
|
- lib/occi/core/action_instance.rb
|
210
210
|
- lib/occi/core/actions.rb
|
211
|
-
- lib/occi/core/attribute.rb
|
212
211
|
- lib/occi/core/attributes.rb
|
213
212
|
- lib/occi/core/categories.rb
|
214
213
|
- lib/occi/core/category.rb
|
data/lib/occi/core/attribute.rb
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
module Occi
|
2
|
-
module Core
|
3
|
-
module Attribute
|
4
|
-
|
5
|
-
attr_accessor :properties
|
6
|
-
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class StringAttribute < String
|
12
|
-
|
13
|
-
attr_accessor :properties
|
14
|
-
|
15
|
-
def properties
|
16
|
-
self.properties ||= Occi::Core::Properties.new
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
class NumericAttribute
|
22
|
-
|
23
|
-
attr_accessor :properties
|
24
|
-
|
25
|
-
def properties
|
26
|
-
self.properties ||= Occi::Core::Properties.new :type => 'number'
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
class FalseClass
|
32
|
-
|
33
|
-
include Occi::Core::Attribute
|
34
|
-
|
35
|
-
def properties
|
36
|
-
self.properties ||= Occi::Core::Properties.new :type => 'boolean'
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
class TrueClass
|
42
|
-
|
43
|
-
include Occi::Core::Attribute
|
44
|
-
|
45
|
-
def properties
|
46
|
-
self.properties ||= Occi::Core::Properties.new :type => 'boolean'
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
#module Occi
|
52
|
-
# module Core
|
53
|
-
# class Attribute < Occi::Core::AttributeProperties
|
54
|
-
#
|
55
|
-
# attr_accessor :_value
|
56
|
-
#
|
57
|
-
# # @param [Hash] properties
|
58
|
-
# # @param [Hash] default
|
59
|
-
# def initialize(properties={})
|
60
|
-
# super(properties)
|
61
|
-
# case properties
|
62
|
-
# when Occi::Core::AttributeProperties
|
63
|
-
# self._value = properties._value if properties._value if properties.respond_to?('_value')
|
64
|
-
# else
|
65
|
-
# self._value = properties[:value] if properties[:value]
|
66
|
-
# end
|
67
|
-
# end
|
68
|
-
#
|
69
|
-
# def _value=(value)
|
70
|
-
# raise "value #{value} can not be assigned as the attribute is not mutable" unless self._mutable if self._value
|
71
|
-
# case self._type
|
72
|
-
# when 'number'
|
73
|
-
# raise "value #{value} from class #{value.class.name} does not match attribute property type #{self._type}" unless value.kind_of?(Numeric)
|
74
|
-
# when 'boolean'
|
75
|
-
# raise "value #{value} from class #{value.class.name} does not match attribute property type #{self._type}" unless !!value == value
|
76
|
-
# when 'string'
|
77
|
-
# raise "value #{value} from class #{value.class.name} does not match attribute property type #{self._type}" unless value.kind_of?(String) || value.kind_of?(Occi::Core::Entity)
|
78
|
-
# else
|
79
|
-
# raise "property type #{self._type} is not one of the allowed types number, boolean or string"
|
80
|
-
# end
|
81
|
-
# raise "value #{value} does not match pattern #{self._pattern}" if value.to_s.scan(Regexp.new(self._pattern)).empty? unless value.kind_of?(Occi::Core::Entity)
|
82
|
-
# @_value = value
|
83
|
-
# end
|
84
|
-
#
|
85
|
-
# def inspect
|
86
|
-
# self._value
|
87
|
-
# end
|
88
|
-
#
|
89
|
-
# def to_s
|
90
|
-
# self._value
|
91
|
-
# end
|
92
|
-
#
|
93
|
-
# def empty?
|
94
|
-
# self._value.nil?
|
95
|
-
# end
|
96
|
-
#
|
97
|
-
# end
|
98
|
-
# end
|
99
|
-
#end
|