archivesspace-client 0.5.1 → 0.6.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d62f24f62e27e4dcb265982a09d19929029a12d7926983137f7835b9e945ec8d
4
- data.tar.gz: 88b7f1d79f02207cba4dfbb6334fae4a7080adca8634c6c52b53d6616398dfd0
3
+ metadata.gz: 5c792727aefb570967d0bd3d69330cc609275d0553cfb439392330bcab2af638
4
+ data.tar.gz: c33eb46a9194ade5465a64c0bce98b9f5796f22ef097f0e628e171659437a03f
5
5
  SHA512:
6
- metadata.gz: d776656385e5e84c4ba0adfec158e6a43ef60720aec43108a15e6e307adaf5022eb2168d463cdc74f4657aae62bbea80662d851dc65aee8a4ed02b1f9cc432d2
7
- data.tar.gz: 482eeab5c389e3433bae0102a687dfc42ede31792bf0b9bafcd2b0ec22492769523c42639718f9c202fc83abd2b08b6b798a7827826441c2ee951de9d817eda9
6
+ metadata.gz: afcb7ffbf95842a8c62a7e1a8616c98f3a5113cfdedd8a47d069cde7a495604a02476f3cbfe75a9192fc14772738da22ea61f1c47682e6d094eaf590070ee722
7
+ data.tar.gz: e8ea7debe60ac9eaf21b4e413703e12c322f935842e54488fcde08806b1babecba1bf91e1ad4e6cf9df53447416b23267f27a0cdc514244db1510b41707a46ac
data/README.md CHANGED
@@ -145,7 +145,8 @@ end
145
145
  ```
146
146
 
147
147
  Scopes restore the previous context on exit (even if the block raises) and can
148
- be nested:
148
+ be nested. Call `repository` with no id to nest a global-scope block inside a
149
+ repository scope:
149
150
 
150
151
  ```ruby
151
152
  client.repository(2) do
@@ -153,6 +154,11 @@ client.repository(2) do
153
154
  client.resources # scoped to repo 3
154
155
  end
155
156
  client.resources # back to repo 2
157
+
158
+ client.repository do
159
+ client.get('repositories') # global scope
160
+ end
161
+ client.resources # back to repo 2 again
156
162
  end
157
163
 
158
164
  # now back in the global scope
@@ -260,6 +266,15 @@ main/master branch a new release will be built and published.
260
266
 
261
267
  ## Changelog
262
268
 
269
+ ### 0.6.0
270
+
271
+ * Support global scope within a nested context. This makes it much
272
+ more ergonomic to request uris within a repository context.
273
+
274
+ ### 0.5.1
275
+
276
+ * Fix: prevent caller options passed to request from being mutated.
277
+
263
278
  ### 0.5.0
264
279
 
265
280
  Breaking changes:
@@ -42,18 +42,22 @@ module ArchivesSpace
42
42
  end
43
43
 
44
44
  # Scoping requests
45
- def repository(id)
46
- return use_global_repository if id.nil?
47
-
48
- begin
49
- Integer(id)
50
- rescue ArgumentError, TypeError
51
- raise RepositoryIdError, "Invalid Repository id: #{id}"
45
+ def repository(id = nil)
46
+ if id.nil?
47
+ return use_global_repository unless block_given?
48
+
49
+ new_context = nil
50
+ else
51
+ begin
52
+ Integer(id)
53
+ rescue ArgumentError, TypeError
54
+ raise RepositoryIdError, "Invalid Repository id: #{id}"
55
+ end
56
+
57
+ new_context = "repositories/#{id}"
58
+ return @context = new_context unless block_given?
52
59
  end
53
60
 
54
- new_context = "repositories/#{id}"
55
- return @context = new_context unless block_given?
56
-
57
61
  previous = @context
58
62
  @context = new_context
59
63
  begin
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ArchivesSpace
4
4
  class Client
5
- VERSION = "0.5.1"
5
+ VERSION = "0.6.0"
6
6
  end
7
7
  end
@@ -141,6 +141,39 @@ describe ArchivesSpace::Client do
141
141
  expect(client.context).to eq "repositories/2"
142
142
  end
143
143
 
144
+ it "scopes to the global repository within a block and restores afterwards" do
145
+ client.repository 2
146
+ client.repository(nil) do
147
+ expect(client.context).to be_nil
148
+ end
149
+ expect(client.context).to eq "repositories/2"
150
+ end
151
+
152
+ it "scopes to the global repository when called with no id and a block" do
153
+ client.repository 2
154
+ client.repository do
155
+ expect(client.context).to be_nil
156
+ end
157
+ expect(client.context).to eq "repositories/2"
158
+ end
159
+
160
+ it "nests a no-arg global block inside a repository block and restores both contexts" do
161
+ client.repository(2) do
162
+ expect(client.context).to eq "repositories/2"
163
+ client.repository do
164
+ expect(client.context).to be_nil
165
+ end
166
+ expect(client.context).to eq "repositories/2"
167
+ end
168
+ expect(client.context).to be_nil
169
+ end
170
+
171
+ it "restores the previous repository context even if a nil-scoped block raises" do
172
+ client.repository 2
173
+ expect { client.repository(nil) { raise "boom" } }.to raise_error("boom")
174
+ expect(client.context).to eq "repositories/2"
175
+ end
176
+
144
177
  it "restores the context even if the block raises" do
145
178
  expect { client.repository(2) { raise "boom" } }.to raise_error("boom")
146
179
  expect(client.context).to be_nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: archivesspace-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Cooper
@@ -269,7 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
269
  - !ruby/object:Gem::Version
270
270
  version: '0'
271
271
  requirements: []
272
- rubygems_version: 4.0.10
272
+ rubygems_version: 4.0.11
273
273
  specification_version: 4
274
274
  summary: Interact with ArchivesSpace via the API.
275
275
  test_files: []