occi-core 4.2.2 → 4.2.3
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/occi/core/entity.rb +2 -2
- data/lib/occi/core/link.rb +1 -1
- data/lib/occi/core/mixin.rb +2 -2
- data/lib/occi/core/resource.rb +1 -1
- data/lib/occi/parser/text.rb +1 -1
- data/lib/occi/parser/text/constants.rb +4 -2
- data/lib/occi/version.rb +1 -1
- data/spec/occi/core/entity_spec.rb +2 -2
- metadata +2 -2
data/lib/occi/core/entity.rb
CHANGED
@@ -201,7 +201,7 @@ module Occi
|
|
201
201
|
|
202
202
|
text << @attributes.to_text
|
203
203
|
|
204
|
-
@actions.each { |action| text << "\nLink: <#{self.location}?action=#{action.term}>;rel=#{action.to_s}" }
|
204
|
+
@actions.each { |action| text << "\nLink: <#{self.location}?action=#{action.term}>;rel=#{action.to_s.inspect}" }
|
205
205
|
|
206
206
|
text
|
207
207
|
end
|
@@ -221,7 +221,7 @@ module Occi
|
|
221
221
|
header['X-OCCI-Attribute'] = attributes unless attributes.blank?
|
222
222
|
|
223
223
|
links = []
|
224
|
-
@actions.each { |action| links << "<#{self.location}?action=#{action.term}>;rel=#{action.to_s}" }
|
224
|
+
@actions.each { |action| links << "<#{self.location}?action=#{action.term}>;rel=#{action.to_s.inspect}" }
|
225
225
|
header['Link'] = links.join(',') if links.any?
|
226
226
|
|
227
227
|
header
|
data/lib/occi/core/link.rb
CHANGED
@@ -77,7 +77,7 @@ module Occi
|
|
77
77
|
string << ";rel=#{@rel.to_s.inspect}"
|
78
78
|
string << ";self=#{self.location.inspect}" if self.location
|
79
79
|
|
80
|
-
categories = [@kind]
|
80
|
+
categories = [@kind.type_identifier].concat(@mixins.to_a.collect { |m| m.type_identifier })
|
81
81
|
string << ";category=#{categories.join(' ').inspect}"
|
82
82
|
|
83
83
|
string << @attributes.to_string
|
data/lib/occi/core/mixin.rb
CHANGED
@@ -32,7 +32,7 @@ module Occi
|
|
32
32
|
# @param kind [Occi::Core::Mixin, String] Mixin or Type Identifier of a Mixin where relation should be checked.
|
33
33
|
# @return [true,false]
|
34
34
|
def related_to?(mixin)
|
35
|
-
self.to_s == mixin.to_s || self.related.
|
35
|
+
self.to_s == mixin.to_s || self.related.any? { |m| m.type_identifier == mixin.to_s }
|
36
36
|
end
|
37
37
|
|
38
38
|
def location
|
@@ -40,7 +40,7 @@ module Occi
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def related
|
43
|
-
self.depends.to_a
|
43
|
+
self.depends.to_a
|
44
44
|
end
|
45
45
|
|
46
46
|
# @param [Hash] options
|
data/lib/occi/core/resource.rb
CHANGED
@@ -65,7 +65,7 @@ module Occi
|
|
65
65
|
# @return [Hash] hash containing the HTTP headers of the text/occi rendering
|
66
66
|
def to_header
|
67
67
|
header = super
|
68
|
-
header['
|
68
|
+
header['Link'] = @links.collect {|link| link.to_string }.join(',') if @links.any?
|
69
69
|
header
|
70
70
|
end
|
71
71
|
|
data/lib/occi/parser/text.rb
CHANGED
@@ -106,7 +106,7 @@ module Occi
|
|
106
106
|
term = match[:term].downcase
|
107
107
|
scheme = match[:scheme]
|
108
108
|
title = match[:title]
|
109
|
-
related = match[:rel].to_s.split
|
109
|
+
related = match[:rel].to_s.split(/\s+/)
|
110
110
|
|
111
111
|
attributes = Occi::Core::Attributes.new
|
112
112
|
if match[:attributes]
|
@@ -20,6 +20,8 @@ module Occi
|
|
20
20
|
REGEXP_TYPE_IDENTIFIER = /#{REGEXP_SCHEME}#{REGEXP_TERM}/
|
21
21
|
REGEXP_TYPE_IDENTIFIER_STRICT = /#{REGEXP_SCHEME}#{REGEXP_TERM_STRICT}/
|
22
22
|
REGEXP_CLASS = /\b(?<!\|)action(?!\|)\b|\b(?<!\|)mixin(?!\|)\b|\b(?<!\|)kind(?!\|)\b/
|
23
|
+
REGEXP_TYPE_IDENTIFIER_LIST = /#{REGEXP_TYPE_IDENTIFIER}(\s+#{REGEXP_TYPE_IDENTIFIER})*/
|
24
|
+
REGEXP_TYPE_IDENTIFIER_LIST_STRICT = /#{REGEXP_TYPE_IDENTIFIER_STRICT}(\s+#{REGEXP_TYPE_IDENTIFIER_STRICT})*/
|
23
25
|
|
24
26
|
REGEXP_ATTR_COMPONENT = /#{REGEXP_LOALPHA}(#{REGEXP_LOALPHA}|#{REGEXP_DIGIT}|-|_)*/
|
25
27
|
REGEXP_ATTRIBUTE_NAME = /#{REGEXP_ATTR_COMPONENT}(\.#{REGEXP_ATTR_COMPONENT})*/
|
@@ -44,7 +46,7 @@ module Occi
|
|
44
46
|
";\\s*scheme=\"(?<scheme>#{REGEXP_SCHEME})#{REGEXP_TERM}?\"" << # scheme (mandatory)
|
45
47
|
";\\s*class=\"?(?<class>#{REGEXP_CLASS})\"?" << # class (mandatory)
|
46
48
|
"(;\\s*title=\"(?<title>#{REGEXP_QUOTED_STRING})\")?" << # title (optional)
|
47
|
-
"(;\\s*rel=\"(?<rel>#{
|
49
|
+
"(;\\s*rel=\"(?<rel>#{REGEXP_TYPE_IDENTIFIER_LIST})\")?"<< # rel (optional)
|
48
50
|
"(;\\s*location=\"(?<location>#{URI::URI_REF})\")?" << # location (optional)
|
49
51
|
"(;\\s*attributes=\"(?<attributes>#{REGEXP_ATTRIBUTE_LIST})\")?" << # attributes (optional)
|
50
52
|
"(;\\s*actions=\"(?<actions>#{REGEXP_ACTION_LIST})\")?" << # actions (optional)
|
@@ -53,7 +55,7 @@ module Occi
|
|
53
55
|
";\\s*scheme=\"(?<scheme>#{REGEXP_SCHEME})\"" << # scheme (mandatory)
|
54
56
|
";\\s*class=\"(?<class>#{REGEXP_CLASS})\"" << # class (mandatory)
|
55
57
|
"(;\\s*title=\"(?<title>#{REGEXP_QUOTED_STRING})\")?" << # title (optional)
|
56
|
-
"(;\\s*rel=\"(?<rel>#{
|
58
|
+
"(;\\s*rel=\"(?<rel>#{REGEXP_TYPE_IDENTIFIER_LIST_STRICT})\")?"<< # rel (optional)
|
57
59
|
"(;\\s*location=\"(?<location>#{URI::URI_REF})\")?" << # location (optional)
|
58
60
|
"(;\\s*attributes=\"(?<attributes>#{REGEXP_ATTRIBUTE_LIST})\")?" << # attributes (optional)
|
59
61
|
"(;\\s*actions=\"(?<actions>#{REGEXP_ACTION_LIST_STRICT})\")?" << # actions (optional)
|
data/lib/occi/version.rb
CHANGED
@@ -145,7 +145,7 @@ X-OCCI-Attribute: occi.core.id="baf1"|
|
|
145
145
|
Category: mymixin;scheme="http://example.com/mynamespace#";class="mixin"
|
146
146
|
X-OCCI-Attribute: occi.core.id="baf1"
|
147
147
|
X-OCCI-Attribute: occi.core.title="TestTitle"
|
148
|
-
Link: </TestLoc/1?action=testaction>;rel=http://schemas.ogf.org/occi/core/entity/action#testaction|
|
148
|
+
Link: </TestLoc/1?action=testaction>;rel="http://schemas.ogf.org/occi/core/entity/action#testaction"|
|
149
149
|
expect(entity.to_text).to eq(expected)
|
150
150
|
end
|
151
151
|
end
|
@@ -168,7 +168,7 @@ Link: </TestLoc/1?action=testaction>;rel=http://schemas.ogf.org/occi/core/entity
|
|
168
168
|
expected = Hashie::Mash.new
|
169
169
|
expected['Category'] = 'entity;scheme="http://schemas.ogf.org/occi/core#";class="kind",mymixin;scheme="http://example.com/mynamespace#";class="mixin"'
|
170
170
|
expected['X-OCCI-Attribute'] = 'occi.core.id="baf1",occi.core.title="TestTitle"'
|
171
|
-
expected['Link'] = '</TestLoc/1?action=testaction>;rel=http://schemas.ogf.org/occi/core/entity/action#testaction'
|
171
|
+
expected['Link'] = '</TestLoc/1?action=testaction>;rel="http://schemas.ogf.org/occi/core/entity/action#testaction"'
|
172
172
|
|
173
173
|
expect(entity.to_header).to eql(expected)
|
174
174
|
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.
|
4
|
+
version: 4.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -276,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
276
276
|
version: '0'
|
277
277
|
segments:
|
278
278
|
- 0
|
279
|
-
hash:
|
279
|
+
hash: 3508725164324827292
|
280
280
|
requirements: []
|
281
281
|
rubyforge_project:
|
282
282
|
rubygems_version: 1.8.25
|