occi-core 4.2.3 → 4.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/occi/collection.rb +40 -12
- data/lib/occi/version.rb +1 -1
- data/spec/occi/collection_spec.rb +3 -2
- metadata +5 -22
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZDU3NTg4MzhjZGYyMGI0N2Y3M2ViYmRmMTA2ZWI5OWY3YjYwMzcxZA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OGRmNTk3NmIwZGUwNWQ3ZTlhN2Y4YjA4NDU4MzJkMmIxZDg4NDExMA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
N2E0MTUzMTlmZDlhYzZjYzZjOGZmYjgxNjZlZmY5NzA4NDk5ZmMyOWY0ZmJm
|
10
|
+
ODlkMzJlM2IyN2IzMjI1ODI3NDdjYWI3YTI5OWY0Y2QxYzdjZWUyYTgyN2Uz
|
11
|
+
MmQ4YTU1ZWFhNDlhN2IzNjUwYmRkZDJjZDUxYjRjYmVjZDg3OWM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZWNlMTdkYWYwMmNiNzZiZjRjYTExOTFjYzA1OTg2ODgyZjQ0M2UyZDk4Y2Q3
|
14
|
+
ZDg4MmJiYjFjYmU3YWIwYzcyOTdmNDIwOGM4YjNlMmYxNjBhODMwZTczOTI1
|
15
|
+
ZWJkN2EzMzUwZDJiMjBkZWFmM2ZiYjk0MjFmYmNkYTJkMjZkYTI=
|
data/lib/occi/collection.rb
CHANGED
@@ -153,9 +153,10 @@ module Occi
|
|
153
153
|
collection.mixins = @mixins.collect { |mixin| mixin.as_json } if @mixins.any?
|
154
154
|
collection.actions = @actions.collect { |action_category| action_category.as_json } if @actions.any?
|
155
155
|
collection.resources = @resources.collect { |resource| resource.as_json } if @resources.any?
|
156
|
+
|
156
157
|
# if there is only one resource and the links inside the resource have no location,
|
157
158
|
# then these links must be rendered as separate links inside the collection
|
158
|
-
if
|
159
|
+
if collection.resources && collection.resources.size == 1
|
159
160
|
if collection.resources.first.links.blank? && @links.empty?
|
160
161
|
lnks = @resources.first.links
|
161
162
|
else
|
@@ -165,6 +166,7 @@ module Occi
|
|
165
166
|
lnks = @links
|
166
167
|
end
|
167
168
|
collection.links = lnks.collect { |link| link.as_json } if lnks.to_a.any?
|
169
|
+
|
168
170
|
collection.action = @action.as_json if @action
|
169
171
|
collection
|
170
172
|
end
|
@@ -172,22 +174,40 @@ module Occi
|
|
172
174
|
# @return [String] text representation
|
173
175
|
def to_text
|
174
176
|
text = ""
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
177
|
+
|
178
|
+
if standalone_links?
|
179
|
+
raise "Only one standalone link allowed for rendering to text/plain" if self.links.size > 1
|
180
|
+
text << self.links.first.to_text
|
181
|
+
elsif standalone_action_instance?
|
182
|
+
text << self.action.to_text
|
183
|
+
else
|
184
|
+
text << self.categories.collect { |category| category.to_text }.join("\n")
|
185
|
+
text << "\n" if self.categories.any?
|
186
|
+
raise "Only one resource allowed for rendering to text/plain" if self.resources.size > 1
|
187
|
+
text << self.resources.first.to_text if self.resources.any?
|
188
|
+
text << self.links.collect { |link| link.to_text_link }.join("\n")
|
189
|
+
text << self.action.to_text if self.action
|
190
|
+
end
|
191
|
+
|
181
192
|
text
|
182
193
|
end
|
183
194
|
|
184
195
|
def to_header
|
185
196
|
header = Hashie::Mash.new
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
197
|
+
|
198
|
+
if standalone_links?
|
199
|
+
raise "Only one standalone link allowed for rendering to text/occi" if self.links.size > 1
|
200
|
+
header = self.links.first.to_header
|
201
|
+
elsif standalone_action_instance?
|
202
|
+
header = self.action.to_header
|
203
|
+
else
|
204
|
+
header['Category'] = self.categories.collect { |category| category.to_string_short }.join(',') if self.categories.any?
|
205
|
+
raise "Only one resource allowed for rendering to text/occi" if self.resources.size > 1
|
206
|
+
header = self.class.header_merge(header, self.resources.first.to_header) if self.resources.any?
|
207
|
+
header['Link'] = self.links.collect { |link| link.to_string }.join(',') if self.links.any?
|
208
|
+
header = self.class.header_merge(header, self.action.to_header) if self.action
|
209
|
+
end
|
210
|
+
|
191
211
|
header
|
192
212
|
end
|
193
213
|
|
@@ -204,5 +224,13 @@ module Occi
|
|
204
224
|
target
|
205
225
|
end
|
206
226
|
|
227
|
+
def standalone_links?
|
228
|
+
!self.links.blank? && self.categories.blank? && self.resources.blank? && self.action.blank?
|
229
|
+
end
|
230
|
+
|
231
|
+
def standalone_action_instance?
|
232
|
+
!self.action.blank? && self.categories.blank? && self.entities.blank?
|
233
|
+
end
|
234
|
+
|
207
235
|
end
|
208
236
|
end
|
data/lib/occi/version.rb
CHANGED
@@ -855,7 +855,7 @@ module Occi
|
|
855
855
|
|
856
856
|
it 'renders text correctly, links only' do
|
857
857
|
collection.links << Occi::Core::Link.new
|
858
|
-
expected = "
|
858
|
+
expected = "Category: link;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\"\nX-OCCI-Attribute: occi.core.id=\"#{collection.links.first.id}\""
|
859
859
|
expect(collection.to_text).to eql(expected)
|
860
860
|
end
|
861
861
|
|
@@ -925,7 +925,8 @@ module Occi
|
|
925
925
|
it 'renders text correctly, links only' do
|
926
926
|
collection.links << Occi::Core::Link.new
|
927
927
|
expected=Hashie::Mash.new
|
928
|
-
expected["
|
928
|
+
expected["Category"] = "link;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\""
|
929
|
+
expected["X-OCCI-Attribute"] = "occi.core.id=\"#{collection.links.first.id}\""
|
929
930
|
expect(collection.to_header).to eql(expected)
|
930
931
|
end
|
931
932
|
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: occi-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
5
|
-
prerelease:
|
4
|
+
version: 4.2.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Florian Feldhaus
|
@@ -11,12 +10,11 @@ authors:
|
|
11
10
|
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date:
|
13
|
+
date: 2014-01-06 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: json
|
18
17
|
requirement: !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
18
|
requirements:
|
21
19
|
- - ! '>='
|
22
20
|
- !ruby/object:Gem::Version
|
@@ -24,7 +22,6 @@ dependencies:
|
|
24
22
|
type: :runtime
|
25
23
|
prerelease: false
|
26
24
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
25
|
requirements:
|
29
26
|
- - ! '>='
|
30
27
|
- !ruby/object:Gem::Version
|
@@ -32,7 +29,6 @@ dependencies:
|
|
32
29
|
- !ruby/object:Gem::Dependency
|
33
30
|
name: hashie
|
34
31
|
requirement: !ruby/object:Gem::Requirement
|
35
|
-
none: false
|
36
32
|
requirements:
|
37
33
|
- - ! '>='
|
38
34
|
- !ruby/object:Gem::Version
|
@@ -40,7 +36,6 @@ dependencies:
|
|
40
36
|
type: :runtime
|
41
37
|
prerelease: false
|
42
38
|
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
39
|
requirements:
|
45
40
|
- - ! '>='
|
46
41
|
- !ruby/object:Gem::Version
|
@@ -48,7 +43,6 @@ dependencies:
|
|
48
43
|
- !ruby/object:Gem::Dependency
|
49
44
|
name: uuidtools
|
50
45
|
requirement: !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
46
|
requirements:
|
53
47
|
- - ! '>='
|
54
48
|
- !ruby/object:Gem::Version
|
@@ -56,7 +50,6 @@ dependencies:
|
|
56
50
|
type: :runtime
|
57
51
|
prerelease: false
|
58
52
|
version_requirements: !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
53
|
requirements:
|
61
54
|
- - ! '>='
|
62
55
|
- !ruby/object:Gem::Version
|
@@ -64,7 +57,6 @@ dependencies:
|
|
64
57
|
- !ruby/object:Gem::Dependency
|
65
58
|
name: nokogiri
|
66
59
|
requirement: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
60
|
requirements:
|
69
61
|
- - ~>
|
70
62
|
- !ruby/object:Gem::Version
|
@@ -72,7 +64,6 @@ dependencies:
|
|
72
64
|
type: :runtime
|
73
65
|
prerelease: false
|
74
66
|
version_requirements: !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
67
|
requirements:
|
77
68
|
- - ~>
|
78
69
|
- !ruby/object:Gem::Version
|
@@ -80,7 +71,6 @@ dependencies:
|
|
80
71
|
- !ruby/object:Gem::Dependency
|
81
72
|
name: activesupport
|
82
73
|
requirement: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
74
|
requirements:
|
85
75
|
- - ~>
|
86
76
|
- !ruby/object:Gem::Version
|
@@ -88,7 +78,6 @@ dependencies:
|
|
88
78
|
type: :runtime
|
89
79
|
prerelease: false
|
90
80
|
version_requirements: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
81
|
requirements:
|
93
82
|
- - ~>
|
94
83
|
- !ruby/object:Gem::Version
|
@@ -96,7 +85,6 @@ dependencies:
|
|
96
85
|
- !ruby/object:Gem::Dependency
|
97
86
|
name: settingslogic
|
98
87
|
requirement: !ruby/object:Gem::Requirement
|
99
|
-
none: false
|
100
88
|
requirements:
|
101
89
|
- - ! '>='
|
102
90
|
- !ruby/object:Gem::Version
|
@@ -104,7 +92,6 @@ dependencies:
|
|
104
92
|
type: :runtime
|
105
93
|
prerelease: false
|
106
94
|
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
95
|
requirements:
|
109
96
|
- - ! '>='
|
110
97
|
- !ruby/object:Gem::Version
|
@@ -258,29 +245,25 @@ files:
|
|
258
245
|
homepage: https://github.com/gwdg/rOCCI-core
|
259
246
|
licenses:
|
260
247
|
- Apache License, Version 2.0
|
248
|
+
metadata: {}
|
261
249
|
post_install_message:
|
262
250
|
rdoc_options: []
|
263
251
|
require_paths:
|
264
252
|
- lib
|
265
253
|
required_ruby_version: !ruby/object:Gem::Requirement
|
266
|
-
none: false
|
267
254
|
requirements:
|
268
255
|
- - ! '>='
|
269
256
|
- !ruby/object:Gem::Version
|
270
257
|
version: 1.9.3
|
271
258
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
272
|
-
none: false
|
273
259
|
requirements:
|
274
260
|
- - ! '>='
|
275
261
|
- !ruby/object:Gem::Version
|
276
262
|
version: '0'
|
277
|
-
segments:
|
278
|
-
- 0
|
279
|
-
hash: 3508725164324827292
|
280
263
|
requirements: []
|
281
264
|
rubyforge_project:
|
282
|
-
rubygems_version: 1.
|
265
|
+
rubygems_version: 2.1.11
|
283
266
|
signing_key:
|
284
|
-
specification_version:
|
267
|
+
specification_version: 4
|
285
268
|
summary: OCCI toolkit
|
286
269
|
test_files: []
|