occi-core 4.2.11 → 4.2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/lib/occi/core/entity.rb +20 -9
- data/lib/occi/core/kind.rb +11 -3
- data/lib/occi/core/mixin.rb +11 -3
- data/lib/occi/version.rb +1 -1
- data/spec/occi/collection_spec.rb +6 -6
- data/spec/occi/core/entity_spec.rb +25 -5
- data/spec/occi/core/kind_spec.rb +27 -0
- data/spec/occi/core/mixin_spec.rb +38 -0
- metadata +12 -11
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MWExYTgyNzM0ZjU4NzA4MjhjNjRkNzZiZDBhZjI4N2IwNmY5ZTdkMw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8ae8a9a2f1e04abc912900002e1a20ffc7d14c4a
|
4
|
+
data.tar.gz: e61f0a1b597466384b814c331792dd27e0cfd0e9
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YmVjNGEyMzkxZjM4OTI4MGFmZDg5ZjA5NTFkNGM1ODFiMjg3MmY4N2FhNTVk
|
11
|
-
ZDZlNWY0NDg2YzZhMDdiNjZkNTIyN2NkODA4MjBkNTYyNGMyZTM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZDhmN2JjNzFmZTFjYTg2NTRiNjU1MjkwZjkyMDFkNGU5YWY5ZjkzYzQxZWEw
|
14
|
-
OWZlNjAzZDRhZGYyMDk3Njk1MzcwYTgzZmQ1OTEzYmNmODJjODM0ODBjZTc0
|
15
|
-
ZmEzOTUyMmJiNTk5ZTliMjQ1ZmI5YzMyNDcxNzA3ZWRmYzVhMjM=
|
6
|
+
metadata.gz: 80566d28dd52b33ce23de9cb2dff9943d2a082a04a6acf8dfecdab40b79a20aaa08b20f7b7bcd7712c4dfad34d85e2c6de82a9b8cacc3729db4069e65d50e9ec
|
7
|
+
data.tar.gz: 09dfb7c50b7ad1c603df9affc70406e4bb59a430844f965e8380430bc957af17cf0e5dcbe525d5935fc7e42b69a8edb8bc95953761670be128daf04ed044f21e
|
data/lib/occi/core/entity.rb
CHANGED
@@ -5,7 +5,7 @@ module Occi
|
|
5
5
|
include Occi::Helpers::Inspect
|
6
6
|
include Occi::Helpers::Comparators::Entity
|
7
7
|
|
8
|
-
attr_accessor :mixins, :attributes, :actions, :id, :model
|
8
|
+
attr_accessor :mixins, :attributes, :actions, :id, :model
|
9
9
|
attr_reader :kind
|
10
10
|
|
11
11
|
class_attribute :kind, :mixins, :attributes, :actions
|
@@ -76,7 +76,7 @@ module Occi
|
|
76
76
|
@attributes['occi.core.id'] ||= UUIDTools::UUID.random_create.to_s
|
77
77
|
|
78
78
|
@actions = Occi::Core::Actions.new actions
|
79
|
-
@location = location
|
79
|
+
@location = location ? URI.parse(location).path : nil
|
80
80
|
end
|
81
81
|
|
82
82
|
# @param [Occi::Core::Kind,String] kind
|
@@ -147,13 +147,24 @@ module Occi
|
|
147
147
|
# set location attribute of entity
|
148
148
|
# @param [String] location
|
149
149
|
def location=(location)
|
150
|
-
@location = location
|
150
|
+
@location = location ? URI.parse(location).path : nil
|
151
151
|
end
|
152
152
|
|
153
153
|
# @return [String] location of the entity
|
154
154
|
def location
|
155
|
-
return @location if @location
|
156
|
-
|
155
|
+
return @location.clone if @location
|
156
|
+
return if id.blank? || kind.location.blank?
|
157
|
+
|
158
|
+
# guess the location from kind and ID
|
159
|
+
# check for kind locations already included in IDs
|
160
|
+
tmp_id = id.gsub('urn:uuid:', '')
|
161
|
+
@location = if tmp_id.start_with?(kind.location)
|
162
|
+
# ID by itself is enough
|
163
|
+
tmp_id
|
164
|
+
else
|
165
|
+
# concat kind location and ID, remove duplicated slashes
|
166
|
+
"#{kind.location}#{tmp_id}".gsub(/\/+/, '/')
|
167
|
+
end
|
157
168
|
end
|
158
169
|
|
159
170
|
# check attributes against their definitions and set defaults
|
@@ -197,11 +208,11 @@ module Occi
|
|
197
208
|
|
198
209
|
# @return [String] text representation
|
199
210
|
def to_text
|
200
|
-
text = "Category: #{self.kind.term};scheme=#{self.kind.scheme.inspect};class=\"kind\""
|
211
|
+
text = "Category: #{self.kind.term};scheme=#{self.kind.scheme.inspect};class=\"kind\";location=#{self.kind.location.inspect}"
|
201
212
|
@mixins.each do |mixin|
|
202
213
|
scheme, term = mixin.to_s.split('#')
|
203
214
|
scheme << '#'
|
204
|
-
text << "\nCategory: #{term};scheme=#{scheme.inspect};class=\"mixin\""
|
215
|
+
text << "\nCategory: #{term};scheme=#{scheme.inspect};class=\"mixin\";location=#{mixin.location.inspect}"
|
205
216
|
end
|
206
217
|
|
207
218
|
text << @attributes.to_text
|
@@ -214,12 +225,12 @@ module Occi
|
|
214
225
|
# @return [Hash] hash containing the HTTP headers of the text/occi rendering
|
215
226
|
def to_header
|
216
227
|
header = Hashie::Mash.new
|
217
|
-
header['Category'] = "#{self.kind.term};scheme=#{self.kind.scheme.inspect};class=\"kind\""
|
228
|
+
header['Category'] = "#{self.kind.term};scheme=#{self.kind.scheme.inspect};class=\"kind\";location=#{self.kind.location.inspect}"
|
218
229
|
|
219
230
|
@mixins.each do |mixin|
|
220
231
|
scheme, term = mixin.to_s.split('#')
|
221
232
|
scheme << '#'
|
222
|
-
header['Category'] << ",#{term};scheme=#{scheme.inspect};class=\"mixin\""
|
233
|
+
header['Category'] << ",#{term};scheme=#{scheme.inspect};class=\"mixin\";location=#{mixin.location.inspect}"
|
223
234
|
end
|
224
235
|
|
225
236
|
attributes = @attributes.to_header
|
data/lib/occi/core/kind.rb
CHANGED
@@ -2,7 +2,7 @@ module Occi
|
|
2
2
|
module Core
|
3
3
|
class Kind < Occi::Core::Category
|
4
4
|
|
5
|
-
attr_accessor :entities, :parent, :actions
|
5
|
+
attr_accessor :entities, :parent, :actions
|
6
6
|
|
7
7
|
# @param scheme [String ] The categorisation scheme.
|
8
8
|
# @param term [String] Unique identifier of the Kind instance within the categorisation scheme.
|
@@ -21,7 +21,7 @@ module Occi
|
|
21
21
|
@parent = [parent].flatten.first
|
22
22
|
@actions = Occi::Core::Actions.new(actions)
|
23
23
|
@entities = Occi::Core::Entities.new
|
24
|
-
location.blank? ?
|
24
|
+
@location = location.blank? ? "/#{term}/" : URI.parse(location).path
|
25
25
|
end
|
26
26
|
|
27
27
|
# @param scheme [String] The categorisation scheme.
|
@@ -96,8 +96,16 @@ module Occi
|
|
96
96
|
self.class.get_class self.scheme, self.term, self.parent
|
97
97
|
end
|
98
98
|
|
99
|
+
# set location attribute of kind
|
100
|
+
# @param [String] location
|
101
|
+
def location=(location)
|
102
|
+
location = URI.parse(location).path if location
|
103
|
+
raise "Kind locations must end with a slash!" unless location.blank? || location =~ /^\/\S+\/$/
|
104
|
+
@location = location
|
105
|
+
end
|
106
|
+
|
99
107
|
def location
|
100
|
-
@location.clone
|
108
|
+
@location ? @location.clone : nil
|
101
109
|
end
|
102
110
|
|
103
111
|
def related
|
data/lib/occi/core/mixin.rb
CHANGED
@@ -2,7 +2,7 @@ module Occi
|
|
2
2
|
module Core
|
3
3
|
class Mixin < Occi::Core::Category
|
4
4
|
|
5
|
-
attr_accessor :entities, :depends, :actions, :
|
5
|
+
attr_accessor :entities, :depends, :actions, :applies
|
6
6
|
|
7
7
|
# @param [String] scheme
|
8
8
|
# @param [String] term
|
@@ -25,7 +25,7 @@ module Occi
|
|
25
25
|
@depends = Occi::Core::Dependencies.new depends
|
26
26
|
@actions = Occi::Core::Actions.new actions
|
27
27
|
@entities = Occi::Core::Entities.new
|
28
|
-
@location = location.blank? ? "/mixin/#{term}/" : location
|
28
|
+
@location = location.blank? ? "/mixin/#{term}/" : URI.parse(location).path
|
29
29
|
@applies = Occi::Core::Kinds.new applies
|
30
30
|
end
|
31
31
|
|
@@ -37,8 +37,16 @@ module Occi
|
|
37
37
|
self.to_s == mixin.to_s || self.related.any? { |m| m.type_identifier == mixin.to_s }
|
38
38
|
end
|
39
39
|
|
40
|
+
# set location attribute of kind
|
41
|
+
# @param [String] location
|
42
|
+
def location=(location)
|
43
|
+
location = URI.parse(location).path if location
|
44
|
+
raise "Mixin locations must end with a slash!" unless location.blank? || location =~ /^\/\S+\/$/
|
45
|
+
@location = location
|
46
|
+
end
|
47
|
+
|
40
48
|
def location
|
41
|
-
@location.clone
|
49
|
+
@location ? @location.clone : nil
|
42
50
|
end
|
43
51
|
|
44
52
|
def related
|
data/lib/occi/version.rb
CHANGED
@@ -833,7 +833,7 @@ module Occi
|
|
833
833
|
collection.resources << Occi::Core::Resource.new
|
834
834
|
collection.links << Occi::Core::Link.new
|
835
835
|
|
836
|
-
expected = "Category: compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";title=\"compute resource\";rel=\"http://schemas.ogf.org/occi/core#resource\";location=\"/compute/\";attributes=\"occi.core.id{immutable} occi.core.title occi.core.summary occi.compute.architecture occi.compute.cores occi.compute.hostname occi.compute.memory occi.compute.speed occi.compute.state{immutable}\";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\"\nCategory: my_mixin;scheme=\"http://example.com/occi/tags#\";class=\"mixin\";location=\"/mixin/my_mixin/\"\nCategory: start;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\"\nCategory: resource;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\"\nX-OCCI-Attribute: occi.core.id=\"#{collection.resources.first.id}\"Link: <>;rel=\"http://schemas.ogf.org/occi/core#link\";self=\"/link/#{collection.links.first.id}\";category=\"http://schemas.ogf.org/occi/core#link\";occi.core.id=\"#{collection.links.first.id}\"Category: action_instance;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"action\""
|
836
|
+
expected = "Category: compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";title=\"compute resource\";rel=\"http://schemas.ogf.org/occi/core#resource\";location=\"/compute/\";attributes=\"occi.core.id{immutable} occi.core.title occi.core.summary occi.compute.architecture occi.compute.cores occi.compute.hostname occi.compute.memory occi.compute.speed occi.compute.state{immutable}\";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\"\nCategory: my_mixin;scheme=\"http://example.com/occi/tags#\";class=\"mixin\";location=\"/mixin/my_mixin/\"\nCategory: start;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\"\nCategory: resource;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";location=\"/resource/\"\nX-OCCI-Attribute: occi.core.id=\"#{collection.resources.first.id}\"Link: <>;rel=\"http://schemas.ogf.org/occi/core#link\";self=\"/link/#{collection.links.first.id}\";category=\"http://schemas.ogf.org/occi/core#link\";occi.core.id=\"#{collection.links.first.id}\"Category: action_instance;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"action\""
|
837
837
|
expect(collection.to_text).to eql(expected)
|
838
838
|
end
|
839
839
|
|
@@ -871,13 +871,13 @@ module Occi
|
|
871
871
|
|
872
872
|
it 'renders text correctly, resources only' do
|
873
873
|
collection.resources << Occi::Core::Resource.new
|
874
|
-
expected = "Category: resource;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\"\nX-OCCI-Attribute: occi.core.id=\"#{collection.resources.first.id}\""
|
874
|
+
expected = "Category: resource;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";location=\"/resource/\"\nX-OCCI-Attribute: occi.core.id=\"#{collection.resources.first.id}\""
|
875
875
|
expect(collection.to_text).to eql(expected)
|
876
876
|
end
|
877
877
|
|
878
878
|
it 'renders text correctly, links only' do
|
879
879
|
collection.links << Occi::Core::Link.new
|
880
|
-
expected = "Category: link;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\"\nX-OCCI-Attribute: occi.core.id=\"#{collection.links.first.id}\""
|
880
|
+
expected = "Category: link;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";location=\"/link/\"\nX-OCCI-Attribute: occi.core.id=\"#{collection.links.first.id}\""
|
881
881
|
expect(collection.to_text).to eql(expected)
|
882
882
|
end
|
883
883
|
|
@@ -894,7 +894,7 @@ module Occi
|
|
894
894
|
collection.links << Occi::Core::Link.new
|
895
895
|
|
896
896
|
expected=Hashie::Mash.new
|
897
|
-
expected["Category"] = "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\",my_mixin;scheme=\"http://example.com/occi/tags#\";class=\"mixin\",start;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\",resource;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\",action_instance;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"action\""
|
897
|
+
expected["Category"] = "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\",my_mixin;scheme=\"http://example.com/occi/tags#\";class=\"mixin\",start;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute/action#\";class=\"action\",resource;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";location=\"/resource/\",action_instance;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"action\""
|
898
898
|
expected["Link"] = "<>;rel=\"http://schemas.ogf.org/occi/core#link\";self=\"/link/#{collection.links.first.id}\";category=\"http://schemas.ogf.org/occi/core#link\";occi.core.id=\"#{collection.links.first.id}\""
|
899
899
|
expected["X-OCCI-Attribute"] = "occi.core.id=\"#{collection.resources.first.id}\""
|
900
900
|
expect(collection.to_header).to eql(expected)
|
@@ -939,7 +939,7 @@ module Occi
|
|
939
939
|
it 'renders text correctly, resources only' do
|
940
940
|
collection.resources << Occi::Core::Resource.new
|
941
941
|
expected=Hashie::Mash.new
|
942
|
-
expected["Category"] = "resource;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\""
|
942
|
+
expected["Category"] = "resource;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";location=\"/resource/\""
|
943
943
|
expected["X-OCCI-Attribute"] = "occi.core.id=\"#{collection.resources.first.id}\""
|
944
944
|
expect(collection.to_header).to eql(expected)
|
945
945
|
end
|
@@ -947,7 +947,7 @@ module Occi
|
|
947
947
|
it 'renders text correctly, links only' do
|
948
948
|
collection.links << Occi::Core::Link.new
|
949
949
|
expected=Hashie::Mash.new
|
950
|
-
expected["Category"] = "link;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\""
|
950
|
+
expected["Category"] = "link;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";location=\"/link/\""
|
951
951
|
expected["X-OCCI-Attribute"] = "occi.core.id=\"#{collection.links.first.id}\""
|
952
952
|
expect(collection.to_header).to eql(expected)
|
953
953
|
end
|
@@ -104,6 +104,26 @@ module Occi
|
|
104
104
|
entity.id = UUIDTools::UUID.random_create.to_s
|
105
105
|
expect(entity.location).to eq '/entity/' + entity.id
|
106
106
|
end
|
107
|
+
|
108
|
+
it 'gets normalized to a relative path' do
|
109
|
+
entity.location = 'http://example.org/entity/12'
|
110
|
+
expect(entity.location).to eq '/entity/12'
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'can be set to nil and default to /kind/id' do
|
114
|
+
entity.location = nil
|
115
|
+
expect(entity.location).to eq '/entity/baf1'
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'will not duplicate slashes' do
|
119
|
+
entity.id = '//baf1'
|
120
|
+
expect(entity.location).to eq '/entity/baf1'
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'will not duplicate kind location' do
|
124
|
+
entity.id = '/entity/baf1'
|
125
|
+
expect(entity.location).to eq '/entity/baf1'
|
126
|
+
end
|
107
127
|
end
|
108
128
|
|
109
129
|
context '#title' do
|
@@ -130,7 +150,7 @@ module Occi
|
|
130
150
|
|
131
151
|
context '#to_text' do
|
132
152
|
it 'renders fresh instance in text correctly' do
|
133
|
-
expected = %Q|Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind"
|
153
|
+
expected = %Q|Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";location="/entity/"
|
134
154
|
X-OCCI-Attribute: occi.core.id="baf1"|
|
135
155
|
expect(entity.to_text).to eq(expected)
|
136
156
|
end
|
@@ -141,8 +161,8 @@ X-OCCI-Attribute: occi.core.id="baf1"|
|
|
141
161
|
entity.location = '/TestLoc/1'
|
142
162
|
entity.mixins << 'http://example.com/mynamespace#mymixin'
|
143
163
|
|
144
|
-
expected = %Q|Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind"
|
145
|
-
Category: mymixin;scheme="http://example.com/mynamespace#";class="mixin"
|
164
|
+
expected = %Q|Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";location="/entity/"
|
165
|
+
Category: mymixin;scheme="http://example.com/mynamespace#";class="mixin";location="/mixin/mymixin/"
|
146
166
|
X-OCCI-Attribute: occi.core.id="baf1"
|
147
167
|
X-OCCI-Attribute: occi.core.title="TestTitle"
|
148
168
|
Link: </TestLoc/1?action=testaction>;rel="http://schemas.ogf.org/occi/core/entity/action#testaction"|
|
@@ -153,7 +173,7 @@ Link: </TestLoc/1?action=testaction>;rel="http://schemas.ogf.org/occi/core/entit
|
|
153
173
|
context '#to_header' do
|
154
174
|
it 'renders fresh instance in HTTP Header correctly' do
|
155
175
|
expected = Hashie::Mash.new
|
156
|
-
expected['Category'] = 'entity;scheme="http://schemas.ogf.org/occi/core#";class="kind"'
|
176
|
+
expected['Category'] = 'entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";location="/entity/"'
|
157
177
|
expected['X-OCCI-Attribute'] = 'occi.core.id="baf1"'
|
158
178
|
|
159
179
|
expect(entity.to_header).to eql(expected)
|
@@ -166,7 +186,7 @@ Link: </TestLoc/1?action=testaction>;rel="http://schemas.ogf.org/occi/core/entit
|
|
166
186
|
entity.mixins << 'http://example.com/mynamespace#mymixin'
|
167
187
|
|
168
188
|
expected = Hashie::Mash.new
|
169
|
-
expected['Category'] = 'entity;scheme="http://schemas.ogf.org/occi/core#";class="kind",mymixin;scheme="http://example.com/mynamespace#";class="mixin"'
|
189
|
+
expected['Category'] = 'entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";location="/entity/",mymixin;scheme="http://example.com/mynamespace#";class="mixin";location="/mixin/mymixin/"'
|
170
190
|
expected['X-OCCI-Attribute'] = 'occi.core.id="baf1",occi.core.title="TestTitle"'
|
171
191
|
expected['Link'] = '</TestLoc/1?action=testaction>;rel="http://schemas.ogf.org/occi/core/entity/action#testaction"'
|
172
192
|
|
data/spec/occi/core/kind_spec.rb
CHANGED
@@ -86,6 +86,33 @@ module Occi
|
|
86
86
|
|
87
87
|
end
|
88
88
|
|
89
|
+
describe '#location' do
|
90
|
+
let(:kind) { Occi::Core::Kind.new }
|
91
|
+
|
92
|
+
it 'gets normalized to a relative path' do
|
93
|
+
kind.location = 'http://example.org/kind/'
|
94
|
+
expect(kind.location).to eq '/kind/'
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'can be set to nil' do
|
98
|
+
kind.location = nil
|
99
|
+
expect(kind.location).to be_nil
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'raises an error when location does not start and end with a slash' do
|
103
|
+
expect { kind.location = '/no_slash' }.to raise_error
|
104
|
+
expect { kind.location = 'no_slash/' }.to raise_error
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'raises an error when location contains spaces' do
|
108
|
+
expect { kind.location = '/sla shes/' }.to raise_error
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'can be set to an empty string' do
|
112
|
+
expect { kind.location = '' }.not_to raise_error
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
89
116
|
describe '#related_to?' do
|
90
117
|
let(:base){ Occi::Core::Kind.new 'http://occi.test.case/core/kind', 'base' }
|
91
118
|
let(:related){ Occi::Core::Kind.new 'http://occi.test.case/core/kind/base', 'related', 'title', Occi::Core::Attributes.new, base }
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Occi
|
2
|
+
module Core
|
3
|
+
describe Mixin do
|
4
|
+
|
5
|
+
describe '#location' do
|
6
|
+
let(:mixin) { Occi::Core::Mixin.new }
|
7
|
+
|
8
|
+
it 'defaults to /mixin/term/' do
|
9
|
+
expect(mixin.location).to eq '/mixin/mixin/'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'gets normalized to a relative path' do
|
13
|
+
mixin.location = 'http://example.org/mixin/'
|
14
|
+
expect(mixin.location).to eq '/mixin/'
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'can be set to nil' do
|
18
|
+
mixin.location = nil
|
19
|
+
expect(mixin.location).to be_nil
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'raises an error when location does not start and end with a slash' do
|
23
|
+
expect { mixin.location = '/no_slash' }.to raise_error
|
24
|
+
expect { mixin.location = 'no_slash/' }.to raise_error
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'raises an error when location contains spaces' do
|
28
|
+
expect { mixin.location = '/sla shes/' }.to raise_error
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'can be set to an empty string' do
|
32
|
+
expect { mixin.location = '' }.not_to raise_error
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
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.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Feldhaus
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
name: json
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - '>='
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '0'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: hashie
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- -
|
33
|
+
- - '>='
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: '0'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- -
|
40
|
+
- - '>='
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '0'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: uuidtools
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- -
|
47
|
+
- - '>='
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: 2.1.3
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- -
|
54
|
+
- - '>='
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: 2.1.3
|
57
57
|
- !ruby/object:Gem::Dependency
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
name: settingslogic
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- -
|
82
|
+
- - '>='
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
description: OCCI is a collection of classes to simplify the implementation of the
|
@@ -178,6 +178,7 @@ files:
|
|
178
178
|
- spec/occi/core/kind_spec.rb
|
179
179
|
- spec/occi/core/link_spec.rb
|
180
180
|
- spec/occi/core/links_spec.rb
|
181
|
+
- spec/occi/core/mixin_spec.rb
|
181
182
|
- spec/occi/core/mixins_spec.rb
|
182
183
|
- spec/occi/core/properties_spec.rb
|
183
184
|
- spec/occi/core/resource_spec.rb
|
@@ -231,12 +232,12 @@ require_paths:
|
|
231
232
|
- lib
|
232
233
|
required_ruby_version: !ruby/object:Gem::Requirement
|
233
234
|
requirements:
|
234
|
-
- -
|
235
|
+
- - '>='
|
235
236
|
- !ruby/object:Gem::Version
|
236
237
|
version: 1.9.3
|
237
238
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
238
239
|
requirements:
|
239
|
-
- -
|
240
|
+
- - '>='
|
240
241
|
- !ruby/object:Gem::Version
|
241
242
|
version: '0'
|
242
243
|
requirements: []
|