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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59d7bfce0068c8362b66814cb1b02804fda5bba8
4
- data.tar.gz: e01c0afa6b9369450862d5189ea0954cf2c90491
3
+ metadata.gz: aea6659762321bf17ab4ebb8e64267be0516cc0f
4
+ data.tar.gz: f156ad57e051818a4ceb30a0e1f9ecf43d875f7b
5
5
  SHA512:
6
- metadata.gz: 8ec2713a12f89c42e7b9fb9117d94051ebed80c610f64123ec33ef8226c0c72934c2369cbaba4799da6a6511baecdd9be4946bd88c10c909f08f025fe5787c7c
7
- data.tar.gz: b779ccb8781e2a9fc40208766dd87442024f70c2e6c1e643fc0a7270892093c2d00f5bfce7c6e3efa341cfef9a61f4f966a5e6a2900da44a2b73de3e55ebba39
6
+ metadata.gz: ade9f4d0a1ffafff2b16e368c22a9e00a5bd714e300832ebf42cda0a99ac24c3f36e43fc542fafce5913e316feac47e14b0aaf8017473f0ce8a602073af79ad3
7
+ data.tar.gz: 310a399f320345f3c8ea7ba4e3187c97f82c2796f9e3c1b689065d1c36f8b171d4dc29d447393496faaa4010ceb984091d1ed57c417201a7c5a6282e95f8c456
data/.travis.yml CHANGED
@@ -2,4 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - 2.1
4
4
  - 2.2
5
-
5
+ - 2.3.0
6
+ gemfile:
7
+ - gemfiles/Gemfile.activemodel-4.1
8
+ - gemfiles/Gemfile.activemodel-4.2
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.2"
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"
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gem "activemodel", "~> 4.1.16"
3
+ gemspec path: "../"
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gem "activemodel", "~> 4.2.7"
3
+ gemspec path: "../"
@@ -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)
@@ -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
- if persisted?
254
- update
255
- else
256
- create
257
- end
256
+ persisted? ? update : create
258
257
  end
259
258
 
260
259
  def query
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Duracloud
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -0,0 +1,5 @@
1
+ module Duracloud
2
+ RSpec.describe SpaceAcls do
3
+
4
+ end
5
+ end
@@ -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.2
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-05-19 00:00:00.000000000 Z
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.2'
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.2'
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