occi-core 4.2.13 → 4.2.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b13e9998a9a2ccb704efa4c1cbb283ae7aa7d46
4
- data.tar.gz: c8e5a5a2dfe2df264cd24c46e86f7ec3d28b10b9
3
+ metadata.gz: 97bfbcd8727b44c08e826dbbe76a6f7c05034a5c
4
+ data.tar.gz: b549d11e985dc2ef189b17fe6e51d02b26fdb75b
5
5
  SHA512:
6
- metadata.gz: 2093cc6c116bf9dc2e281a57ba5cfc2b05528e81da87695bc6a46c4078830c4575e9fde4aff0392edcea820b6c6f20e5c3a9232e83aacb54930f09d9701b9937
7
- data.tar.gz: 01acb909e3a5942c83988de6966fb036827d07e7ac481b6862358356b99d06d79c0335de9151d9bdf3ab8f2d6fda5dbb38dba44a22eea40331568358ac069740
6
+ metadata.gz: b48367de96eccf0689868a85e72fb3eadc0576f2bbc7e9cf3248538aa5a21e943cc66e6aeeb3dd679be635b6613453df410330efb731aa92606e649c52f3ba75
7
+ data.tar.gz: d735235babe4e5405902d583504957ee15a0235037566f7adb4cc152aa74da33c8525236b92c723687951541da5480031c1787a2e4a6f3d7e70a6336552e3164
@@ -11,7 +11,7 @@ module Occi
11
11
  self.kind = Occi::Core::Kind.new scheme='http://schemas.ogf.org/occi/core#',
12
12
  term='link',
13
13
  title='link',
14
- attributes=self.attributes,
14
+ attributes=Occi::Core::Attributes.new(self.attributes),
15
15
  parent=Occi::Core::Entity.kind
16
16
 
17
17
  # @param [String] kind
@@ -38,8 +38,8 @@ module Occi
38
38
  # set target attribute of link
39
39
  # @param [String] target
40
40
  def target=(target)
41
- self.attributes['occi.core.target'] = target
42
- @target = target
41
+ self.attributes['occi.core.target'] = target.to_s
42
+ @target = target.to_s
43
43
  end
44
44
 
45
45
  # @return [String] source attribute of the link
@@ -51,13 +51,13 @@ module Occi
51
51
  # set source attribute of link
52
52
  # @param [String] source
53
53
  def source=(source)
54
- self.attributes['occi.core.source'] = source
55
- @source = source
54
+ self.attributes['occi.core.source'] = source.to_s
55
+ @source = source.to_s
56
56
  end
57
57
 
58
58
  # Runs check on attributes
59
- def check
60
- raise ArgumentError, "Cannot run check on #{self.to_s} without relation (@rel attribute) set" unless @rel
59
+ def check(set_defaults = false)
60
+ raise ArgumentError, "Cannot run check on #{self.to_s.inspect} kind #{self.kind.to_s.inspect} without relation (the rel attribute) set!" unless @rel
61
61
  super
62
62
  end
63
63
 
data/lib/occi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Occi
2
- VERSION = "4.2.13" unless defined?(::Occi::VERSION)
2
+ VERSION = "4.2.14" unless defined?(::Occi::VERSION)
3
3
  end
@@ -8,9 +8,11 @@ module Occi
8
8
  context '#check' do
9
9
  let(:defs){
10
10
  defs = Occi::Core::Attributes.new
11
- defs['occi.core.id'] = { :type=> 'string', :required => true }
12
- defs['stringtype'] = { :type => 'string', :pattern => '[adefltuv]+',
11
+ defs['occi.core.id'] = { :type=> 'string', :required => true }
12
+ defs['stringtype'] = { :type => 'string', :pattern => '[adefltuv]+',
13
13
  :default => 'defaultforlink', :mutable => true, :required => true }
14
+ defs['stringtypeoptional'] = { :type => 'string', :pattern => '[adefltuv]+',
15
+ :default => 'defaultforlink', :mutable => true, :required => false }
14
16
  defs }
15
17
 
16
18
  it 'sets default for required attribute' do
@@ -22,6 +24,19 @@ module Occi
22
24
 
23
25
  link.check
24
26
  expect(link.attributes['stringtype']).to eql 'defaultforlink'
27
+ expect(link.attributes['stringtypeoptional']).to be_nil
28
+ end
29
+
30
+ it 'accepts the set_defaults flag' do
31
+ link = Occi::Core::Link.new
32
+ link.kind.attributes.merge!(defs)
33
+ model = Occi::Model.new
34
+ model.register(link.kind)
35
+ link.model = model
36
+
37
+ link.check(true)
38
+ expect(link.attributes['stringtype']).to eql 'defaultforlink'
39
+ expect(link.attributes['stringtypeoptional']).to eql 'defaultforlink'
25
40
  end
26
41
 
27
42
  it 'raises error if no relationship is set' do
@@ -17,7 +17,7 @@ module Occi
17
17
  end
18
18
 
19
19
  it 'sets the right target' do
20
- expect(resource.links.first.target).to eql target
20
+ expect(resource.links.first.target).to eql target.to_s
21
21
  end
22
22
  end
23
23
 
@@ -27,12 +27,12 @@ module Occi
27
27
 
28
28
  it "has the correct link as target" do
29
29
  compute.storagelink target
30
- expect(compute.links.first.target).to be target
30
+ expect(compute.links.first.target).to eq target.to_s
31
31
  end
32
32
 
33
33
  it "has target with correct ID" do
34
34
  compute.storagelink target
35
- expect(compute.links.first.target.id).to eq target.id
35
+ expect(compute.links.first.target.split('/').last).to eq target.id
36
36
  end
37
37
  end
38
38
 
@@ -55,7 +55,7 @@ module Occi
55
55
  it 'shows correctly in collections' do
56
56
  compute.storagelink target
57
57
  compute.model=modl
58
- expect(compute.storagelinks[0].target.id).to eq target.id
58
+ expect(compute.storagelinks[0].target.split('/').last).to eq target.id
59
59
  end
60
60
  end
61
61
  end
@@ -80,7 +80,7 @@ module Occi
80
80
 
81
81
  it "has the correct interface as target" do
82
82
  compute.networkinterface target
83
- expect(compute.links.first.target).to be target
83
+ expect(compute.links.first.target).to eq target.to_s
84
84
  end
85
85
  end
86
86
 
@@ -103,7 +103,7 @@ module Occi
103
103
  it 'shows correctly in collections' do
104
104
  compute.networkinterface target
105
105
  compute.model=modl
106
- expect(compute.networkinterfaces[0].target.id).to eq target.id
106
+ expect(compute.networkinterfaces[0].target.split('/').last).to eq target.id
107
107
  end
108
108
  end
109
109
  end
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.2.13
4
+ version: 4.2.14
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: 2014-04-08 00:00:00.000000000 Z
13
+ date: 2014-04-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -242,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
242
  version: '0'
243
243
  requirements: []
244
244
  rubyforge_project:
245
- rubygems_version: 2.1.11
245
+ rubygems_version: 2.2.2
246
246
  signing_key:
247
247
  specification_version: 4
248
248
  summary: OCCI toolkit