occi-core 4.0.0.beta.1 → 4.0.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -159,6 +159,10 @@ module Occi
159
159
  case value
160
160
  when Occi::Core::Attributes
161
161
  hash[key] = value.as_json unless value.as_json.size == 0
162
+ when Occi::Core::Entity
163
+ hash[key] = value.to_s unless value.to_s.empty?
164
+ when Occi::Core::Category
165
+ hash[key] = value.to_s
162
166
  else
163
167
  hash[key] = value.as_json if value
164
168
  end
@@ -243,7 +243,7 @@ module Occi
243
243
  end
244
244
  attributes = []
245
245
  @attributes.names.each_pair do |name, value|
246
- attributes << name + '=' + value.inspect
246
+ attributes << name + '=' + value.to_s.inspect
247
247
  end
248
248
  header['X-OCCI-Attribute'] = attributes.join(',') if attributes.any?
249
249
  links = []
@@ -37,7 +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
+ self.attributes['occi.core.target'] = target
41
41
  @target = target
42
42
  end
43
43
 
@@ -50,7 +50,7 @@ module Occi
50
50
  # set source attribute of link
51
51
  # @param [String] source
52
52
  def source=(source)
53
- self.attributes['occi.core.source'] = source.to_s
53
+ self.attributes['occi.core.source'] = source
54
54
  @source = source
55
55
  end
56
56
 
@@ -78,11 +78,10 @@ module Occi
78
78
  categories = [@kind] + @mixins.join(',').split(',')
79
79
  string << ';category=' + categories.join(' ').inspect
80
80
  @attributes.names.each_pair do |name, value|
81
- value = value.inspect
81
+ next if value.to_s.blank?
82
+ value = value.to_s.inspect
82
83
  string << ';' + name + '=' + value
83
84
  end
84
- string << ';occi.core.target=' + self.target.to_s.inspect
85
- string << ';occi.core.source=' + self.source.to_s.inspect unless self.source.blank?
86
85
 
87
86
  string
88
87
  end
@@ -61,7 +61,8 @@ module Occi
61
61
  # @return [Hash] hash containing the HTTP headers of the text/occi rendering
62
62
  def to_header
63
63
  header = super
64
- header['Links'] = @links.join(',')
64
+ header['Links'] = @links.collect {|link| link.to_string }.join(',') if @links.any?
65
+ header
65
66
  end
66
67
 
67
68
  # @param [Hash] options
@@ -101,12 +101,12 @@ module Occi
101
101
  @attributes.occi!.compute!.state = state
102
102
  end
103
103
 
104
- def storagelink(target, mixins=[], attributes=Occi::Core::Attributes.new)
105
- link(target, Occi::Infrastructure::Storagelink.kind, mixins, attributes, rel=Occi::Infrastructure::Storage.type_identifier)
104
+ def storagelink(target, mixins=[], attributes=Occi::Core::Attributes.new, kind=Occi::Infrastructure::Storagelink.kind)
105
+ link(target, kind, mixins, attributes, rel=Occi::Infrastructure::Storage.type_identifier)
106
106
  end
107
107
 
108
- def networkinterface(target, mixins=[], attributes=Occi::Core::Attributes.new)
109
- link(target, Occi::Infrastructure::Networkinterface.kind, mixins, attributes)
108
+ def networkinterface(target, mixins=[], attributes=Occi::Core::Attributes.new, kind=Occi::Infrastructure::Networkinterface.kind)
109
+ link(target, kind, mixins, attributes, rel=Occi::Infrastructure::Network.type_identifier)
110
110
  end
111
111
 
112
112
  def storagelinks
data/lib/occi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Occi
2
- VERSION = "4.0.0.beta.1" unless defined?(::Occi::VERSION)
2
+ VERSION = "4.0.0.beta.2" unless defined?(::Occi::VERSION)
3
3
  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.0.0.beta.1
4
+ version: 4.0.0.beta.2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-07-28 00:00:00.000000000 Z
14
+ date: 2013-08-01 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: json