duracloud-client 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/duracloud.gemspec +1 -1
- data/gemfiles/Gemfile.activemodel-4.1 +3 -0
- data/gemfiles/Gemfile.activemodel-4.2 +3 -0
- data/lib/duracloud/properties.rb +8 -0
- data/lib/duracloud/space.rb +4 -5
- data/lib/duracloud/space_acls.rb +28 -0
- data/lib/duracloud/version.rb +1 -1
- data/spec/unit/space_acls_spec.rb +5 -0
- data/spec/unit/space_spec.rb +20 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aea6659762321bf17ab4ebb8e64267be0516cc0f
|
4
|
+
data.tar.gz: f156ad57e051818a4ceb30a0e1f9ecf43d875f7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ade9f4d0a1ffafff2b16e368c22a9e00a5bd714e300832ebf42cda0a99ac24c3f36e43fc542fafce5913e316feac47e14b0aaf8017473f0ce8a602073af79ad3
|
7
|
+
data.tar.gz: 310a399f320345f3c8ea7ba4e3187c97f82c2796f9e3c1b689065d1c36f8b171d4dc29d447393496faaa4010ceb984091d1ed57c417201a7c5a6282e95f8c456
|
data/.travis.yml
CHANGED
data/duracloud.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_dependency "hashie", "~> 3.4"
|
24
24
|
spec.add_dependency "httpclient", "~> 2.7"
|
25
|
-
spec.add_dependency "activemodel", "~> 4.
|
25
|
+
spec.add_dependency "activemodel", "~> 4.1"
|
26
26
|
spec.add_dependency "nokogiri", "~> 1.6"
|
27
27
|
|
28
28
|
spec.add_development_dependency "webmock", "~> 2.0"
|
data/lib/duracloud/properties.rb
CHANGED
@@ -89,6 +89,14 @@ module Duracloud
|
|
89
89
|
self.class.property?(prop)
|
90
90
|
end
|
91
91
|
|
92
|
+
# Filter the hash of properties, selecting only the properties valid
|
93
|
+
# for this particular usage (subclass).
|
94
|
+
# @param hsh [Hash] the unfiltered properties
|
95
|
+
# @return [Hash] the filtered properties
|
96
|
+
def filter(hsh)
|
97
|
+
self.class.filter(hsh)
|
98
|
+
end
|
99
|
+
|
92
100
|
# @api private
|
93
101
|
def regular_writer(key, value)
|
94
102
|
if property?(key)
|
data/lib/duracloud/space.rb
CHANGED
@@ -9,6 +9,8 @@ module Duracloud
|
|
9
9
|
include Persistence
|
10
10
|
include HasProperties
|
11
11
|
|
12
|
+
after_save :reset_acls
|
13
|
+
|
12
14
|
# Max size of content item list for one request.
|
13
15
|
# This limit is imposed by Duracloud.
|
14
16
|
MAX_RESULTS = 1000
|
@@ -230,6 +232,7 @@ module Duracloud
|
|
230
232
|
|
231
233
|
def create
|
232
234
|
Client.create_space(id, **query)
|
235
|
+
update unless acls.empty?
|
233
236
|
end
|
234
237
|
|
235
238
|
def update
|
@@ -250,11 +253,7 @@ module Duracloud
|
|
250
253
|
end
|
251
254
|
|
252
255
|
def do_save
|
253
|
-
|
254
|
-
update
|
255
|
-
else
|
256
|
-
create
|
257
|
-
end
|
256
|
+
persisted? ? update : create
|
258
257
|
end
|
259
258
|
|
260
259
|
def query
|
data/lib/duracloud/space_acls.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
module Duracloud
|
2
2
|
class SpaceAcls < Properties
|
3
3
|
|
4
|
+
READ = "READ".freeze
|
5
|
+
WRITE = "WRITE".freeze
|
6
|
+
|
7
|
+
ACL_PREFIX = (PREFIX + "acl-").freeze
|
8
|
+
|
4
9
|
def self.property?(prop)
|
5
10
|
space_acl?(prop)
|
6
11
|
end
|
@@ -20,5 +25,28 @@ module Duracloud
|
|
20
25
|
{ storeID: space.store_id }
|
21
26
|
end
|
22
27
|
|
28
|
+
def show
|
29
|
+
each_with_object({}) do |(k, v), memo|
|
30
|
+
memo[k.sub(ACL_PREFIX, "")] = v
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def grant(perm, to)
|
35
|
+
prop = ACL_PREFIX + to
|
36
|
+
self[prop] = perm
|
37
|
+
end
|
38
|
+
|
39
|
+
def grant_write(to)
|
40
|
+
grant WRITE, to
|
41
|
+
end
|
42
|
+
|
43
|
+
def grant_read(to)
|
44
|
+
grant READ, to
|
45
|
+
end
|
46
|
+
|
47
|
+
def revoke(from)
|
48
|
+
prop = ACL_PREFIX + from
|
49
|
+
delete prop
|
50
|
+
end
|
23
51
|
end
|
24
52
|
end
|
data/lib/duracloud/version.rb
CHANGED
data/spec/unit/space_spec.rb
CHANGED
@@ -87,7 +87,26 @@ EOS
|
|
87
87
|
|
88
88
|
describe "#delete"
|
89
89
|
|
90
|
-
describe "#acls"
|
90
|
+
describe "#acls" do
|
91
|
+
let(:url) { "https://example.com/durastore/foo" }
|
92
|
+
subject { Space.find("foo") }
|
93
|
+
before {
|
94
|
+
stub_request(:head, url)
|
95
|
+
allow(Client).to receive(:get_space_acls)
|
96
|
+
.with("foo", hash_including(storeID: nil)) {
|
97
|
+
double(body: "",
|
98
|
+
headers: {
|
99
|
+
'x-dura-meta-acl-bob'=>'READ',
|
100
|
+
'x-dura-meta-acl-group-curators'=>'WRITE'
|
101
|
+
})
|
102
|
+
}
|
103
|
+
}
|
104
|
+
specify {
|
105
|
+
expect(subject.acls.to_h)
|
106
|
+
.to eq({'x-dura-meta-acl-bob'=>'READ',
|
107
|
+
'x-dura-meta-acl-group-curators'=>'WRITE'})
|
108
|
+
}
|
109
|
+
end
|
91
110
|
|
92
111
|
describe "contents" do
|
93
112
|
let(:body) { <<-EOS
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: duracloud-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Chandek-Stark
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '4.
|
47
|
+
version: '4.1'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '4.
|
54
|
+
version: '4.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: nokogiri
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,6 +151,8 @@ files:
|
|
151
151
|
- README.md
|
152
152
|
- Rakefile
|
153
153
|
- duracloud.gemspec
|
154
|
+
- gemfiles/Gemfile.activemodel-4.1
|
155
|
+
- gemfiles/Gemfile.activemodel-4.2
|
154
156
|
- lib/duracloud-client.rb
|
155
157
|
- lib/duracloud.rb
|
156
158
|
- lib/duracloud/audit_log.rb
|
@@ -186,6 +188,7 @@ files:
|
|
186
188
|
- spec/unit/content_spec.rb
|
187
189
|
- spec/unit/manifest_spec.rb
|
188
190
|
- spec/unit/properties_spec.rb
|
191
|
+
- spec/unit/space_acls_spec.rb
|
189
192
|
- spec/unit/space_spec.rb
|
190
193
|
- spec/unit/store_spec.rb
|
191
194
|
homepage: https://github.com/duracloud/duracloud-ruby-client
|
@@ -223,5 +226,6 @@ test_files:
|
|
223
226
|
- spec/unit/content_spec.rb
|
224
227
|
- spec/unit/manifest_spec.rb
|
225
228
|
- spec/unit/properties_spec.rb
|
229
|
+
- spec/unit/space_acls_spec.rb
|
226
230
|
- spec/unit/space_spec.rb
|
227
231
|
- spec/unit/store_spec.rb
|